Skip to content

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

Closed

Description

@nphias

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

Activity

  1. 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
  2. nphias commented on Jan 15, 2017

    @nphias
    Author

    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)

  3. lovell commented on Jan 15, 2017

    @lovell
    Owner

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

  4. brousalis commented on Jan 16, 2017

    @brousalis

    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.

  5. lovell commented on Jan 16, 2017

    @lovell
    Owner

    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.

  6. nphias commented on Jan 18, 2017

    @nphias
    Author

    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?

  7. nphias commented on Jan 29, 2017

    @nphias
    Author

    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

  8. BiancoA commented on Mar 3, 2018

    @BiancoA
    Contributor

    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?

  9. adhambadr commented on Apr 17, 2019

    @adhambadr

    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",

  10. zzuzsj commented on Jul 24, 2019

    @zzuzsj

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions