Repository navigation
Description
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- Running
npm install sharpcompletes without error. - Running
node -e "require('sharp')"completes without error.
If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
- I am using the latest version of
sharpas reported bynpm view sharp dist-tags.latest.
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?
System:
OS: Linux 6.13 Arch Linux
CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
Memory: 26.15 GB / 31.25 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.9.0 - /usr/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 11.2.0 - /usr/bin/npm
npmPackages:
sharp: ^0.33.5 => 0.33.5
Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.
- Adding
sharp.cache(false)does not fix this problem.
Does this problem relate to images appearing to have been rotated by 90 degrees?
Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.
-
To auto-orient pixel values use the parameter-less
rotate()operation. -
To retain EXIF Orientation use
keepExif(). -
Using
rotate()orkeepExif()does not fix this problem.
What are the steps to reproduce?
Use Sharp to resize an image and write output to buffer from an Electron app started with Electron Forge.
What is the expected behaviour?
The code runs fine on Debian but throws this error on Arch. It also works as expected when I run the same code outside of the Electron app on Arch.
ERROR:/__w/sharp/sharp/node_modules/@img/sharp-libvips-dev/include/vips/VImage8.h:134
:vips::VObject& vips::VObject::operator=(const vips::VObject&): assertion failed: (!a
.vobject || VIPS_IS_OBJECT(a.vobject))
Bail out! ERROR:/__w/sharp/sharp/node_modules/@img/sharp-libvips-dev/include/vips/VIm
age8.h:134:vips::VObject& vips::VObject::operator=(const vips::VObject&): assertion f
ailed: (!a.vobject || VIPS_IS_OBJECT(a.vobject))
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
I'm unable to provide that at the moment as it is hard to judge which part of the code is causing the issue, especially since the same code works fine on Debian. One thing I know for sure after debugging is that it crashes on toBuffer. Hoping to get some insight into what may be causing it on one distro but not another.
Activity
xsmh commentedon Mar 18, 2025
A few others seemed to have had the same issue here #4129
lovell commentedon Mar 18, 2025
My best guess would be that this relates to a glib version mismatch.
Electron dynamically links against the system glib whereas the prebuilt libvips binaries provided by sharp statically link against their own glib and attempt to force its use internally via
-Bsymbolic-functions.https://github.com/lovell/sharp-libvips/blob/4e1ebe2c69982382d398a3cf7f1d5e536a114542/build/lin.sh#L465
There has been at least one previous Electron issue relating to the provision of statically-linked binaries - see electron/electron#25495
Perhaps try the pre-release version of sharp
0.34.0-rc.0, which provides the latest glib 2.84.0 - see #4248 (comment)xsmh commentedon Mar 18, 2025
Hey @lovell, the pre-release version works perfectly, thank you!
lovell commentedon Mar 18, 2025
Thanks for confirming - please subscribe to #4248 for updates.
Bilb commentedon Oct 13, 2025
Hey @lovell
Is it possible that this issue is back?
I have a bunch of users on archlinux reporting that anything image-*related is making the app crash, like those:
session-foundation/session-desktop#1626
session-foundation/session-desktop#1602
session-foundation/session-desktop#1618
The packaged sharp version is
0.34.4.I do reproduce this issue myself in an archlinux virtual machine (cachyOS).
Any help to debug this issue would be greatly appreciated.
Bilb commentedon Oct 13, 2025
Let me know if you'd prefer have another issue open for this.
Here is what I could get from the electron dump
lovell commentedon Oct 13, 2025
@Bilb This comment session-foundation/session-desktop#1602 (comment) nails the underlying problem, there's really not a lot we can do. You'll need to either switch electron to statically-link against all of its dependencies or switch sharp to use an OS-managed libvips shared library (to match electron's use of OS-managed shared libaries).
Bilb commentedon Oct 14, 2025
@lovell thanks for you reply. I guess using the OS managed libvips is going to be easier for my usecase.
Does it mean I'll loose some important options/performance tweaks of the sharp-built one?
Bilb commentedon Oct 26, 2025
Ok, thanks a lot about that info. I'll see what I can do when I got some time to deal with this.