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

**URL:** https://discourse.roots.io/t/gulp-dies-when-images-are-added-or-when-running-gulp-or-gulp-build-solved/4162
**Category:** sage
**Tags:** gulp
**Created:** 2015-07-02T04:08:57Z
**Posts:** 12

## Post 1 by @alwaysblank — 2015-07-02T04:08:57Z

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](https://discourse.roots.io/t/gulp-error-spawn-eacces-resulting-from-images-added-to-asset-folder/3950). 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
```

---

## Post 2 by @kalenjohnson — 2015-07-02T04:41:03Z

What version of node and npm do you have?

---

## Post 3 by @alwaysblank — 2015-07-02T04:43:21Z

Sorry, forgot to add that:

npm - 2.12.0  
node - v0.12.0

---

## Post 4 by @kalenjohnson — 2015-07-02T06:33:01Z

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

---

## Post 5 by @austin — 2015-07-02T12:40:40Z

EACCESS + “cannot execute {{ binary }}” = permissions issues

Try out [https://docs.npmjs.com/getting-started/fixing-npm-permissions](https://docs.npmjs.com/getting-started/fixing-npm-permissions).

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

---

## Post 6 by @alwaysblank — 2015-07-03T01:27:57Z

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.

---

## Post 7 by @kalenjohnson — 2015-07-03T04:06:17Z

You could set the project up on the Ubuntu drive and see if it works…

---

## Post 8 by @austin — 2015-07-03T15:12:04Z

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

---

## Post 9 by @kalenjohnson — 2015-07-06T05:02:22Z

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.

---

## Post 10 by @alwaysblank — 2015-07-07T16:22:16Z

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`

---

## Post 11 by @alwaysblank — 2015-07-07T18:25:38Z

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.

---

## Post 12 by @kalenjohnson — 2015-07-07T18:42:42Z

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.
