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

Electron: libvips-cpp.42.dylib image not found mac osx build #678

Closed
nphias opened this issue Jan 11, 2017 · 10 comments
Closed

Electron: libvips-cpp.42.dylib image not found mac osx build #678

nphias opened this issue Jan 11, 2017 · 10 comments
Labels

Comments

@nphias
Copy link

nphias commented Jan 11, 2017

ELECTRON_ASAR.js:173 Uncaught Error:
dlopen(/var/folders/rt/7f85090559l9jxmyt06cd_7w0000gn/T/.org.app.4Y18VM, 1): Library not loaded: @rpath/libvips-cpp.42.dylib
Referenced from: /var/folders/rt/7f85090559l9jxmyt06cd_7w0000gn/T/.org.app.4Y18VM
Reason: image not found

i get this when trying to build on electron (electron-builder).... not sure what image its looking for

@lovell
Copy link
Owner

lovell commented Jan 12, 2017

@lovell lovell changed the title libvips-cpp.42.dylib image not found mac osx build Electron: libvips-cpp.42.dylib image not found mac osx build Jan 12, 2017
@nphias
Copy link
Author

nphias commented 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
Copy link
Owner

lovell commented Jan 15, 2017

Thanks for the update.

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 :(

@brousalis
Copy link

brousalis commented 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.

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.

@lovell
Copy link
Owner

lovell commented Jan 16, 2017

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.

@nphias
Copy link
Author

nphias commented 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
Copy link
Author

nphias commented 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
Copy link
Contributor

BiancoA commented Mar 3, 2018

I ended up here because I have the same problem when running yarn dist i use electron-builder in my workflow.
adding

  "build": {
    "asar": true,
    "asarUnpack": ["**/node_modules/sharp/**/*"]
  }

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
Copy link

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
Copy link

zzuzsj commented Jul 24, 2019

@adhambadr You can try build the app without asar.

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

No branches or pull requests

6 participants