[BUG] Library not loaded: '/opt/homebrew/opt/unixodbc/lib/libodbc.2.dylib'
Describe your system
odbcPackage Version: 2.4.6- Database OS: mac 12.6 (m1)
- Node.js Version: 16.18.1
- Node.js OS: mac/electron
Describe the bug I am able to successfully package my electron application for mac with node-odbc, but when I actually open the application, I get the following fatal error:
Uncaught Error: dlopen(/Volumes/WebshipLink 0.1.5-arm64/WebshipLink.app/Contents/Resources/app.asar.unpacked/node_modules/odbc/lib/bindings/napi-v6/odbc.node, 0x0001): Library not loaded: '/opt/homebrew/opt/unixodbc/lib/libodbc.2.dylib'
Referenced from: '/Volumes/WebshipLink 0.1.5-arm64/WebshipLink.app/Contents/Resources/app.asar.unpacked/node_modules/odbc/lib/bindings/napi-v6/odbc.node'
Reason: tried: '/opt/homebrew/opt/unixodbc/lib/libodbc.2.dylib' (code signature in <567F0218-30B5-32A0-8400-BCCAEB9E27C0> '/opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbc.2.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)), '/usr/lib/libodbc.2.dylib' (no such file), '/opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbc.2.dylib' (code signature in <567F0218-30B5-32A0-8400-BCCAEB9E27C0> '/opt/homebrew/Cellar/unixodbc/2.3.11/lib/libodbc.2.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)), '/usr/lib/libodbc.2.dylib' (no such file)
at process.func [as dlopen] (node:electron/js2c/asar_bundle:5)
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1199)
at Object.func [as .node] (node:electron/js2c/asar_bundle:5)
at Module.load (node:internal/modules/cjs/loader:988)
at Module._load (node:internal/modules/cjs/loader:829)
at Function.c._load (node:electron/js2c/asar_bundle:5)
at Function.o._load (node:electron/js2c/renderer_init:33)
at Module.require (node:internal/modules/cjs/loader:1012)
at require (node:internal/modules/cjs/helpers:94)
at Object.<anonymous> (/Volumes/WebshipLink 0.1.5-arm64/WebshipLink.app/Contents/Resources/app.asar/node_modules/odbc/lib/odbc.js:6)
I'm able to install the library but I do get some warnings:
⠇ Building modules: 2/3 CXX(target) Release/obj.target/odbc/src/odbc_statement.o
⠙ Building modules: 2/3../src/odbc_statement.cpp:98:21: warning: private field 'odbcStatement' is not used [-Wunused-private-field]
ODBCStatement *odbcStatement;
^
../src/odbc_statement.cpp:99:21: warning: private field 'odbcConnection' is not used [-Wunused-private-field]
ODBCConnection *odbcConnection;
^
../src/odbc_statement.cpp:225:21: warning: private field 'odbcStatement' is not used [-Wunused-private-field]
ODBCStatement *odbcStatement;
^
../src/odbc_statement.cpp:226:21: warning: private field 'odbcConnection' is not used [-Wunused-private-field]
ODBCConnection *odbcConnection;
^
⠦ Building modules: 2/34 warnings generated.
CXX(target) Release/obj.target/odbc/src/odbc_cursor.o
⠸ Building modules: 2/3 CXX(target) Release/obj.target/odbc/src/dynodbc.o
SOLINK_MODULE(target) Release/odbc.node
⠼ Building modules: 2/3ld: warning: dylib (/opt/homebrew/lib/libodbc.dylib) was built for newer macOS version (12.0) than being linked (11.0)
COPY /Users/alex/Desktop/webship-link-2022/release/app/node_modules/odbc/lib/bindings/napi-v{napi_build_version}/odbc.node
TOUCH Release/obj.target/action_after_build.stamp
Do I need to build from a different version of mac? I've already installed unixodbc
To better demonstrate the issue, I created a repo based on this boilerplate https://github.com/todbot/electron-hid-test-erb
Here is a fairly minimal example that demonstrates the issue: https://github.com/rocksolidinternet/electron-odbc-mac-demo
when I run yarn start I see output that contains the row as a result of select 1 however, when I run yarn package, I get a fatal error when the app launches
I found a workaround that allows me to build while including node-odbc as a native dependency. I followed the steps here: https://stackoverflow.com/questions/71699960/signing-electron-build-for-m1-macs-causes-renderer-to-crash/71759691#71759691
Then I deleted both node_module directories, ran yarn and now I am able to successfully package the application.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.