tr1ckydev / webview-bun

Bun bindings for webview, a tiny library for creating web-based desktop GUIs.
https://www.npmjs.com/package/webview-bun
MIT License
201 stars 8 forks source link

ERR_DLOPEN_FAILED: Failed to open library. This is usually caused by a missing library or an invalid library path. #13

Open citkane opened 1 month ago

citkane commented 1 month ago

Linux64 (Debian 12) Bun 1.1.22 webview-bun 2.1.0

Webview-bun crashes with the titled error.

A number of related issues have already been closed with no obvious remedy, and the root of the problem (for Debian based distros anyways), seems to be this issue with LD_LIBRARY_PATH.

I have worked around this for now:

  1. Locally building the webview binary for my specific environment.
  2. Copying the built libwebview.so into .../myApp/bin.
  3. Running myApp with WEBVIEW_PATH=bin/libwebview.so bun run src/myApp.ts.

My libview.so build is however likely to fail on a different linux environment of an end user...

I have tried to use the npm bundled webview binary by setting export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH (the spot for Debian 12), but this still fails. This leads me to suspect that the problem is in this repository's built binary, and that a "one binary fits all linux" situation is not true.

Maybe when webview-bun builds the linux binary at its lowest level, there is an option to pass export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/local/lib64/:$LD_LIBRARY_PATH?

tr1ckydev commented 1 day ago

It may be also helpful to provide ldd libwebview.so output from your system.

Now in the latest commit I integrated webview's own build system to create the library instead of relying on my own build commands previously.

Please test this again with the now compiled library in this repo and report back!