nut-tree/libnut-core

Unable to find libnut bindings when packaging for Electron (OS X)

mattslight opened this issue · 1 comments

Version
nut-js 2.3.1@next
electron v20
os x 12.6
node 16.15.1

Short overview
When using electron-builder to package Electron, the build process finishes successfully. When launching either ARM64 or INTEL executable the following error is produced:

Uncaught Exception:
Error: Could not locate the bindings file. Tried:
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/build/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/build/Debug/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/build/Release/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/out/Debug/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/Debug/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/out/Release/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/Release/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/build/default/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/compiled/16.15.0/darwin/arm64/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/addon-build/release/install-root/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/addon-build/debug/install-root/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/addon-build/default/install-root/libnut.node
→ .../release/build/mac-arm64/Qissa.app/Contents/Resources/app.asar/lib/binding/node-v107-darwin-arm64/libnut.node

Steps to reproduce error

git clone --depth 1 --branch main https://github.com/electron-react-boilerplate/electron-react-boilerplate.git
npm install @nut-tree/nut-js@next

... add userland code calling nut.js

npm run package

OK I managed to fix the issue with a hack. I tried copying libnut.node to the app contents under the Resources/app folder (needed to use codesign to allow the file to be accessed).

I guess this is an issue with electron-builder rather than libnut - I'm trying to figure out how to tell the build script to sign and package libnut.node...