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 pre-build test failed #168

Open
bshack opened this Issue May 7, 2016 · 40 comments

Comments

Projects
None yet
@bshack

bshack commented May 7, 2016

not sure if I should be posting this here or in mozjpeg but mozjpeg is failing for me on OS X 10.11:

optipng-bin@3.1.1 postinstall /Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
> node lib/install.js

  ✔ optipng pre-build test passed successfully

> mozjpeg@4.1.1 postinstall /Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg
> node lib/install.js

  ⚠ The `/Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/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 --prefix="/Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --bindir="/Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --libdir="/Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" && make --jobs=8 && make install --jobs=8
Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: command not found

    at ChildProcess.exithandler (child_process.js:213:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:477:12)

> gifsicle@3.0.3 postinstall /Users/xxx/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js

  ✔ gifsicle pre-build test passed successfully
@shinnn

This comment has been minimized.

Member

shinnn commented May 7, 2016

$ nasm -v
@bshack

This comment has been minimized.

bshack commented May 7, 2016

NASM version 0.98.40 (Apple Computer, Inc. build 11) compiled on Feb 10 2016

@shinnn

This comment has been minimized.

Member

shinnn commented May 7, 2016

@bshack

This comment has been minimized.

bshack commented May 7, 2016

NASM version 2.12.01 compiled on Mar 23 2016

 ✔ optipng pre-build test passed successfully

> mozjpeg@4.1.1 postinstall /Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg
> node lib/install.js

  ⚠ The `/Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/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 --prefix="/Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --bindir="/Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --libdir="/Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" && make --jobs=8 && make install --jobs=8
Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: command not found

    at ChildProcess.exithandler (child_process.js:213:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:827:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:477:12)

> gifsicle@3.0.3 postinstall /Users/billshackelford/Sites/white-label/node_modules/gulp-imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js

  ✔ gifsicle pre-build test passed successfully
@shinnn

This comment has been minimized.

Member

shinnn commented May 7, 2016

/bin/sh: autoreconf: command not found

http://stackoverflow.com/questions/9575989/install-autoreconf-on-osx-lion

Anyway, the prebuilt binary should work. In my OS X 10.11.4 (15E65) npm install mozjpeg shows the message "optipng pre-build test passed successfully" as I expected. I don't know the root cause of the installation failure in your OS.

@bshack

This comment has been minimized.

bshack commented May 7, 2016

Mine is a fresh install of os x 10.11.4

@bshack

This comment has been minimized.

bshack commented May 7, 2016

I also have the latest Xcode updates

@nathangaw

This comment has been minimized.

nathangaw commented May 7, 2016

Hi - I'm getting exactly the same error on OS X 10.11.4, with NASM version 2.12.01.

@shinnn

This comment has been minimized.

Member

shinnn commented May 8, 2016

@bshack @nathangaw Could you try to build mozjpeg from the v3.1 source in your OS https://github.com/mozilla/mozjpeg/releases/tag/v3.1, then provide me the built binary?

@shinnn

This comment has been minimized.

Member

shinnn commented May 8, 2016

If you successfully build the mozjpeg binary and it works on both my Mac and yours, I'll replace the current binary with the newly built one.

@shelldandy

This comment has been minimized.

shelldandy commented May 8, 2016

I'm having the same error, it used to work fine, but after the Xcode Update this got broken 😢

@bshack

This comment has been minimized.

bshack commented May 8, 2016

@shinnn are you able to reproduce this issue after installing all the latest xcode updates?

@shinnn

This comment has been minimized.

Member

shinnn commented May 9, 2016

@bshack No.

Also I added OSX test to the mozjpeg npm package in imagemin/mozjpeg-bin@b0bd5cd. It runs with OSX v10.11 and Xcode v7.3 and, in contrast to @mike3run's comment #168 (comment), it passes the build test.

@bshack

This comment has been minimized.

bshack commented May 9, 2016

hmm.. not sure what is up. I am rolling back to 2.x.x for my stuff.

@shelldandy

This comment has been minimized.

shelldandy commented May 9, 2016

I can tell you what was the difference with mine a probably the OP.

I always npm-cache install to help with load times, but this time besides the xcode update i had deleted all of my node projects so the install was made from scratch and no catching was done.

Then I think that's where the problem is, try running that without having any other functional imagemin on your computer :)

@shelldandy

This comment has been minimized.

shelldandy commented May 9, 2016

Try running also node node_modules/mozjpeg/lib/install.js to try the build manually

@chrisvanpatten

This comment has been minimized.

chrisvanpatten commented May 9, 2016

I got a similar error. Here's what I did to fix it; hopefully this helps someone else!

  1. Update Xcode command line tools to latest release
  2. brew install nasm (I was using the bundled OS X version 0.98.40, now using 2.11.08)
  3. npm cache clean
  4. npm install

Still getting an error with the cjpeg binary, but the build from source works now.

@shelldandy

This comment has been minimized.

shelldandy commented May 9, 2016

What @chrisvanpatten did worked for me as well.

The binary fails but then the build from source works. :)

@afzal273

This comment has been minimized.

afzal273 commented Jun 18, 2016

How do you build from source on OS X?

I'm still getting - /node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg` binary doesn't seem to work correctly

node node_modules/imagemin-mozjpeg/node_modules/mozjpeg/lib/install.js

⚠ mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: autoreconf -fiv && ./configure --disable-shared --prefix=/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --bindir="/node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" --libdir="./node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor" && make --jobs=8 && make install --jobs=8
Command failed: /bin/sh -c autoreconf -fiv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --output=aclocal.m4t
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory

at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
@shelldandy

This comment has been minimized.

shelldandy commented Jun 18, 2016

You can try what @chrisvanpatten said 2 comments above yours or you could also use node LTS version which is 4.4.5

Apparently there are tons of bugs running Node 6.0 +

So unless you're an active node dev you should stay on 4.4.5 :)

@afzal273

This comment has been minimized.

afzal273 commented Jun 18, 2016

Already did what @chrisvanpatten said and my node version is 4.4.4.

Chris also says to do build from source. How do you do that?

@shelldandy

This comment has been minimized.

shelldandy commented Jun 18, 2016

Okay so just try to npm install imagemin again :)

That worked for me but you could also cd into node_modules > mozjpeg > test and run node test

That should try to build it but you need to have done what @chrisvanpatten said

@artmatsak

This comment has been minimized.

artmatsak commented Oct 17, 2016

cjpeg managed to build from source after I installed a newer version of nasm via MacPorts. However, cjpeg now exits with a segmentation fault when invoked from a parent dir, or is unable to process a JPEG file when invoked from its dir:

$ ./node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor/cjpeg ~/Downloads/test.jpg
Segmentation fault: 11
$ cd node_modules/imagemin-mozjpeg/node_modules/mozjpeg/vendor
$ ./cjpeg ~/Downloads/test.jpg
Unrecognized input file format --- perhaps you need -targa

Any suggestions please? OS X 10.12 here.

@artmatsak

This comment has been minimized.

artmatsak commented Oct 17, 2016

Update: Installing mozjpeg first via npm install mozjpeg also leads to building from source but seems to produce a non-faulty cjpeg.

@wmartins

This comment has been minimized.

wmartins commented Dec 7, 2016

I don't know if @bshack is still having problems with that, but I was struggling with the same problem yesterday and I think that I've found a solution.

My Scenario: building a project that uses imagemin inside a docker container using alpine linux.

Solution: install the following alpine packages:

  • libpng-dev
  • autoconf
  • automake
  • make
  • g++
  • libtool
  • nasm

After installing that, I was able to compile the binaries.

I don't know if it helps, but I'm adding it here, so anyone can try this when having same problems.

@westyby

This comment has been minimized.

westyby commented Jan 27, 2017

This bug reproduced on CentOS 6.8 witn node.js v6.9.4.
But when I install yum install wget autoconf automake gcc nasm libtool, I successfully compiled mozjpeg

mozjpeg@4.1.1 postinstall /home/bitrix/serv_opti/node_modules/mozjpeg
node lib/install.js

⚠ The /home/bitrix/serv_opti/node_modules/mozjpeg/vendor/cjpeg binary doesn't seem to work correctly
⚠ mozjpeg pre-build test failed
ℹ compiling from source
✔ mozjpeg built successfully

@ahgittin

This comment has been minimized.

ahgittin commented Feb 7, 2017

This fixed the source build for me on Mac Sierra:

sudo port install automake autoconf libtool dpkg pkgconfig nasm

@jmeit

This comment has been minimized.

jmeit commented Feb 7, 2017

On Ubuntu 16.04, sudo apt install nasm worked for me!

@LitvinenkoEvgeny

This comment has been minimized.

LitvinenkoEvgeny commented May 3, 2017

hey guys did you try this ?
mozilla/mozjpeg#99 (comment)

@desmond132518

This comment has been minimized.

desmond132518 commented Jul 11, 2017

On MacOS 10.11.6, I did this

brew install automake autoconf libtool dpkg pkgconfig nasm libpng

@genio

This comment has been minimized.

genio commented Feb 13, 2018

Still no dice here on CentOS 7.

# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)
# yum install nasm gcc make autoconf automake m4 libtool wget curl libjpeg-turbo-utils libjpeg-turbo-devel libpng libpng-devel
Loaded plugins: fastestmirror, priorities, replace, versionlock
Loading mirror speeds from cached hostfile
 * base: mirror.pac-12.org
 * epel: mirrors.cat.pdx.edu
 * extras: mirrors.cat.pdx.edu
 * updates: mirrors.kernel.org
 * webtatic: uk.repo.webtatic.com
Package nasm-2.10.07-7.el7.x86_64 already installed and latest version
Package gcc-4.8.5-16.el7_4.1.x86_64 already installed and latest version
Package 1:make-3.82-23.el7.x86_64 already installed and latest version
Package autoconf-2.69-11.el7.noarch already installed and latest version
Package automake-1.13.4-3.el7.noarch already installed and latest version
Package m4-1.4.16-10.el7.x86_64 already installed and latest version
Package libtool-2.4.2-22.el7_3.x86_64 already installed and latest version
Package wget-1.14-15.el7_4.1.x86_64 already installed and latest version
Package curl-7.29.0-42.el7_4.1.x86_64 already installed and latest version
Package libjpeg-turbo-utils-1.2.90-5.el7.x86_64 already installed and latest version
Package libjpeg-turbo-devel-1.2.90-5.el7.x86_64 already installed and latest version
Package 2:libpng-1.5.13-7.el7_2.x86_64 already installed and latest version
Package 2:libpng-devel-1.5.13-7.el7_2.x86_64 already installed and latest version
Nothing to do

and then:

# npm install -g mozjpeg
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/usr/bin/mozjpeg -> /usr/lib/node_modules/mozjpeg/cli.js

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

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

Error: callback() can only be called once.
    at onetime (/usr/lib/node_modules/mozjpeg/node_modules/onetime/index.js:15:11)
    at /usr/lib/node_modules/mozjpeg/node_modules/download/index.js:156:5
    at ConcatStream.<anonymous> (/usr/lib/node_modules/mozjpeg/node_modules/concat-stream/index.js:36:43)
    at ConcatStream.emit (events.js:165:20)
    at finishMaybe (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:620:14)
    at endWritable (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:628:3)
    at ConcatStream.Writable.end (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:584:41)
    at DuplexWrapper.onend (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:255:19)
    at DuplexWrapper.emit (events.js:165:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mozjpeg@5.0.0 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mozjpeg@5.0.0 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!     /root/.npm/_logs/2018-02-13T03_25_29_915Z-debug.log
@FernandoMiguel

This comment has been minimized.

FernandoMiguel commented Mar 14, 2018

anyone ever figured how to natively install this in alpine without requiring to build from source?

@andot

This comment has been minimized.

andot commented Mar 19, 2018

I get the same error:

sudo npm install mozjpeg -g
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/usr/bin/mozjpeg -> /usr/lib/node_modules/mozjpeg/cli.js

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

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

Error: callback() can only be called once.
    at onetime (/usr/lib/node_modules/mozjpeg/node_modules/onetime/index.js:15:11)
    at /usr/lib/node_modules/mozjpeg/node_modules/download/index.js:156:5
    at ConcatStream.<anonymous> (/usr/lib/node_modules/mozjpeg/node_modules/concat-stream/index.js:36:43)
    at ConcatStream.emit (events.js:185:15)
    at finishMaybe (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:620:14)
    at endWritable (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:628:3)
    at ConcatStream.Writable.end (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_writable.js:584:41)
    at DuplexWrapper.onend (/usr/lib/node_modules/mozjpeg/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (events.js:272:13)
    at DuplexWrapper.emit (events.js:185:15)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mozjpeg@5.0.0 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mozjpeg@5.0.0 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!     /root/.npm/_logs/2018-03-19T11_29_33_714Z-debug.log
@thegbom

This comment has been minimized.

thegbom commented Apr 12, 2018

Complements to okodor (mozilla/mozjpeg#99):

sudo apt-get -y install build-essential cmake libtool autoconf automake m4 nasm pkg-config
sudo ldconfig /usr/lib
cd ~
wget https://github.com/mozilla/mozjpeg/archive/v3.1.tar.gz
tar -xvzf v3.1.tar.gz
cd mozjpeg-3.1/
autoreconf -fiv
mkdir build
cd build
sh ../configure
sudo make install

I supplemented a missing tar-statement. Running npm install after the steps above, I did not get the error.

@boogie4eva

This comment has been minimized.

boogie4eva commented Apr 16, 2018

Great this worked for me .

@behroozam

This comment has been minimized.

behroozam commented Jun 19, 2018

everytime i use npm for install nodejs dependencies , its stock on pre or post install scripts for install laravel-mix dependencies like gifsicle or mozjpeg in ci for alpine docker sometime for poor internet connection ,sometime for iran sanctions that make github usless without proxy.
in that case i suggest install node-sass first and ignore scripts like this in your dockerfile
RUN npm install --ignore-scripts && npm install node-sass --verbose && npm run production --verbose && npm cache clean --force && rm -rf node_modules

@debasishshanti

This comment has been minimized.

debasishshanti commented Aug 14, 2018

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

@joepagan

This comment has been minimized.

joepagan commented Sep 18, 2018

@debasishshanti can't quite believe that was it, how annoying, package-lock built on macos, then centos really hated it... what the actual...

@xakzona

This comment has been minimized.

@debasishshanti

This comment has been minimized.

debasishshanti commented Oct 26, 2018

@joepagan Many packages have OS specific implementations/versions. So when lock file is created in a particular OS it will reference the dependencies needed for that OS. I believe this is the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment