unjs / ipx

🖼️ High performance, secure and easy-to-use image optimizer.
MIT License
1.2k stars 59 forks source link

sharp <0.33 installation issues #202

Closed Kemystra closed 5 months ago

Kemystra commented 6 months ago

Environment

Node: v21.5.0 npm: 10.2.5

Reproduction

This issue isn't related to ipx itself, but rather to its sharp dependency.

Describe the bug

ipx currently depends on ^sharp@0.32.0. This sharp version (and other 0.32.x versions) utilizes a problematic custom install script that may fail on some machines (see lovell/sharp#3833 and lovell/sharp#3750). Any sharp versions upwards of 0.33.0 would have fixed this problem.

For reference, this is one of the errors that may happen during installation:

npm ERR! code 1
npm ERR! path /home/user/.local/lib/node_modules/ipx/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-
gyp rebuild && node install/dll-copy)
npm ERR! sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.14.5/libvips-8.14.5-linux-x64.tar.br
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: Request timed out

Additional context

No response

Logs

No response

Kemystra commented 6 months ago

Right, I didn't notice that pull request (#190). Sorry for that.

Nevertheless, I think I will keep this issue open so that people that encounter this same problem will understand why.

For those who came here because of the above error: TL;DR, one of ipx dependencies is too old and uses a weird install script. There is a pull request addressing this problem, though. For now, you can use the npm:ipx-nightly@latest version to avoid this problem.

MickL commented 6 months ago

@Kemystra Has the PR been released to npm? I am on latest ipx 2.0.2 and the sharp dependency is ^0.32.6.

I come here because using Bun sharp is not getting installed. This has been fixed with 0.33.0 of sharp, latest version is 0.33.1: https://github.com/lovell/sharp/issues/3511

The problem is cascading a bit because @nuxt/image is using ipx ^2.0.2 which is using sharp ^0.32.6

Kemystra commented 6 months ago

@MickL as of just now, no the PR (#190) is still in draft state (and npm installation is still failing). Also seems like Bun installed ipx@latest and sharp@0.33.0 just fine, so that's nice. Bun really does handle the script properly.

And yeah, this problem is cascading. I came here in the first place from netlify/cli cuz I can't install that too.

MickL commented 6 months ago

Yes it works fine in Bun with latest sharp 0.33.1. When using @nuxt/image just run bun add sharp which will add 0.33.1 and everything works.

Problem is that sharp is still in 0.x which means ^0.x will not grab any minor update, I think even ^0.33.0 will not grab 0.33.1

Hope sharp version will be updated soon in unjs/ipx. Can we just set the version in package.json to ^0.33.1 @pi0 ?

pi0 commented 5 months ago

https://github.com/unjs/ipx/releases/tag/v3.0.0

(due to potential breaking changes, it is released as a major version in IPX same as sharp)