cwebp-bin icon indicating copy to clipboard operation
cwebp-bin copied to clipboard

Locally installed distro binaries ignored?

Open polarathene opened this issue 6 years ago • 6 comments

I have a docker alpine image. I'm building it without wanting to compile binaries for packages. I have cwebp binary from an official Alpine package installed already. cwebp -version returns 1.0.0, this package only seems to source binaries via URLs to this repo and then call the binary version check?

Not sure why this is failing, is it downloading a binary for linux assuming compatibility with Alpine and preferring that invalid binary to the globally installed one?

node node_modules/cwebp-bin/lib/install.js
  ⚠ spawn /site/node_modules/cwebp-bin/vendor/cwebp ENOENT
  ⚠ cwebp pre-build test failed
  ℹ compiling from source

It's here:

ls node_modules/cwebp-bin/vendor
cwebp

fails to run:

./node_modules/cwebp-bin/vendor/cwebp -version
/bin/sh: ./node_modules/cwebp-bin/vendor/cwebp: not found

outside of that location, running installed alpine package version works fine:

cwebp -version
1.0.0

polarathene avatar Jan 02 '19 01:01 polarathene

I see that bin-wrapper .run() is meant to check for local binaries before downloading source to build. With pngquant-bin this works correctly.

which pngquant
/usr/bin/pngquant

which cwebp
/usr/bin/cwebp

I have tried to compare between the two projects but I'm not noticing any differences as to why pngquant is working as expected and cwebp is having trouble?

polarathene avatar Jan 02 '19 02:01 polarathene

pngquant-bin was doing the same thing, just it's binary was smaller/faster to add I guess and compatible.

The .run() method appears to only work on the binary if it's in the .dest() path. I changed the path to /usr/bin in my case and it was able to find cwebp successfully.. though that's not really a solution for fixing this package.. :(

polarathene avatar Jan 02 '19 03:01 polarathene

Tracking PR. If this gets merged, all the imagemin binary packages relying on bin-wrapper can benefit. Just needs to use an env var to allow using system binaries instead :)

polarathene avatar Jan 02 '19 03:01 polarathene

@polarathene from what I can see in the Google documentation (and from trying to add pngquant in the path before invoking cwebp) the cwebp binary does not care about external executables: the development version of the relevant libraries (e.g. libpng-dev) must be available at compile time, AND in some cases (dynamic linking) must be available (on the path) at runtime as well. See issue #39 , similar story.

geonanorch avatar Feb 18 '20 09:02 geonanorch

Actually I've solved this for myself by archiving necessary modules like cwebp,mozjpeg,pngquant into some tar archive. Now, my images do not require any c compilers and dynamic libs but libjpeg-turbo and libpng. Negative side-effects - i'm not able to use npm ci (node_modules are cleared before npm ci)

stck avatar Mar 12 '20 15:03 stck

I've solved this by forking. https://www.npmjs.com/package/@mole-inc/cwebp-bin

I've changed the postinstall script to use system binaries by creating symlink. https://github.com/mole-inc/cwebp-bin/blob/4096d2e/lib/install.js#L36-L63

aaharu avatar May 01 '20 12:05 aaharu