Gulp dies when images are added, or when running 'gulp' or 'gulp build' [solved]

When I run gulp or gulp build, or when I add an image to the assets/images folder when gulp watch is running, I get the following error and gulp dies and dumps me to the command line:

[20:50:21] Using gulpfile /path/to/project/dev/site/web/app/themes/proj_name/gulpfile.js
[20:50:21] Starting 'build'...
[20:50:21] Starting 'wiredep'...
[20:50:22] Finished 'wiredep' after 444 ms
[20:50:22] Starting 'styles'...
[20:50:25] Finished 'styles' after 3.04 s
[20:50:25] Starting 'jshint'...
[20:50:25] Finished 'jshint' after 212 ms
[20:50:25] Starting 'scripts'...
[20:50:29] Finished 'scripts' after 4.6 s
[20:50:29] Starting 'fonts'...
[20:50:29] Starting 'images'...
child_process.js:1155
    throw errnoException(err, 'spawn');
          ^
Error: spawn EACCES
    at exports._errnoException (util.js:746:11)
    at ChildProcess.spawn (child_process.js:1155:11)
    at exports.spawn (child_process.js:988:9)
    at exports.execFile (child_process.js:682:15)
    at ExecBuffer.<anonymous> (/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/exec-buffer/index.js:91:3)
    at /path/to/project/dev/site/web/app/themes/proj_name/node_modules/wiredep/node_modules/bower-config/node_modules/graceful-fs/graceful-fs.js:104:5
    at /path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-rev/node_modules/vinyl-file/node_modules/graceful-fs/graceful-fs.js:42:10
    at FSReqWrap.oncomplete (fs.js:99:15)

Iā€™ve read a few threads from people who seem to be having the same problem like this one: Gulp Error: spawn EACCES resulting from images added to asset folder. I tried deleting my node_modules folder as it suggested and re-running npm install it had no effect: I still get the exact same error.

I get some errors when I run npm install that I think might be related, since they seem to have to do with gulp stuff that relates to images (warning, this is a long chunk of text):

  āš  gifsicle pre-build test failed                                                                                                                                                                                [237/1382]
  ā„¹ compiling from source
  āœ” gifsicle built successfully
npm WARN optional dep failed, continuing fsevents@0.3.6
 
> optipng-bin@3.0.2 postinstall /path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin
> node lib/install.js

  āš  Couldn't execute the `/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/optipng-bin/vendor/optipng` b
inary. Make sure it has the right permissions.
  āš  optipng pre-build test failed
  ā„¹ compiling from source
  āœ” optipng built successfully

> jpegtran-bin@3.0.2 postinstall /path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin
> node lib/install.js

  āš  Couldn't execute the `/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin/vendor/jpegtran
` binary. Make sure it has the right permissions.
  āš  jpegtran pre-build test failed
  ā„¹ compiling from source
  āœ– Error: ./configure --disable-shared --prefix="/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpeg
tran-bin/vendor" --bindir="/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bin/vendor" && mak
e install
Command failed: /bin/sh -c ./configure --disable-shared --prefix="/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/n
ode_modules/jpegtran-bin/vendor" --bindir="/path/to/project/dev/site/web/app/themes/proj_name/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-jpegtran/node_modules/jpegtran-bi
n/vendor"
configure: error: no nasm (Netwide Assembler) found

    at ChildProcess.exithandler (child_process.js:744:12)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1008:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1080:5)

> pngcrush-bin@3.0.0 postinstall /path/to/project/dev/site/web/app/themes/proj_name/node_modules/imagemin-pngcrush/node_modules/pngcrush-bin
> node lib/install.js

  āš  Couldn't execute the `/path/to/project/dev/site/web/app/themes/proj_name/node_modules/imagemin-pngcrush/node_modules/pngcrush-bin/vendor/pngcrush` binary. Make sure it has the right permissions.
  āš  pngcrush pre-build test failed
  ā„¹ compiling from source
  āœ” pngcrush built successfully

What version of node and npm do you have?

Sorry, forgot to add that:

npm - 2.12.0
node - v0.12.0

I havenā€™t seen issues with permissions like that before. Maybe try googling how to clear npm cache. If youā€™ve ever done sudo npm install your ~/.npm folder might have bad permissions. Other than that, Iā€™m not sure

EACCESS + ā€œcannot execute {{ binary }}ā€ = permissions issues

Try out https://docs.npmjs.com/getting-started/fixing-npm-permissions.

Also verify that your actual folder permissions on your machine are correct.

I checked out your link @austin, but I have Node/NPM installed through NVM so Iā€™m not sure if itā€™s the same process. I did check the permissions on the folder I got from npm config get prefix, and they appear to be correct (ā€œbenā€ is my user):

/home/ben/.nvm/versions/node/v0.12.0

drwxrwxr-x 3 ben ben 4.0K Feb  9 00:12 .
drwxrwxr-x 4 ben ben 4.0K Feb  9 00:12 ..
drwxrwxr-x 7 ben ben 4.0K Mar 17 19:01 v0.12.0

The permissions on my assets/images folder, and the images in it, also look like theyā€™re okay:

assets/

drwx------ 1 ben ben 4.0K Jun 19 13:20 .
drwx------ 1 ben ben 4.0K Jul  1 20:47 ..
drwx------ 1 ben ben    0 Jun  4 15:53 fonts
drwx------ 1 ben ben 4.0K Jul  1 12:06 images
-rw------- 1 ben ben  423 Jun 23 20:37 manifest.json
drwx------ 1 ben ben    0 Jun 23 22:04 scripts
drwx------ 1 ben ben 4.0K Jun 19 13:20 styles


assets/images/

drwx------ 1 ben ben 4.0K Jul  1 12:06 .
drwx------ 1 ben ben 4.0K Jun 19 13:20 ..
-rw------- 1 ben ben    0 Jun  4 15:53 .gitkeep
-rw------- 1 ben ben  562 Jun 24 15:40 left.png
-rw------- 1 ben ben  481 Jun 24 15:40 left.svg
-rw------- 1 ben ben  29K Jul  1 10:55 lines-repeat.png
-rw------- 1 ben ben 6.1K Jun 24 12:19 logo.png
-rw------- 1 ben ben 7.4K Jun 24 12:20 logo.svg
-rw------- 1 ben ben 5.6K Jun 24 12:24 notch.png
-rw------- 1 ben ben  14K Jun 30 08:42 plant_logo.png
-rw------- 1 ben ben  547 Jun 24 15:41 right.png
-rw------- 1 ben ben  480 Jun 24 15:41 right.svg

Iā€™m working in Ubuntu 14.04 LTS, which is on a dual-boot system with Window 8, and the files in question are on an NTFS drive that both OSes use. Could that be affecting any of this?

@kalenjohnson, I tried clearing the cache and rebuilding node_modules again, but Iā€™m still getting the same error.

You could set the project up on the Ubuntu drive and see if it worksā€¦

@kalenjohnson those permissions do not look right. What are your permissions on your Ubuntu box?

The permissions do look pretty restrictive. You can set the permissions when you mount a drive via fstab, and I donā€™t think the default mounting options if you click on a drive via the ā€œFilesā€ explorer app is that restrictive. I think the default mounting options are actually basically full write access for everyone, unless I changed something when I was mounting a drive for Steamā€¦

In any case, I would try my last suggestion, try doing everything on the Ubuntu drive. If it works, then you know you need to start trying some different permissions on the NTFS mounted shared drive.

Hey everyone! Thanks for all your help, Iā€™ve finally got it working.

It was indeed a permissions issue. The Ubuntu auto-mount (the one you get when just click a drive to mount it in Nautilus) was applying those restrictive permissions forā€¦reasons, apparently. I ended up solving it by adding the following line to my fstab (ā€˜benā€™ is my userā€™s name):

UUID=[UUID_Number] /media/ben/Galifrey ntfs-3g uid=ben,gid=users,umask=0022,windows_names 0 0

Short follow-up:

Although this got Gulp working, it broke Vagrant (Iā€™m using Bedrock): When I tried to bring my machine up, it complained that the private key file it needed for SSH didnā€™t have the correct permissions (0600). I was unable to change the permissions on it (presumably because itā€™s on an NTFS drive). I was able to make a workaround by just making a soft link to a private key file with the correct permissions, but I thought I should add this note in case anyone runs into the same secondary problem.

1 Like

Iā€™ve also had issues with NTFS drives in the past, for the same reasons youā€™re having, permissions are frustrating and difficult to change.

What Iā€™ve ended up doing is keeping all my current work in the /home/kalen/Work directory, that way permissions can be set correctly, and generally there are a lot less issues. I then move any ā€œarchivedā€ work to the NTFS drive.

Thanks for posting what your fix was though, always appreciated.