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

Error: spawn ENOENT when running imagemin task #96

Closed
msguerra74 opened this issue Oct 25, 2013 · 35 comments
Closed

Error: spawn ENOENT when running imagemin task #96

msguerra74 opened this issue Oct 25, 2013 · 35 comments

Comments

@msguerra74
Copy link

I'm getting the following error when running imagemin. I'm not sure why, but it looks like it's adding a tmp folder inside the 'grunt-jekyll' task? I've tried running it independent of any other task and the same error occurs. After crashing, it leaves some of the images in the output folder with '.tmp' extensions (ex: image.png.tmp). Any ideas would be greatly appreciated, thanks!

Running "imagemin:images" (imagemin) task

D:\Dropbox\Projects\automata\node_modules\grunt-jekyll\node_modules\tmp\lib\tmp.js:261
  throw err;
        ^
Error: spawn ENOENT
  at errnoException (child_process.js:980:11)
  at Process.ChildProcess._handle.onexit (child_process.js:771:34)
@ngarland79
Copy link

Same for me, when I do a grunt build, I get this:

Running "imagemin:dist" (imagemin) task
app/images/bos_header.jpg (saved 3.99 kB)

/Users/ngarland1/Projects/bouleutai/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
  throw err;
        ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

@msguerra74
Copy link
Author

It looks like it's backing out of it's own directory and into an adjacent one or something. This also only seems to happen with PNGs.

@msguerra74
Copy link
Author

I was updating my NPMs today and noticed a popup from Microsoft Security Essentials giving the following notice, stating it's quarantining a file (optipng.exe) it believes to be a virus, which is probably why this problem has been occurring. Apparently this has been happening for the last couple of weeks, so I've left the file quarantined until further notice. Any thoughts on this?

virus

@vladikoff
Copy link
Member

Duplicate of imagemin/optipng-bin#12

@msguerra74
Copy link
Author

I've removed the quarantined "optipng.exe" file, disabled the virus program, removed all node_modules and reinstalled, and am still getting the same error. I even disabled all imagemin options and this is what it's telling me when running 'grunt imagemin --vebose'

Running tasks: imagemin

Running "imagemin" task

Running "imagemin:images" (imagemin) task
Verifying property imagemin.images exists in config...OK
Files: Projects/_example.com/_assets/images/apple-touch-icon-precomposed.png ->
Projects/_example.com/assets/img/apple-touch-icon-precomposed.png
Options: optimizationLevel=0, progressive=false, pngquant, interlaced=false, pngquaint=false
Reading Projects/_example.com/_assets/images/apple-touch-icon-precomposed.png...OK

D:\Dropbox\Projects\automata\node_modules\grunt-jekyll\node_modules\tmp\lib\tmp.js:261
  throw err;
        ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)
PS D:\Dropbox\Projects\automata>

@vladikoff vladikoff reopened this Oct 30, 2013
@oxtoacart
Copy link

I'm getting this error on OS X. It looks like imagemin looks for the pngquant binary in node_modules/pngquant-bin/vendor/pngquant. Unfortunately, as of version 0.1.4 of pngquant-bin, that binary is in a different location.

I believe that the solution is to update package.json to reference a specific version of pngquant-bin instead of any 0.1 version. I tried 0.1.3 and it worked for me.

@msguerra74
Copy link
Author

Everything in my build process works flawlessly and I only ever have problems with grunt-contrib-imagemin, so my conclusion is that this is pretty much worthless on Windows machines. I still get the spawn error, so bleh... I'm done.

@stowball
Copy link

This still chokes on JPEGs using jpegtran-bin 0.2.3 and grunt-contrib-imagemin 0.5.0. Tested on Win 8.1 Pro 64 bit. It's a tad frustrating

@JBusch
Copy link

JBusch commented Jan 20, 2014

Same issues here. Also Win 8.1 64bit.

@rikvanmechelen
Copy link

+1 on Win 8.1 64bit

@fitzchak
Copy link

+1, it fails on Win 8.1 x64

@Guuz
Copy link

Guuz commented Jan 23, 2014

So what now? I'm on Win 8.1 64 bit and I am having this problem. Any workarounds or alternatives? Or just no image optimization for me anymore? :-/
Other people on my team run other OS'es so its really annoying that I can not build...

@vladikoff
Copy link
Member

@Guuz tried falling back to ~0.4?

@Guuz
Copy link

Guuz commented Jan 23, 2014

@vladikoff no, I will give that a try!

@stowball
Copy link

@vladikoff I was on 0.4.0 and it didn’t work, which is why I tried upgrading to 0.5.0. No dice ☹

@Guuz
Copy link

Guuz commented Jan 24, 2014

@vladikoff : Strange... We were actually on v0.3.0. I have just upgraded to v0.5.0 and this works for us on Win 7, Win 8.1 and mac. v0.4.0 also worked.

@BlueInt32
Copy link

Hi,
The problem occured to me with png files using the latest 0.5.0 version (default npm install version btw) of grunt-imagemin-contrib, then I tried what Guuz suggested with previous version (0.4.1 seems to be stable) and this worked again.

I guess switching versions could make it work...

@Fire-Dragon-DoL
Copy link

Has this problem being fixed? I still have it: with version 0.3.0 it's present in one directory and NOT present in another, so it's a package dependency breaking everything... If I copy imagemin package from an older project (always 0.3.0 version), this works fine. I'm trying to find out what's causing it.

@Fire-Dragon-DoL
Copy link

I can say the cause is pngquant-bin module. I couldn't track it down to a submodule because after specifying a version, it's auto-fixed:

{
    "pngquant-bin": "0.1.6",
    "gifsicle": "0.1.4",
    "jpegtran-bin": "0.2.3",
    "optipng-bin": "0.3.1",
    "pngquant-bin": "0.1.6",
    "grunt-contrib-imagemin": "0.3.0"
}

This in my package.json fixed the issue

Important note: specify those in your package.json, CLEAN node_modules directory (completely, even .bin directory), restart your computer, I think it's an issue with environment or a link to an exe that doesn't exist, I don't know, but I didn't want to track it down so restarting was ok (one time). After restart, run npm install and it should work.

My full package.json if anyone interested: https://gist.github.com/Fire-Dragon-DoL/407c4823af0d7811cfa9

@patik
Copy link

patik commented May 21, 2014

I fixed it by following @Fire-Dragon-DoL's advice directly above. Then I followed this comment's instructions. Finally, I did npm install -g gifsicle and npm install -g node-optipng and copied those folders to my project's /node_modules/grunt-contrib-imagemin/node_modules folder, similar to jpegtrain. This is for Windows 7 32-bit.

@vlrprbttst
Copy link

i've been struggling with imagemin in general from so long on so many issues i might go back to some simpler GUI like prepros or something

@kevva
Copy link
Member

kevva commented Aug 16, 2014

@vlrprbttst, that isn't very helpful. Could you describe what problems you are experiencing?

@vlrprbttst
Copy link

my latest problem is this: http://prntscr.com/4dcsqk
prior to this i tried to make the watch task go togheter with imagemin, trying to make it optimize only the newer pictures in my source folder and failed at that (http://stackoverflow.com/questions/24099367/imagemin-for-gruntjs-used-with-watch-for-grunt-not-properly-watching-my-files) too. but i may be off-topic here, sorry for that

@patik
Copy link

patik commented Aug 16, 2014

Ultimately, the problem is that you cannot simply run npm install grunt-contrib-imagemin and expect it to work, at least not on Windows. You have to fiddle around with each individual optimizer (optipng, etc) — see my comment above.

Also, at least in my experience you can't simply run npm update on a project once you've gotten imagemin working. I did so but luckily I had a backup of my node_modules folder.

@kevva
Copy link
Member

kevva commented Aug 16, 2014

The watch task isn't related to imagemin, it's just how that one works. The spawn issue is caused by some binary not existing. Try installing a newer version of imagemin (^1.0.0).

I have no problems whatsoever on Windows. Most of the issues are with Linux.

@wethinkagile
Copy link

This is latest Mac Yosemite, date is March 2015. Installed imagemin as well as pngquant latest version. Not working, failing with error message provided by the thread creator.

@SamJacobs
Copy link

Installing earlier version of contrib-imagemin fixed it for me. I picked one at random. used 0.4.0, grunt build worked

@jzaric
Copy link

jzaric commented Mar 26, 2015

@SamJacobs Worked for me. I was using 0.8.0 and it started working when I installed 0.7.0

@binarykitchen
Copy link

Okay, I found out when this is happening: when the prebuild-test failed and thus is compiling from the source, see extract below:

  ⚠ Couldn't connect to https://raw.github.com/imagemin/optipng-bin/v2.0.4/vendor/linux/x64/optipng (503)
  ⚠ optipng pre-build test failed
  ℹ compiling from source
  ✖ Error: ./configure --with-system-zlib --prefix="/var/www/signdna-video/live/source/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor" --bindir="/var/www/signdna-video/live/source/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor" && make install
Command failed: 
    at ChildProcess.exithandler (child_process.js:648:15)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Socket.<anonymous> (child_process.js:969:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

This happened during instable network conditions which is not the real issue here. The problem is that compiling from source results in a different state than when doing the pre-build. Both ways should make the code behave the same.

@schmod
Copy link

schmod commented Mar 30, 2015

I'm having a similar issue with jpegtran failing to build, likely due to Github's network problems...

The real underlying issue seems to be that optipng and jpegtran's build scripts can fail "silently," without cascading upwards to imagemin/grunt-imagemin.

@schmod
Copy link

schmod commented Mar 30, 2015

I've opened a PR in jpegtran-bin that will hopefully cause compilation errors to propogate upward, so that the NPM module doesn't trick any dependent packages into believing that it was installed successfully.

@kevva
Copy link
Member

kevva commented Mar 31, 2015

@schmod, that's exactly what we want. They are optional dependencies. Be aware of any error messages when installing instead.

@schmod
Copy link

schmod commented Mar 31, 2015

I left a comment in the other thread.

Essentially, I don't think that's actually a desirable behavior, as it bypasses npm's built-in infrastructure for handling optional dependencies, and effectively makes imagemin and grunt-contrib-imagemin unsafe to use in a scripted environment, as it doesn't provide any reliable mechanism to determine whether or not everything installed correctly.

imagemin already has logic to gracefully treat jpegtran-bin as an optional dependency, but that logic is worthless if jpegtran-bin's build script doesn't report failures.

@patternboxtech
Copy link

Ran into this issue with "grunt-contrib-imagemin": "^0.8.1". Updated to "grunt-contrib-imagemin": "^0.9.4" fixed my issue.

@sbley
Copy link

sbley commented Jun 2, 2015

Updating "grunt-contrib-imagemin" from "^0.9.2" to "^0.9.4" fixed my issue.

@gruntjs gruntjs locked and limited conversation to collaborators Jun 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests