Reputation: 98
I'm trying to package @tensorflow/tfjs-node in an electron project. Everything works properly when I run electron locally, but when I try to package it using electron-forge I get an error
An unhandled rejection has occurred inside Forge:
Error: /var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-OpAoHn/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.2.dylib: file "../../../../../../../../../../../../var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-OpAoHn/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.2.7.0.dylib" links out of the package
at Filesystem.insertLink (/path/node_modules/@electron/asar/lib/filesystem.js:106:13)
at handleFile (/path/node_modules/@electron/asar/lib/asar.js:132:20)
at next (/path/node_modules/@electron/asar/lib/asar.js:148:11)
at next (/path/node_modules/@electron/asar/lib/asar.js:149:12)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async MacApp.asarApp (/path/node_modules/@electron/packager/dist/platform.js:200:9)
at async MacApp.buildApp (/path/node_modules/@electron/packager/dist/platform.js:124:9)
at async MacApp.initialize (/path/node_modules/@electron/packager/dist/platform.js:117:13)
at async MacApp.create (/path/node_modules/@electron/packager/dist/mac.js:321:9)
at async Promise.all (index 0)
at async packager (/path/node_modules/@electron/packager/dist/packager.js:237:22)
I found some other posts that looked similar suggesting a posthook script that removes the offending binary… but I actually need it! … so that doesn't work for me.
Is there a way that I can see what the dylib file is linking to that is outside the project? If I can do that, then is it possible to copy those files into the project and relink? or is that a rabbit hole that I shouldn't go down?
Possibly relevant information: OSX 14.4 on a M2 Mac Python 2.7.18 (also tried 3.11.5 before reading that tfjs-node requires 2.7)
"@tensorflow/tfjs-node": "^4.17.0",
"@electron-forge/cli": "^7.3.0",
"@electron-forge/maker-deb": "^7.3.0",
"@electron-forge/maker-rpm": "^7.3.0",
"@electron-forge/maker-squirrel": "^7.3.0",
"@electron-forge/maker-zip": "^7.3.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.3.0",
"@electron-forge/plugin-fuses": "^7.3.0",
"node-gyp": "^10.0.1"
I have tried removing the dylib file and the app is packaged but obviously fails at runtime. I have also tried changing python versions as I read that tfjs-node requires python version 2.7.
I expect that the required binaries will be copied into the packaged application so that it is portable to other machines without having to run through the command line.
I think I was able to figure out what external libraries the dylib files link to. They are all system libraries I believe.
1038:10:55~:: otool -L /private/var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-sePJID/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.2.7.0.dylib
/private/var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-sePJID/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.2.7.0.dylib:
@rpath/libtensorflow_framework.2.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1853.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1853.0.0)
1039:10:59~:: otool -L /private/var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-sePJID/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.2.7.0.dylib
/private/var/folders/7w/spt6jhj57gl2gs0vcfcc_jqh0000gp/T/electron-packager/tmp-sePJID/Electron.app/Contents/Resources/app/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.2.7.0.dylib:
@rpath/libtensorflow.2.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)
@rpath/libtensorflow_framework.2.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1853.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1853.0.0)
Upvotes: 0
Views: 133