Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Unlink symlinked directory target #30

maherbeg opened this Issue Aug 9, 2013 · 6 comments


None yet
5 participants

maherbeg commented Aug 9, 2013

When a clean is invoked on a symlinked folder, the symlink still appears in the folder but in a broken state. Could the clean target automatically unlink the folder?

Would something like this make more sense as a user filter? If so, could examples using symlinks be shown as well?


arcanis commented Dec 23, 2013

Up. Contrib clean is currently not able to delete symlinks. Maybe adding an option would be enough without breaking BC ?

dazld commented Jan 15, 2014

also want this.


jmeas commented Feb 20, 2014

Update: I'm thinking this might be relevant. When I made a working symlink it cleaned just fine. Here's an example that will create a symlink that can be removed, and one that can't.

If this is the case, the issue is more a matter of reporting bad symlinks.

What OS are y'all using?

I'm working on a fix for this for OSX. Here's what I know so far:

grunt-contrib-clean is just a wrapper around isaac's rimraf, and rimraf has no problem deleting symlinks. So the issue is with grunt-contrib-clean, or maybe even node.

The first problem is this if statement. grunt.file.exists relies on fs.exists, which seems to return false for symlinks – or at least the symlink that I've made. I'm thinking this check can be removed altogether. (Note: ref this issue which suggests that exists should work for symlinks)

The second issue is this line. grunt.file.isPathInCwd depends on fs.realpath, which throws the following error when I pass my symlink's path as the argument:

Error: ELOOP, too many symbolic links encountered

I thought that this might be relevant, but it's only throwing the error with the node function. Everything else seems a-okay.

If anyone else has any ideas, feel free to chime in. Otherwise I'll look more into this sometime soon.

Note to self: using fs.lstatSync(filepath).isSymbolicLink() could be useful.


vladikoff commented Jul 28, 2014

@jmeas is this related to gruntjs/grunt#1069 ?


jmeas commented Jul 28, 2014

Only as far as them both involving symlinks. This is a bug with bad symlinks, I think, and that's adding new functionality to grunt.


vladikoff commented Jul 28, 2014

@jmeas ah both involve changes to the grunt.file module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment