Sharp: Error: libvips-cpp.so.42: File not found with electron-builder under Linux

Created on 10 Mar 2017  路  4Comments  路  Source: lovell/sharp

Hello,

I have a problem with Sharp and Electron under Ubuntu 16.10.

I just added sharp to my project, and in developement it works great, I can launch the app with electron . without any problem.

Then, I tried to package it for Linux, using https://github.com/electron-userland/electron-builder. The build process works, but when I try to execute the application with ./dist/linux-unpacked/test-sharp I have the following error:

A JavaScript error occurred in the main process
Uncaught Exception:
Error: libvips-cpp.so.42: Ne peut ouvrir le fichier d'objet partag茅: Aucun fichier ou dossier de ce type
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:187:18)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ntag/test-sharp-electron/dist/linux-unpacked/resources/app.asar/node_modules/sharp/lib/constructor.js:8:15)
    at Object.<anonymous> (/home/ntag/test-sharp-electron/dist/linux-unpacked/resources/app.asar/node_modules/sharp/lib/constructor.js:211:3)

I tried to put sharp inside or outside the asar archive (like suggested in this issue), but the result is the same.
Especially, when I do: ldd dist/linux-unpacked/resources/app.asar.unpacked/node_modules/sharp/bin/linux-x64-53/sharp.node I get:

linux-vdso.so.1 =>  (0x00007ffd461fc000)
libvips-cpp.so.42 => not found
libvips.so.42 => not found
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f66903eb000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f6690198000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f668fe10000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f668fb05000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f668f8ee000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f668f527000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f668f2b4000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f668f096000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f668ee8e000)
/lib64/ld-linux-x86-64.so.2 (0x000055cadfeed000)

And under Mac and Windows I didn't have any problem...

I created a repository just to reproduce the error: https://github.com/NTag/test-sharp-electron

Thank you very much!

question

Most helpful comment

Ok, I think I found the problem, which comes from electron-builder.

When it copies the files (which will go outside the asar archive), it doesn't consider symbolic links.

I created an issue here.

All 4 comments

Hello, the appearance of /lib/x86_64-linux-gnu/libglib-2.0.so.0 suggests libvips might have been globally installed on the Linux box at build/install time. If so, please try removing it first.

Watch out for a node_modules/sharp/vendor directory created at install-time and make sure that ends up in the correct location relative to sharp.node (see @loader_path in binding.gyp#L142).

I have tried locate libvips I don't find anything global, so I guess libvips has not been installed globally?

I indeed have a node_modules/sharp/vendor folder in dev, and a dist/linux-unpacked/resources/app.asar.unpacked/node_modules/sharp/vendor/ after the build.

In dev, ldd node_modules/sharp/bin/linux-x64-53/sharp.node gives:

linux-vdso.so.1 =>  (0x00007ffd44d4b000)
libvips-cpp.so.42 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libvips-cpp.so.42 (0x00007f8e4c504000)
libvips.so.42 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libvips.so.42 (0x00007f8e4bef8000)
libglib-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libglib-2.0.so.0 (0x00007f8e4bb87000)
libgobject-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgobject-2.0.so.0 (0x00007f8e4b934000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f8e4b58f000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8e4b286000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f8e4b06f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8e4aca8000)
libz.so.1 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libz.so.1 (0x00007f8e4aa91000)
libpng16.so.16 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libpng16.so.16 (0x00007f8e4a858000)
libtiff.so.5 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libtiff.so.5 (0x00007f8e4a5ee000)
libjpeg.so.8 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libjpeg.so.8 (0x00007f8e4a373000)
libgmodule-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgmodule-2.0.so.0 (0x00007f8e4a170000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f8e49f68000)
libgsf-1.so.114 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgsf-1.so.114 (0x00007f8e49d1f000)
libxml2.so.2 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libxml2.so.2 (0x00007f8e49a34000)
liborc-0.4.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/liborc-0.4.so.0 (0x00007f8e4979b000)
liblcms2.so.2 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/liblcms2.so.2 (0x00007f8e49532000)
libgif.so.7 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgif.so.7 (0x00007f8e49329000)
librsvg-2.so.2 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/librsvg-2.so.2 (0x00007f8e490eb000)
libgio-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgio-2.0.so.0 (0x00007f8e48d3d000)
libgdk_pixbuf-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgdk_pixbuf-2.0.so.0 (0x00007f8e48b11000)
libcairo.so.2 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libcairo.so.2 (0x00007f8e4881a000)
libwebp.so.6 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libwebp.so.6 (0x00007f8e48594000)
libexif.so.12 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libexif.so.12 (0x00007f8e4834e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f8e48130000)
libffi.so.6 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libffi.so.6 (0x00007f8e47f26000)
/lib64/ld-linux-x86-64.so.2 (0x0000557949c41000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8e47d22000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f8e47b07000)
libpangocairo-1.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libpangocairo-1.0.so.0 (0x00007f8e478fa000)
libpangoft2-1.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libpangoft2-1.0.so.0 (0x00007f8e476e3000)
libharfbuzz.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libharfbuzz.so.0 (0x00007f8e47473000)
libpango-1.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libpango-1.0.so.0 (0x00007f8e47224000)
libgthread-2.0.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libgthread-2.0.so.0 (0x00007f8e47023000)
libpixman-1.so.0 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libpixman-1.so.0 (0x00007f8e46d65000)
libfontconfig.so.1 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libfontconfig.so.1 (0x00007f8e46b19000)
libfreetype.so.6 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libfreetype.so.6 (0x00007f8e4686e000)
libcroco-0.6.so.3 => /home/ntag/test-sharp-electron/node_modules/sharp/bin/linux-x64-53/../../vendor/lib/libcroco-0.6.so.3 (0x00007f8e46632

But in the electron-builder build, the sharp module is quiet different, that's strange...

Ok, I think I found the problem, which comes from electron-builder.

When it copies the files (which will go outside the asar archive), it doesn't consider symbolic links.

I created an issue here.

This looks like a feature of electron-builder so closing here as there's not a lot we can do, plus there seems to be a workaround.

Was this page helpful?
0 / 5 - 0 ratings