You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Electron: libvips-cpp.42.dylib image not found mac osx build #678
changed the title [-]libvips-cpp.42.dylib image not found mac osx build[/-][+]Electron: libvips-cpp.42.dylib image not found mac osx build[/+]on Jan 12, 2017
Hi Lovell,
yes I tried that page.
using electron 1.4.14
i tried rebuilding with the rebuild module: ./node_modules/.bin/electron-rebuild
same error..
I dont know if the issue is with the sharp module, node-gyp or electron-build/rebuild
but the problem only occurs on mac osx.. windows is fine (untested on linux)
binding.js#L32 places pre-compiled binaries in the node_modules/sharp/vendor directory at npm install time.
binding.gyp#L141-L142 sets the runtime location for rpath so the compiled sharp.node shared library can find the pre-compiled binaries.
My best guess is that Electron on OS X is using non-standard locations. /var/folders/rt/7f85090559l9jxmyt06cd_7w0000gn/T/.org.app.4Y18VM looks very much non-standard :(
I'm having the same issue. I'm on a Mac, Node 6.9.1, NPM 3.10.8, sharp 0.17.1
My app works locally with sharp. After using electron-builder to generate the Mac dist of my app, when I run it on a machine without libvips installed through brew, I get.
Uncaught Error: dlopen(/Applications/test.app/Contents/Resources/app/node_modules/sharp/build/Release/sharp.node, 1): Library not loaded: /usr/local/opt/vips/lib/libvips-cpp.42.dylib
Referenced from: /Applications/test.app/Contents/Resources/app/node_modules/sharp/build/Release/sharp.node
Reason: image not found
Which makes sense.. I think, since libvips can't be found. I'd hoped the pre-built versions inside node_modules/sharp would cover it.
Before creating the dist, I made sure to use electron-rebuild, and it says Building module: sharp. I don't however see a /vendor folder inside the node_modules/sharp, but the Build/ folder looks right.
Compiling native modules is new to me, I know you don't explicitly support electron but would love any insight you have.
The appearance of /usr/local/opt suggests libvips might have previously been installed, or at least enough of it remains for pkg-config --modversion vips-cpp to think it has found it.
From v0.17.x onwards you'll see the node_modules/sharp/vendor directory created at npm install time, which hopefully is also the case for the electron npm install command I think you'll need to use with Electron.
we need to use the asar option .. electron-builder claims to automate native module building
but its the same error above at runtime
could it be that the sharp module is misconfigured somehow..? is there a problem will modules that use node-gyp?
it the seems the workaround for mac is to use Electron-builder and the asarUnpack option: "build": { "asar": true, "appId": "myappid", "asarUnpack": [ "**/node_modules/sharp/**/*" ], "extraResources": [ "bg_mask.png" ], "mac": { "category": "app.beta.com", "icon": "assets/ico/mac_icon.icns" }, "win": { "iconUrl": "https://aurl.win_icon.ico" } },
this puts the sharp module outside asar... and it runs fine
Reacted by Sabatino Masala, Wang Wenlin, Thomas Dao, Vu Minh Tam, Roger Urscheler, jimmy schwarz, Joël Charles, Adi, Scen.K, Michael Michailidis and 6 more
Reacted by Lovell Fuller, shadowsong91, Basile Bruneau, Sabatino Masala, Andy Merskin, Thomas Dao, Vu Minh Tam, Christophe Marois, Adi, Michael Michailidis and 1 more
Reacted by Vu Minh Tam, Adi, Michael Michailidis and Daniel Röhrig
to my package.json seems to solve the problem, yarn dist works, the application starts, and sharp works. But since I don't understand fully the implications, I am a bit unsure of using it in production
Activity
lovell commentedon Jan 12, 2017
Hello, were you following the instructions at https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md ?
[-]libvips-cpp.42.dylib image not found mac osx build[/-][+]Electron: libvips-cpp.42.dylib image not found mac osx build[/+]nphias commentedon Jan 15, 2017
Hi Lovell,
yes I tried that page.
using electron 1.4.14
i tried rebuilding with the rebuild module: ./node_modules/.bin/electron-rebuild
same error..
I dont know if the issue is with the sharp module, node-gyp or electron-build/rebuild
but the problem only occurs on mac osx.. windows is fine (untested on linux)
lovell commentedon Jan 15, 2017
Thanks for the update.
binding.js#L32 places pre-compiled binaries in the
node_modules/sharp/vendordirectory atnpm installtime.binding.gyp#L141-L142 sets the runtime location for
rpathso the compiledsharp.nodeshared library can find the pre-compiled binaries.My best guess is that Electron on OS X is using non-standard locations.
/var/folders/rt/7f85090559l9jxmyt06cd_7w0000gn/T/.org.app.4Y18VMlooks very much non-standard :(brousalis commentedon Jan 16, 2017
I'm having the same issue. I'm on a Mac, Node 6.9.1, NPM 3.10.8, sharp 0.17.1
My app works locally with sharp. After using electron-builder to generate the Mac dist of my app, when I run it on a machine without libvips installed through brew, I get.
Which makes sense.. I think, since libvips can't be found. I'd hoped the pre-built versions inside node_modules/sharp would cover it.
Before creating the dist, I made sure to use
electron-rebuild, and it says Building module: sharp. I don't however see a/vendorfolder inside the node_modules/sharp, but the Build/ folder looks right.Compiling native modules is new to me, I know you don't explicitly support electron but would love any insight you have.
lovell commentedon Jan 16, 2017
The appearance of
/usr/local/optsuggests libvips might have previously been installed, or at least enough of it remains forpkg-config --modversion vips-cppto think it has found it.From v0.17.x onwards you'll see the
node_modules/sharp/vendordirectory created atnpm installtime, which hopefully is also the case for theelectron npm installcommand I think you'll need to use with Electron.nphias commentedon Jan 18, 2017
node: 7.4.0 npm: 4.0.5
I was able to package the app fine after building inside the module directory:
./node_modules/.bin/electron-rebuild
HOME=~/.electron-gyp node-gyp rebuild --target=1.4.14 --arch=x64 --dist-url=https://atom.io/download/electron;
.. problem occurs with asar file option (asar: true)
it seems there are limitations with native modules and using calls like dlopen
http://electron.atom.io/docs/tutorial/application-packaging/
we need to use the asar option .. electron-builder claims to automate native module building
but its the same error above at runtime
could it be that the sharp module is misconfigured somehow..? is there a problem will modules that use node-gyp?
nphias commentedon Jan 29, 2017
it the seems the workaround for mac is to use Electron-builder and the asarUnpack option:
"build": { "asar": true, "appId": "myappid", "asarUnpack": [ "**/node_modules/sharp/**/*" ], "extraResources": [ "bg_mask.png" ], "mac": { "category": "app.beta.com", "icon": "assets/ico/mac_icon.icns" }, "win": { "iconUrl": "https://aurl.win_icon.ico" } },this puts the sharp module outside asar... and it runs fine
BiancoA commentedon Mar 3, 2018
I ended up here because I have the same problem when running
yarn disti useelectron-builderin my workflow.adding
to my package.json seems to solve the problem, yarn dist works, the application starts, and sharp works. But since I don't understand fully the implications, I am a bit unsure of using it in production
@lovell or @nphias is there any update?
adhambadr commentedon Apr 17, 2019
Im still having this problem with Electron and unpacking the sharp module solution is not working any one has any other ideas ?
sharp": "^0.22.0",zzuzsj commentedon Jul 24, 2019
@adhambadr You can try build the app without asar.