This repository has been archived by the owner. It is now read-only.

Cache folders in different drives on Windows causes error "Adding a cache directory to the cache will make to world implode" #4313

Closed
mikeobrien opened this Issue Dec 14, 2013 · 9 comments

Comments

Projects
None yet
5 participants
@mikeobrien

mikeobrien commented Dec 14, 2013

I'm trying to run npm install on my build server before running grunt and I'm getting:

[20:47:18][Step 1/1] Starting: D:\TeamCity\BuildAgent\temp\agentTmp\custom_script8048618093979852786.cmd
[20:47:18][Step 1/1] in directory: D:\TeamCity\BuildAgent\work\d7db8d081cd00b85
[20:47:19][Step 1/1] npm WARN package.json Drachma@0.0.0 No repository field.
[20:47:19][Step 1/1] npm http GET https://registry.npmjs.org/grunt
[20:47:19][Step 1/1] npm http 200 https://registry.npmjs.org/grunt
[20:47:19][Step 1/1] npm http GET https://registry.npmjs.org/grunt/-/grunt-0.4.2.tgz
[20:47:20][Step 1/1] npm http 200 https://registry.npmjs.org/grunt/-/grunt-0.4.2.tgz
[20:47:21][Step 1/1] npm ERR! Error: Adding a cache directory to the cache will make the world implode.
[20:47:21][Step 1/1] npm ERR!     at addLocalDirectory (C:\Program Files\nodejs\node_modules\npm\lib\cache.js:1120:45)
[20:47:21][Step 1/1] npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\cache.js:1173:7
[20:47:21][Step 1/1] npm ERR!     at cb (C:\Program Files\nodejs\node_modules\npm\lib\utils\tar.js:150:7)
[20:47:21][Step 1/1] npm ERR!     at C:\Program Files\nodejs\node_modules\npm\lib\utils\tar.js:147:9
[20:47:21][Step 1/1] npm ERR!     at C:\Program Files\nodejs\node_modules\npm\node_modules\lockfile\lockfile.js:61:41
[20:47:21][Step 1/1] npm ERR!     at Object.oncomplete (fs.js:107:15)
[20:47:21][Step 1/1] npm ERR! If you need help, you may report this *entire* log,
[20:47:21][Step 1/1] npm ERR! including the npm and node versions, at:
[20:47:21][Step 1/1] npm ERR!     <http://github.com/isaacs/npm/issues>
[20:47:21][Step 1/1] 
[20:47:21][Step 1/1] npm ERR! System Windows_NT 6.2.9200
[20:47:21][Step 1/1] npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
[20:47:21][Step 1/1] npm ERR! cwd D:\TeamCity\BuildAgent\work\d7db8d081cd00b85
[20:47:21][Step 1/1] npm ERR! node -v v0.10.23
[20:47:21][Step 1/1] npm ERR! npm -v 1.3.17
[20:47:21][Step 1/1] npm
[20:47:21][Step 1/1] Process exited with code 1

I've narrowed this down to the pathIsInside function. In my case the potentialChild is D:\TeamCity\BuildAgent\temp\... and the parent is C:\...\AppData\Roaming\npm-cache. Because the two paths are on different drives path.relative just returns the to path (e.g. path.relative('d:\\this', 'c:\\that') == c:\that). That does not contain .. so pathIsInside incorrectly returns true and the above exception gets thrown.

Here is a version of pathIsInside that solves this problem and should be cross platform:

function pathIsInside (potentialChild, parent) {
  return (path.resolve(potentialChild) + path.sep).indexOf(path.resolve(parent) + path.sep) === 0;
}

Let me know if I should send a PR or if I'm missing something and there is a better solution.

Thanks!

m

@smikes

This comment has been minimized.

Show comment
Hide comment
@smikes

smikes Dec 14, 2013

Contributor

Same error message, probably same problem, trying to run npm publish on Windows 7

Contributor

smikes commented Dec 14, 2013

Same error message, probably same problem, trying to run npm publish on Windows 7

@mikeobrien

This comment has been minimized.

Show comment
Hide comment
@mikeobrien

mikeobrien Dec 14, 2013

Someone is reporting this same error here: #4128. Not sure if this is related or not.

BTW, you can get around this by setting the cache directory to be on the same drive as your temp directory e.g. call npm config set cache d:\temp\npm-cache if its on D:.

mikeobrien commented Dec 14, 2013

Someone is reporting this same error here: #4128. Not sure if this is related or not.

BTW, you can get around this by setting the cache directory to be on the same drive as your temp directory e.g. call npm config set cache d:\temp\npm-cache if its on D:.

@smikes

This comment has been minimized.

Show comment
Hide comment
@smikes

smikes Dec 14, 2013

Contributor

@mikeobrien That does not resolve the npm publish issue for me, but it makes other things less painful, thanks.

Contributor

smikes commented Dec 14, 2013

@mikeobrien That does not resolve the npm publish issue for me, but it makes other things less painful, thanks.

@HugoHeneault

This comment has been minimized.

Show comment
Hide comment
@HugoHeneault

HugoHeneault Dec 14, 2013

I have this issue, and yes, it's when the cache folder is set to another drive.
I installed npm on c:/ (so cache folder was on c) and have this issue. After moving it to e:/ (where my system cache is), it worked !

HugoHeneault commented Dec 14, 2013

I have this issue, and yes, it's when the cache folder is set to another drive.
I installed npm on c:/ (so cache folder was on c) and have this issue. After moving it to e:/ (where my system cache is), it worked !

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Dec 14, 2013

Member

Hey all, so sorry for introducing this; it's my fault, as part of #4214. I'll try to push a fix ASAP and hopefully release a new npm version with that fix. Sincere apologies.

Member

domenic commented Dec 14, 2013

Hey all, so sorry for introducing this; it's my fault, as part of #4214. I'll try to push a fix ASAP and hopefully release a new npm version with that fix. Sincere apologies.

@mikeobrien

This comment has been minimized.

Show comment
Hide comment
@mikeobrien

mikeobrien Dec 14, 2013

No worries, thanks for handling it!

mikeobrien commented Dec 14, 2013

No worries, thanks for handling it!

@smikes

This comment has been minimized.

Show comment
Hide comment
@smikes

smikes Dec 14, 2013

Contributor

Thanks!

On Dec 14, 2013, at 11:48 AM, mikeobrien notifications@github.com wrote:

No worries, thanks for handling it!


Reply to this email directly or view it on
GitHubhttps://github.com//issues/4313#issuecomment-30583149
.

Contributor

smikes commented Dec 14, 2013

Thanks!

On Dec 14, 2013, at 11:48 AM, mikeobrien notifications@github.com wrote:

No worries, thanks for handling it!


Reply to this email directly or view it on
GitHubhttps://github.com//issues/4313#issuecomment-30583149
.

domenic added a commit that referenced this issue Dec 14, 2013

@domenic domenic closed this in 966373f Dec 16, 2013

@XhmikosR

This comment has been minimized.

Show comment
Hide comment
@XhmikosR

XhmikosR Dec 19, 2013

@domenic: is there any ETA on a new node.js + npm stable version? I hit this issue with node.js 0.10.23 and npm 1.3.17

C:\Users\XhmikosR\Desktop>npm config list
; cli configs
registry = "https://registry.npmjs.org/"

; globalconfig C:\Users\XhmikosR\AppData\Roaming\npm\etc\npmrc
cache = "H:\\progs\\thirdparty\\npm-cache"
prefix = "H:\\progs\\thirdparty\\npm"

; builtin config undefined

; node bin location = H:\progs\thirdparty\nodejs\\node.exe
; cwd = C:\Users\XhmikosR\Desktop
; HOME = C:\Users\XhmikosR
; 'npm config ls -l' to show all defaults.

I purposely have set the directories not to C since that's an SSD drive and I don't want to clutter it at this point.

EDIT: I guess I can try getting npm from http://nodejs.org/dist/npm/ first.

XhmikosR commented Dec 19, 2013

@domenic: is there any ETA on a new node.js + npm stable version? I hit this issue with node.js 0.10.23 and npm 1.3.17

C:\Users\XhmikosR\Desktop>npm config list
; cli configs
registry = "https://registry.npmjs.org/"

; globalconfig C:\Users\XhmikosR\AppData\Roaming\npm\etc\npmrc
cache = "H:\\progs\\thirdparty\\npm-cache"
prefix = "H:\\progs\\thirdparty\\npm"

; builtin config undefined

; node bin location = H:\progs\thirdparty\nodejs\\node.exe
; cwd = C:\Users\XhmikosR\Desktop
; HOME = C:\Users\XhmikosR
; 'npm config ls -l' to show all defaults.

I purposely have set the directories not to C since that's an SSD drive and I don't want to clutter it at this point.

EDIT: I guess I can try getting npm from http://nodejs.org/dist/npm/ first.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Dec 19, 2013

Member

@XhmikosR indeed, you can always upgrade npm independently of node.

Member

domenic commented Dec 19, 2013

@XhmikosR indeed, you can always upgrade npm independently of node.

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