Did you see the documentation relating to installation?
yes
Have you ensured the platform and version of Node.js used for npm install is the same as the platform and version of Node.js used at runtime?
The build script uses 'electron-builder install-app-deps' to ensure the correct version.
If you are installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?
not installing as root
If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?
not using this
What is the complete output of running npm install --verbose sharp? Have you checked this output for useful error messages?
It builds fine, but a user running the electron app gets the error in the title
What is the output of running npx envinfo --binaries --languages --system --utilities?
This is the information from the original bug report:
Operating System: Feren OS 2020.01
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.65.0
Qt Version: 5.13.2
Kernel Version: 5.3.0-26-generic
OS Type: 64-bit
Processors: 2 × Intel® Core™2 CPU 6600 @ 2.40GHz
Memory: 7,8 GiB of RAM
This is the error the reporter gets:
/tmp/.mount_MIX-Acx3Utya/resources/app.asar.unpacked/node_modules/sharp/build/Release/../../vendor/lib/librsvg-2.so.2: undefined symbol: cairo_font_options_get_variations
The app is built on travis on ubuntu xenial:
https://travis-ci.com/mix-blockchain/mix-acuity/jobs/277504135#L2310
What is the best way to proceed to resolve this for them?
Original bug report:
https://github.com/mix-blockchain/mix-acuity/issues/43
I'm attempting to build on bionic to see if it makes a difference.
Yes, We are getting the same error. Version 0.23.4 works perfectly. These new symbols are added in the latest Cairo but on 0.24 the libcairo seems to be older.
The prebuilt binaries for sharp v0.23.x provided cairo v1.17.2 but this caused #1895 so sharp v0.24.x reverted to cairo v0.16.0.
The cairo_font_options_get_variations symbol was added in cairo v0.16.0 so this may be a red herring.
My best guess would be that there is another native dependency that also depends upon cairo.
I've built an Electron app:
https://github.com/ExamProCo/fast-author
npm i
./node_modules/.bin/electron-rebuild -p -t "dev,prod,optional"
npm start
It throws this error as well:
Uncaught Exception:
Error:
Something went wrong installing the "sharp" module
/home/ab/sites/fast-author/node_modules/sharp/build/Release/../../vendor/lib/librsvg-2.so.2: undefined symbol: cairo_font_options_get_variations
What is confusing is that if I test Sharp in a sample app it works with no issue on Ubuntu
Running Node12 for both.
It looks like the prebuilt electron binary for Linux depends on the system libcairo and therefore conflicts.
$ ./node_modules/electron/dist/electron -v
v7.1.12
$ ldd node_modules/electron/dist/electron | grep cairo
libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f4e09c2f000)
libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f4e09a9b000)
libcairo-gobject.so.2 => /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f4e08d49000)
If you depend on a globally-installed libcairo for electron then you'll also have to depend on a globally-installed libvips that uses the same libcairo.
@lovell I am confused... this might be just my lack of understanding the issue. Are you suggesting that this is actually an Electron bug? Does this mean that there isn't a fix that would restore the working functionality of v0.23?
Some prebuilt electron binaries on Linux depend on the system cairo. If you are using this with the prebuilt binaries provided by sharp and the versions of cairo happen to match, then it will appear to work. If they do not match then it might work or it might not.
It's about versions of cairo rather than versions of sharp or electron.
The best advice I can offer right now is as before:
If you depend on a globally-installed libcairo for electron then you'll also have to depend on a globally-installed libvips that uses the same libcairo.
The use of static linking for the prebuilt binaries provided by sharp is being considered to prevent this kind of problem - see https://github.com/lovell/sharp-libvips/issues/39
You might also consider compiling your own Electron with its dependencies statically-linked.
Thank you for clarifying, that helps!
I hope this information helped. Please feel free to re-open with more details if further assistance is required.
@lovell
We are stuck at 0.23.4 and here's the reason.
Ubuntu: 18.04 depends on Cairo lib v1.15
Environment:: Electron
Both options are failing::
a) If we use the globally installed libvips: We get Error: Input file contains unsupported image format
b) If we use the local libvips built by Sharp then we get the above error: undefined symbol: cairo_font_options_get_variations
I believe the reason being even though we built the latest libvips, it depends on the old version of system Cairo with limited features.
To make sharp easy for all node environments including electron, it might be important to build a static version of Libvips (Long term)
Do you have any short term solution for our case? also, I believe you would have evaluated the trade-off for downgrading the Cairo version.
Thanks and let me know if I am missing something.
@lovell any suggestions would greatly help.
@janakg Please see my comment above at https://github.com/lovell/sharp/issues/2058#issuecomment-605685059