Sorry to create a new issue for this, but all previous threads are locked and the preferred method to attempt to solve this is still unclear. Could you please point me in the right direction on this?
I'm using Electron 1.8.4, but have also tried Electron 2.0.0. Is it possible with either of the two methods to package a working application including Sharp? I'm running Linux Mint 18.3 x64. I've also tried Linux Mint 17.3 x64
Using: LD_PRELOAD=./node_modules/sharp/vendor/lib/libz.so
Results in: ERROR: ld.so: object './node_modules/sharp/vendor/lib/libz.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Thanks very much for any advice you can offer.
From #892
so there's nothing sharp can do here. Two possible options are:
- Upgrade the system libz from the vulnerable v1.2.8 to the latest v1.2.11
- Use LD_PRELOAD=/path/to/node_modules/sharp/vendor/lib/libz.so electron ... so the system will use the sharp-provided v1.2.11 instead of its own v1.2.8.
LD_PRELOAD is relative to (I think) LD_LIBRARY_PATH rather than the current working directory, so you'll need to use absolute paths.
See also my comment about requesting that Electron ship with its own libz, plus my final comment about rolling your own bundle. https://github.com/lovell/sharp/issues/892#issuecomment-360901007
Actually as soon as I stepped away from the computer I realized I had the wrong path... Silly mistake... I am going to see how far I can get with this solution. Thanks very much for your (insanely fast) reply!
@lovell Electron 2 & Electron 3 are using [email protected], am I mistaken to believe I should not be getting this message anymore, about not being able to find 1.2.9?
Uncaught Error: /lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/user/projects/myApp/app/node_modules/sharp/build/Release/../../vendor/lib/libpng16.so.16)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
Electron relies on the system zlib shared library even though Node provides a static zlib.
Please see my comment https://github.com/lovell/sharp/issues/892#issuecomment-357422744 in "Electron beta appears to use system zlib".
"You might want to make an upstream request that the electron binaries link and ship with the latest libz, which will involve a change somewhere around here https://github.com/electron/electron/blob/fce84fbe99b3ea726297bb6de0d811173ffb6dea/electron.gyp#L211"
So even in if, from Electron, process.versions.libz returns 1.2.11, this version will not available to Sharp?
Correct, process.versions.libz is the version of libz statically linked to at Node build time. Electron treats Node as a shared library, so can't use Node's libz, hence my suggestion that Electron could be modified to ship with its own libz as a shared library (as it already ships with its own libffmpeg as a shared library).
Thanks for the clarification @lovell. Always appreciate your help. I'd love if they'd do this. I guess it's back to the custom libvips route.