jasonhansel
jasonhansel

Reputation: 642

Constant EBUSY issues on Windows

I have a very simple Gulpfile:

var gulp = require('gulp'),
    prefix = require('gulp-autoprefixer'),
    gsass = require('gulp-sass');
gulp.task('sass', function() {
    gulp.src('scss/*.scss')
        .pipe(gsass({
            unixNewlines: true,
            style: 'compact'
        }))
        .pipe(prefix('last 2 versions'))
        .pipe(gulp.dest('.'));
});

gulp.task('default', ['sass'], function() {
    gulp.watch('scss/*.scss', ['sass']);
});

When the SCSS file is changed and the sass task runs, I occasionally (about 10% of the time) get the following error message on the console:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: EBUSY, open 'C:\whatever\scss\main.scss'

The error in question happens during the call to gulp.src. Passing the read: false option into that function stops the error from happening (but, of course, prevents sass from working).

This error is a problem because the watch task stops running whenever the error is encountered. Neither gulp-plumber nor .on('error', ...) help with this problem.

Is there a way to work around this issue? I'm on Windows, if it's relevant.

A few more relevant points:

Upvotes: 1

Views: 3368

Answers (2)

Eleanor Zimmermann
Eleanor Zimmermann

Reputation: 432

There is a decent chance you have one of your files open in Microsoft Word. Word locks up access to the file. Completely exit MS Word and re-build. Fixed the problem for me. Hope it helps!

Upvotes: 3

Ben
Ben

Reputation: 10156

So I'm not entirely sure about this because I don't run Windows, but here's some pointers:

  • Like I mentioned in the comment, always return your streams from gulp tasks. That way gulp's task manager knows when the task finishes and can properly sequence your dependencies.
  • If you are overwriting files that are being used by the system, it's not recommended. See this issue for a little more detail: https://github.com/joyent/node/issues/3017
  • I'm not sure this will help either, but you could try writing your compiled CSS into a subdirectory, say ./dist/css or something along those lines.
  • It may be worth opening an issue (after trying the above points first!) on vinyl-fs which is the module used for gulp.src etc.

Upvotes: 0

Related Questions