Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open my app, error: Library not loaded: /opt/homebrew/opt/llvm/lib/libunwind.1.dylib #8716

Open
cobbcheng opened this issue Dec 2, 2024 · 4 comments

Comments

@cobbcheng
Copy link

  • Electron-Builder Version: 26.0.0-alpha.6
  • Node Version: v20.10.0
  • Electron Version: 31.0.2

  • Electron Type (current, beta, nightly): current

  • Target: Production

Need I set the nativeRebuilder to 'legacy'?

Uncaught Exception:
Error: dlopen(/Applications/test.app/Contents/Resources/app.asar.unpacked/node_modules/@serialport/bindings-cpp/build/Release/bindings.node, 0x0001): Library not loaded: /opt/homebrew/opt/llvm/lib/libunwind.1.dylib
Referenced from: <046D978E-24B1-3B60-A5C6-2B997D1FA795> /Applications/test.app/Contents/Resources/app.asar.unpacked/node_modules/@serialport/bindings-cpp/build/Release/bindings.node
Reason: tried: '/opt/homebrew/opt/llvm/lib/libunwind.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/llvm/lib/libunwind.1.dylib' (no such file), '/opt/homebrew/opt/llvm/lib/libunwind.1.dylib' (no such file)
at process.func [as dlopen] (node:electron/js2c/node_init:2:2559)
at Module._extensions..node (node:internal/modules/cjs/loader:1470:18)
at Object.func [as .node] (node:electron/js2c/node_init:2:2786)
at Module.load (node:internal/modules/cjs/loader:1215:32)
at Module._load (node:internal/modules/cjs/loader:1031:12)
at c._load (node:electron/js2c/node_init:2:17025)
at Module.require (node:internal/modules/cjs/loader:1240:19)
at require (node:internal/modules/helpers:179:18)
at load (/Applications/test.app/Contents/Resources/app.asar/node_modules/node-gyp-build/node-gyp-build.js:22:10)
at Object. (/Applications/test.app/Contents/Resources/app.asar/node_modules/@serialport/bindings-cpp/dist/load-bindings.js:11:46)

@mmaietta
Copy link
Collaborator

mmaietta commented Dec 2, 2024

This doesn't look related to the native rebuilder as it looks like this is an error at runtime. Is that correct? It also looks like a dependency on your system is not installed

@cobbcheng
Copy link
Author

This doesn't look related to the native rebuilder as it looks like this is an error at runtime. Is that correct? It also looks like a dependency on your system is not installed

But how do we package local dependencies into the application? We shouldn’t assume that the user has this dependency locally, right?

@rhzs
Copy link

rhzs commented Dec 11, 2024

Hi, i got this issue as well, when first time running it. How do I resolve it?

@cobbcheng
Copy link
Author

Hi, i got this issue as well, when first time running it. How do I resolve it?

Yes, I resolved this issue.
First, you need to create an afterPack.js script to fix the path. The problem arises because the serialport library depends on a dynamic library from the local LLVM.
You need to locate the libunwind.1.dylib file in your local LLVM and place it in your project. Its path is: /opt/homebrew/opt/llvm/lib/libunwind.1.dylib.
It is worth noting that on macOS, we typically use Homebrew for installations. Homebrew creates symlinks for dynamic libraries, which are pointers to the actual files. If you find that your local libunwind.1.dylib file is only a few bytes in size, it is likely a symlink. Run ls -l /opt/homebrew/opt/llvm/lib/libunwind.1.dylib to locate the actual file. Copy this file into your repository; I placed it in the resources directory.
Next, here’s the key step: execute the necessary commands in the afterPack.js script.

install_name_tool -change \
/opt/homebrew/opt/llvm/lib/libunwind.1.dylib \
@executable_path/../resources/lib/libunwind.1.dylib \
"./dist/mac-arm64/test.app/Contents/Resources/app.asar.unpacked/node_modules/@serialport/bindings-cpp/build/Release/bindings.node"

This command will redirect the dependency path in bindings.node from local to your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants