Skip to content

Sometimes gulp del cause EPERM error #738

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

Closed
havenchyk opened this issue Oct 22, 2014 · 11 comments
Closed

Sometimes gulp del cause EPERM error #738

havenchyk opened this issue Oct 22, 2014 · 11 comments

Comments

@havenchyk
Copy link

Hi.

I'm trying del in my clean task.

gulp.task('clean', function(cb) {
 del('build/**', cb);
});

gulp.task('build', ['clean'], function() {
    ...
});

And from time to time during running build task I've got

'clean' errored after 24 ms
Error: EPERM, rmdir 'D:\dev\projects...

OS: Windows 7.

Is it problem of my implementation or just wrong behavior on Windows?

Sorry if it's not a good place to post this problem.

Thanks

@sindresorhus
Copy link
Contributor

EPERM means it doesn't have permission to delete the folder. You probably have the wrong permission set on that folder.

@havenchyk
Copy link
Author

@sindresorhus, yeah, I understand, what means EPERM, but it happens only from time to time.

E.g. I run

  1. gulp build
    result correct (starting clean, finished clean)
    ...
    trying again
    n) gulp build
    and got "starting clean EPERM error".
    n+1) gulp build
    correct

@havenchyk
Copy link
Author

Could it be a problem of pattern?

'build/**'

@robrich
Copy link
Contributor

robrich commented Oct 22, 2014

Generally this happens on Windows because a virus scanner or other background service has the file open when you try to delete it. Thanks, MS -- a completely non-deterministic symptom. Are you on Windows?

@havenchyk
Copy link
Author

@robich, Yes, I'm on windows. I'll try to disable antivirus but changing pattern from build/** to build solves problem. I suppose, that the problem can be in pattern. But my main suggestion is that del tries to remove folder during deliting file inside this folder. Is it possible?

@heikki
Copy link
Contributor

heikki commented Oct 22, 2014

@havenchyk Yes, see sindresorhus/del#10

@havenchyk
Copy link
Author

Hmm. build/**/* also causes EPERM. Only build/**/*.* works without problem.

@havenchyk
Copy link
Author

Could anyone explain, how to handle this type of errors? e.g. to repeat task with del() in case of error

@rmorse
Copy link

rmorse commented Mar 19, 2015

I'm not sure if it's related directly to your problem but I was also getting this error intermittently - although checking my files & folders, the task had successfully run.

Looking at your particular use case it doesn't seem like this applies but I hope this helps others:

First, I was also getting another issue with watch on my build picking up newly created files:
floatdrop/gulp-watch#1

After finding this solution and solving the problem above, my del issue disappeared too:

Basically when my globs started with ./ it caused this error - simply remove it so:

./scripts/**

would become:

scripts/**

(I'm on Windows 8)

@onewebdesigner

This comment was marked as resolved.

@onewebdesigner

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants