Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locally installed distro binaries ignored? #27

Open
polarathene opened this issue Jan 2, 2019 · 6 comments
Open

Locally installed distro binaries ignored? #27

polarathene opened this issue Jan 2, 2019 · 6 comments

Comments

@polarathene
Copy link

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 polarathene changed the title Local binaries ignored? Locally installed distro binaries ignored? Jan 2, 2019
@polarathene
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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 :)

@geonanorch
Copy link

@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.

@stck
Copy link

stck commented Mar 12, 2020

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)

@aaharu
Copy link

aaharu commented May 1, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants