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

node 5.7.0 – Warning: Cannot delete files outside the current working directory. #85

Closed
m99coder opened this issue Feb 23, 2016 · 12 comments

Comments

@m99coder
Copy link

Hi guys,

I’m experiencing an issue with the new node 5.7.0.

// Gruntfile.js
grunt.initConfig({
    clean: {
        test: {
            src: ['coverage']
        }
    }
});
$ grunt test:clean --verbose
/* ... */
Running "clean:test" (clean) task
Verifying property clean.test exists in config...OK
Files: coverage
Options: force=false, no-write=false
ERROR
Warning: Cannot delete files outside the current working directory. Use --force to continue.

$ node -v && npm -v
v5.7.0
3.7.3

It work fine before the node update and I don’t get why the given coverage directory should be outside of working directory. Gruntfile.js and coverage directory are at the same level. The exact same level I’m calling grunt test:clean in.

If you need further more verbose output let me know.

@timvancleef
Copy link

Having the same issue.
There seems to be a change in nodejs' path.relative() function.
With Node v4.3.1 path.relative('a/b/c', 'a/b') returns ..
Whereas with Node v5.7.0 it returns ../c.
Therefore the isPathInCwd check in the clean task itself fails.

@mscdex
Copy link

mscdex commented Feb 23, 2016

@timvancleef For me node -pe "require('path').relative('a/b/c', 'a/b')" on node v5.7.0 outputs ../../b and not ../c.

@timvancleef
Copy link

@mscdex oh you are right.
Noetheless the important/problematic part is the b, because isPathInCwd checks for word characters (/w+/).

@shama
Copy link
Member

shama commented Feb 23, 2016

Related failing test: https://travis-ci.org/gruntjs/grunt-contrib-clean/jobs/110697189 Nice research you all :)

@spdaly
Copy link

spdaly commented Feb 23, 2016

+1

@shian48263
Copy link

+1 on OS X El Capitan.

Is it save to add options: {force: true} for the moment before node v5.7.1 is released?

@shama
Copy link
Member

shama commented Feb 24, 2016

If you want safety, I recommend going with Node v4.3.1 until a fix is released.

@roryhardy
Copy link

For what it's worth, I haven't observed this issue with versions of Node prior to 5.7.0 (on 5.6.0 currently).

@vbarbarosh
Copy link

Have the same issue.

$ node --version
v5.7.0
$ node -pe 'require("path").relative("/aa/bb/cc/dd", "/aa/bb/cc")'
../../cc

$ node --version
v5.0.0
$ node -pe 'require("path").relative("/aa/bb/cc/dd", "/aa/bb/cc")'
..

@m99coder
Copy link
Author

The node team already fixed it with this commit nodejs/node@3a331b6

@XhmikosR
Copy link
Member

XhmikosR commented Mar 3, 2016

Node.js 5.7.1 is out with the relevant fixes.

@ctrlmaniac
Copy link

Hmm same problem here:

$ node --version
v8.9.4
$ npm --version
6.2.0

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

10 participants