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

Keep getting ENOTEMPTY error. Unable to delete directories. #34

Closed
Saturate opened this issue Sep 4, 2013 · 28 comments
Closed

Keep getting ENOTEMPTY error. Unable to delete directories. #34

Saturate opened this issue Sep 4, 2013 · 28 comments

Comments

@Saturate
Copy link

Saturate commented Sep 4, 2013

I am having trouble deleting my dirs when running grunt-contrib-clean I get this output

Running "clean:dist" (clean) task
Verifying property clean.dist exists in config...OK
Files: .tmp, dist -> dist
Options: force, no-write=false
Cleaning .tmp...ERROR
Warning: Unable to delete ".tmp" file (ENOTEMPTY, directory not empty 'C:\Path\.tmp'). Use --force to continue.

Aborted due to warnings.

This is my grunt config:

clean: {
    options: { force: true },
    dist: ['.tmp', 'dist']
},

Is there anything that I can do to fix this issue?

System information

  • Windows 7
  • Node version: 0.10.17
  • Grunt version: 0.4.1
  • Task version: 0.5.0
@oanguenot
Copy link

I have the same problem. (same system information)

@Saturate
Copy link
Author

In addition to this I also tried 'dist/**/*' with the same problem.

@shama
Copy link
Member

shama commented Sep 10, 2013

This seems related to isaacs/rimraf#25

@Saturate
Copy link
Author

But @shama we are not creating files are we? That issue was

Seems that it was creating files while rimraf was trying to delete at the same time

It works about 20% of the time with no issues.

After some investigation, mostly just changed to dist/**/* it seems that it is the "dist/bower_components" dir thats the problem, but only some times. It's a little strange as bower does nothing with this dir, it's the copy task that clones the dir.

@mlarcher
Copy link

mlarcher commented Oct 7, 2013

I had the same problem; but it seems it was due to the fact I had an explorer window opened in the directory I was trying to delete. Could it be that you are in the same situation ?

@Saturate
Copy link
Author

Saturate commented Oct 8, 2013

@mlarcher Nope I tried closing all explore windows. Could be Anti-Virus maybe...

@mlarcher
Copy link

mlarcher commented Nov 8, 2013

I confirm that not having an explorer opened on the folder is not always enough to fix the issue.

I believe this is due to an issue in rimraf pointed out in isaacs/rimraf#25 which also affects other packages (like Medium/phantomjs#108 for example)

@vjtyagi
Copy link

vjtyagi commented Nov 17, 2013

@Saturate Are you using file watcher ? if yes then can you post your watch task ?

@Saturate
Copy link
Author

Yes I am, but I am not watching my dist folder.

    watch: {
        jshint: {
            files: ['<%= settings.app %>/{widgets,pages}/**/*.js'],
            tasks: ['jshint']
        },
        compass: {
            files: ['<%= settings.app %>/styles/**/*.{scss,sass}'],
            tasks: ['compass:server']
        },
        livereload: {
            options: {
                livereload: LIVERELOAD_PORT,
            },
            files: [
                'app/*.html',
                'app/*.js',
                '{.tmp,app}/styles/*.css',
                //'{.tmp,app}/styles/*.scss',
                '{.tmp,app}/extensions/*.js',
                '{.tmp,app}/scripts/*.js',
                'app/{widgets,pages}/**/*.hbs',
                'app/{widgets,pages}/**/*.js',
                'app/images/*.{png,jpg,jpeg}'
            ]
        }
    },

@vjtyagi
Copy link

vjtyagi commented Nov 21, 2013

I was suspecting that you are accidently watching some file in dist. If that's not the case, does you manual compilation(build) and clean(using grunt clean) work all the time ?

@Saturate
Copy link
Author

It does not work all the time, but it's extremely rare it doesn't work, so it's not that annoying anymore. It's on a VM machine with no Anti-Virus.

@CrocoDillon
Copy link

I had the same problem today. The problem was I listened to the wrong 'end' event (event from the response instead of the pipe). Changed this:

response
  .pipe(zlib.createGunzip())
  .pipe(tar.Extract({path:'grunt/extract'}));
response.on('end', callback);

...to this:

response
  .pipe(zlib.createGunzip())
  .pipe(tar.Extract({path:'grunt/extract'}))
  .on('end', callback);

...and it worked :) (the callback runs the clean task) Hope it helps anyone.

@Taiche
Copy link

Taiche commented Mar 12, 2014

I was Dropbox in my case.

@KyleMerritt
Copy link

This is working for me:

    clean: {
        dist: distDir + '/**/*.*'
    },

As long as you don't mind the directories sticking around.

@ladaltamirano
Copy link

Also happens when you have a grunt server up. Just stop the server and try to run the test again. (Reproduced on Windows 8)

@newaeonweb
Copy link

HI, i had this error and solve closing all windows explorer window. My task is:
clean: {
dist: ['dist']
},

@FrankFang
Copy link

@KyleMerritt Yeah, it works for me.

@PolygeneLubricants
Copy link

This seems to be related to https://code.google.com/p/tortoisegit/issues/detail?id=623.

Ofcause this can be caused by other processes, but it is confirmed that this particular process can be very troublesome when grunt-cleaning:
TortoiseGit's Cache will sometimes lock directories when indexing. This will often happen when adding files, for example when copying files to build folders. Disabling the cache seems to fix the problem. This can be done through TortoiseGit > Settings > Icon Overlays > Status cache = none.

@devilmark84
Copy link

I have the same problem and I think the problem was Windows 7. The same gulpfile on Windows 8 works as expected.

@mwmwmw
Copy link

mwmwmw commented Apr 5, 2015

Same problem, my issue was Dropbox. I had to pause syncing before cleaning.

@dahfazz
Copy link

dahfazz commented May 13, 2015

Thanks a lot mlarcher. I couldn't build my project until reading your comment.

...Windows :(

@bolora
Copy link

bolora commented Oct 12, 2015

In Windows this is related to windows path 255 character limit. When you have node modules that are nested deeply the windows path exceeds its limit. If you were to delete the directory by hand in the explorer window you would see the exception triggered and you get a dialog that says something like "the path is too long do you want to proceed with permanently deleting this". When fired from grunt this exception issues an error and grunt stops.

I've been able to somewhat mitigate this issue by identifying problematic node modules and deleting the node_modules directory in those first.

clean: {
dist: {
src: ['dist/problem_module_1/node_modules/','dist/problem_module_2/node_modules/', 'dist/'],
options: {
force:true
}
}
}

@androidlinked
Copy link

I have the same problem on Ubuntu14.04 but following way I have solved it.

var gulp = require('gulp');
var rimraf = require('rimraf');

// delete all files and folders from dist folder
gulp.task('clean:dist', function (cb) {
    rimraf('./dist/**/*', cb);
});

@zxxc
Copy link

zxxc commented Dec 11, 2015

I've solved issue for cordova plugins and platforms, by changings like this

was:            platforms: ['platforms']

change to:

+            platforms: {
+               files:[
+                   {
+                       dot:true,
+                       src:['platforms/**/*.*', 'platforms/*','platforms']
+                   }
+               ]
+            }

@picco
Copy link

picco commented Feb 19, 2016

To anyone bumping into this - your del task needs to complete before doing other stuff. Your log needs to look similar to this:

[23:09:30] Starting 'build'...
[23:09:30] Starting 'clean'...
[23:09:30] Finished 'build' after 9.31 ms
[23:09:30] Finished 'clean' after 18 ms
[23:09:30] Starting 'server'...
[23:09:30] Starting 'shrinkwrap'...
[23:09:30] Starting 'assets'...
[23:09:30] Starting 'webpack'...

You can solve the situation with run-sequence module for example:

var runSequence = require('run-sequence');

gulp.task('build', () => {
  runSequence('clean', ['server', 'shrinkwrap', 'assets', 'webpack']);
});

@SLdragon
Copy link

Some files are being using by another program may cause this problem.

@jerrylauky
Copy link

@bolora In my case it was the same as yours. Thank you.

@jaganathanb
Copy link

In my case, unit test was running hence could not delete the files being accessed by karma runner.

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