imagemin icon indicating copy to clipboard operation
imagemin copied to clipboard

mozjpeg pre-build test failed

Open bshack opened this issue 9 years ago • 55 comments

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

[email protected] 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

> [email protected] 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)

> [email protected] 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

bshack avatar May 07 '16 03:05 bshack

$ nasm -v

shinnn avatar May 07 '16 04:05 shinnn

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

bshack avatar May 07 '16 04:05 bshack

https://github.com/mozilla/mozjpeg/blob/da75d56d6c71fcf33cca2118065af13409fe35d4/BUILDING.txt#L21-L22

Can you update NASM and try installation again?

shinnn avatar May 07 '16 04:05 shinnn

NASM version 2.12.01 compiled on Mar 23 2016

 ✔ optipng pre-build test passed successfully

> [email protected] 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)

> [email protected] 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

bshack avatar May 07 '16 04:05 bshack

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

shinnn avatar May 07 '16 04:05 shinnn

Mine is a fresh install of os x 10.11.4

bshack avatar May 07 '16 13:05 bshack

I also have the latest Xcode updates

bshack avatar May 07 '16 13:05 bshack

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

nathangaw avatar May 07 '16 22:05 nathangaw

@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 avatar May 08 '16 05:05 shinnn

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.

shinnn avatar May 08 '16 05:05 shinnn

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

shelldandy avatar May 08 '16 16:05 shelldandy

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

bshack avatar May 08 '16 17:05 bshack

@bshack No.

Also I added OSX test to the mozjpeg npm package in https://github.com/imagemin/mozjpeg-bin/commit/b0bd5cdd7fc276891701642584ad9bb2422178a0. It runs with OSX v10.11 and Xcode v7.3 and, in contrast to @mike3run's comment https://github.com/imagemin/imagemin/issues/168#issuecomment-217732098, it passes the build test.

shinnn avatar May 09 '16 11:05 shinnn

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

bshack avatar May 09 '16 12:05 bshack

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 avatar May 09 '16 14:05 shelldandy

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

shelldandy avatar May 09 '16 14:05 shelldandy

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.

chrisvanpatten avatar May 09 '16 14:05 chrisvanpatten

What @chrisvanpatten did worked for me as well.

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

shelldandy avatar May 09 '16 16:05 shelldandy

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)

afzal273 avatar Jun 18 '16 01:06 afzal273

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

shelldandy avatar Jun 18 '16 01:06 shelldandy

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?

afzal273 avatar Jun 18 '16 01:06 afzal273

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

shelldandy avatar Jun 18 '16 02:06 shelldandy

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 avatar Oct 17 '16 14:10 artmatsak

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

artmatsak avatar Oct 17 '16 20:10 artmatsak

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.

wmartins avatar Dec 07 '16 19:12 wmartins

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

[email protected] 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

westyby avatar Jan 27 '17 13:01 westyby

This fixed the source build for me on Mac Sierra:

sudo port install automake autoconf libtool dpkg pkgconfig nasm

ahgittin avatar Feb 07 '17 13:02 ahgittin

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

jmeit avatar Feb 07 '17 19:02 jmeit

hey guys did you try this ? https://github.com/mozilla/mozjpeg/issues/99#issuecomment-52628719

LitvinenkoEvgeny avatar May 03 '17 18:05 LitvinenkoEvgeny

On MacOS 10.11.6, I did this

brew install automake autoconf libtool dpkg pkgconfig nasm libpng

desmond132518 avatar Jul 11 '17 03:07 desmond132518