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

mozjpeg@5.0.0 fails to build binary at postinstall #35

Open
doochik opened this issue Jan 24, 2018 · 17 comments
Open

mozjpeg@5.0.0 fails to build binary at postinstall #35

doochik opened this issue Jan 24, 2018 · 17 comments

Comments

@doochik
Copy link

doochik commented Jan 24, 2018

npm@5.5.1
node@8.9.0
Ubuntu 14.04.5 LTS

$ npm i mozjpeg

> mozjpeg@5.0.0 postinstall /home/aandrosov/node_modules/mozjpeg
> node lib/install.js

  ⚠ The `/home/aandrosov/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: autoreconf -fiv && ./configure --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/home/aandrosov/node_modules/mozjpeg/vendor" --bindir="/home/aandrosov/node_modules/mozjpeg/vendor" --libdir="/home/aandrosov/node_modules/mozjpeg/vendor" && make -j4 && make install -j4
Command failed: autoreconf -fiv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force 
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:23: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
@hsz
Copy link

hsz commented Jan 29, 2018

> mozjpeg@5.0.0 postinstall /opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg
> node lib/install.js

  ⚠ The `/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: autoreconf -fiv && ./configure --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor" --bindir="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor" --libdir="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor" && make -j2 && make install -j2
Command failed: ./configure --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor" --bindir="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor" --libdir="/opt/bitnami/apps/jenkins/jenkins_home/jobs/Project/workspace/node_modules/mozjpeg/vendor"
./configure: line 13124: PKG_PROG_PKG_CONFIG: command not found
./configure: line 13303: syntax error near unexpected token `libpng,'
./configure: line 13303: `PKG_CHECK_MODULES(libpng, libpng, HAVE_LIBPNG=1,'

    at ChildProcess.exithandler (child_process.js:270:12)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:927:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

@jjwilliams42
Copy link

> mozjpeg@4.1.1 postinstall /app/MYAPP/node_modules/mozjpeg
  > node lib/install.js
  
    ΓÜá The `/app/MYAPP/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly
    ΓÜá mozjpeg pre-build test failed
    ℹ compiling from source
EXEC : Γ£û error : autoreconf -fiv && ./configure --disable-shared --prefix="/app/MYAPP/node_modules/mozjpeg/vendor" --bindir="/app/MYAPP/node_modules/mozjpeg/vendor" --libdir="/app/MYAPP/node_modules/mozjpeg/vendor" && make --jobs=2 && make install --jobs=2 [/app/MYAPP/MYAPP.csproj]
  Command failed: autoreconf -fiv
  /bin/sh: 1: autoreconf: not found
  
      at ChildProcess.exithandler (child_process.js:199:12)
      at emitTwo (events.js:106:13)
      at ChildProcess.emit (events.js:191:7)
      at maybeClose (internal/child_process.js:920:16)
      at Socket.<anonymous> (internal/child_process.js:351:11)
      at emitOne (events.js:96:13)
      at Socket.emit (events.js:188:7)
      at Pipe._handle.close [as _onclose] (net.js:497:12)

@lewebsimple
Copy link

Installing the following under Ubuntu 16.04 works for me:

sudo apt-get install autoconf libtool nasm

@fiws
Copy link

fiws commented Feb 21, 2018

hm... CI does not like this :\

why does the pre build binary does not work in the first place?

@jjwilliams42
Copy link

I have no idea. I've never had an npm dependency that had an npm dependency that had an npm dependency that required an entire build chain of requirements. I spent about a day trying to get it working then gave up.

@heisian
Copy link

heisian commented May 5, 2018

On Amazon EC2:

# Amazon AMI Linux
yum install autoconf automake libtool nasm

VERY not happy I have to install all this crap on my build server to get it working.

@thom4parisot
Copy link

thom4parisot commented May 5, 2018

VERY not happy I have to install all this crap on my build server to get it working.

I don't feel very comfortable to read such a rude message. And I don't even develop the tool.

Some people are thinking about it and it does not seem trivial.
Maybe you can share your knowledge in #33

@heisian
Copy link

heisian commented May 7, 2018

Well let's see what happens here...

yum install autoconf automake libtool nasm

This is all done so that cjpeg can be built, which seems to be a part of the standard libraries for many common flavors of linux:

https://www.unix.com/man-page/redhat/1/cjpeg/
http://manpages.ubuntu.com/manpages/xenial/man1/cjpeg.1.html
https://linux.die.net/man/1/cjpeg

That being said, one still seems to need to run the following to get cjpeg to make && make install in CentOS & Fedora: mozilla/mozjpeg#218

So how to make this happen without having sudo permissions?

Have the script download tarballs from verified sources on fixed versions and install to ~/bin or something standard for local libraries, and then compile the cjpeg binary and install into the local module folder [1].

All of these dependencies are standard and the installations and dependencies themselves can be locally cleaned up after cjpeg is compiled.

Of course it would be nice if I put this into practice and made a pull request rather than just shit-talk on a thread, wouldn't it?

So, what are your thoughts?

@heisian
Copy link

heisian commented May 7, 2018

The point is, rather than having to pick and pull from different statically-linked libraries that may or may not exist in varying distros of linux,

it's better to pull all the dependencies and compile them from source locally without sudo such that the target binary, cjpeg, can be compiled locally and specific to the flavor of linux being run,

and then all the dependencies used to compile it can be cleaned up such that in the end, the only dependency needed in the first place, cjpeg, remains.

Such a strategy would give the widest success across the various flavors of linux, and probably BSD, but I haven't spent enough time in BSD-land.

@lastboy1228
Copy link

Every time I install mozjpeg in the same project folder, it always says the cjpeg binary doesn't seem to work correctly, and rebuild it again. I don't know why.

@debasishshanti
Copy link

@doochik @fiws Do you have a Package lock file that was generated from another OS? I faced this issue when a package-lock.json file was created in Windows system and then we tried to deploy the code in Jenkins(Linux) environment. Deleting the package-lock.json file solved the issue for me.
Hope this helps

@ChinmoyDn
Copy link

Getting the same error. Removing the yarn.lock file and the node_modules, then reinstalling all the node modules solves it.
How to get over this issue?

@dmitryuk
Copy link

dmitryuk commented Sep 19, 2018

same error on Centos.
After installed libpng16-dev problem was solved
https://stackoverflow.com/questions/25549536/error-while-loading-shared-libraries-libpng16

@fiws
Copy link

fiws commented Sep 20, 2018

@debasishshanti you guessed right, it was generated on another os. But I recreated the package-lock on my (Linux) machine and it sadly did not fix the issue :(

@debasishshanti
Copy link

@fiws Try not to have that Package lock file in repository and check

@ChangeZhang
Copy link

mozjpeg@4.1.1 postinstall /Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/mozjpeg
node lib/install.js

⚠ EACCES: permission denied, mkdir '/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/mozjpeg/vendor'
⚠ mozjpeg pre-build test failed
ℹ compiling from source
/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/onetime/index.js:15
throw new Error(fnName + ' can only be called once.');
^

Error: callback() can only be called once.
at onetime (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/onetime/index.js:15:11)
at /Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/download/index.js:156:5
at ConcatStream. (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/concat-stream/index.js:37:43)
at emitNone (events.js:111:20)
at ConcatStream.emit (events.js:208:7)
at finishMaybe (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/readable-stream/lib/_stream_writable.js:630:14)
at endWritable (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/readable-stream/lib/_stream_writable.js:638:3)
at ConcatStream.Writable.end (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/readable-stream/lib/_stream_writable.js:594:41)
at DuplexWrapper.onend (/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/readable-stream/lib/_stream_readable.js:577:10)
at Object.onceWrapper (events.js:313:30)
npm info lifecycle mozjpeg@4.1.1~postinstall: Failed to exec postinstall script
npm WARN tire@0.0.2 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mozjpeg@4.1.1 postinstall: node lib/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mozjpeg@4.1.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/zhangwen/.npm/_logs/2019-05-20T11_41_36_101Z-debug.log

@quarryman
Copy link

EACCES: permission denied, mkdir '/Users/zhangwen/Desktop/linkingfresh-project/tire/node_modules/mozjpeg/vendor'

This is most likely because you have node_modules created by root user.
Even if you are running npm i mozjpeg under root too, postinstall compiler will operate as system user (ec2-user in case of Amazon Linux for instance), so it has no rights to write to node_modules/mozjpeg to create binaries.

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