-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Homebrew installed npm can't upgrade itself #22408
Comments
This issue isn't helpful; there's basically no information here for how we'd actually fix this. |
The symlink that Homebrew creates causes a conflict with how npm wants to upgrade itself when an upgrade to npm is availabe: For instance: $ brew install node
.....
$ npm update -g
npm http GET https://registry.npmjs.org/npm
npm http 304 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/1.3.11
npm http 304 https://registry.npmjs.org/npm/1.3.11
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
npm ERR! error rolling back at clobberFail (/usr/local/Cellar/node/0.10.18/lib/node_modules/npm/lib/utils/gently-rm.js:41:12)
npm ERR! error rolling back at next (/usr/local/Cellar/node/0.10.18/lib/node_modules/npm/lib/utils/gently-rm.js:27:14)
npm ERR! error rolling back at /usr/local/Cellar/node/0.10.18/lib/node_modules/npm/lib/utils/gently-rm.js:36:12
npm ERR! error rolling back at Object.oncomplete (fs.js:107:15)
npm ERR! error rolling back [email protected] { [Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm] code: 'EEXIST', path: '/usr/local/bin/npm' }
npm ERR! Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
File exists: /usr/local/bin/npm
Move it away, and try again.
npm ERR! System Darwin 12.5.0
npm ERR! command "/usr/local/Cellar/node/0.10.18/bin/node" "/usr/local/bin/npm" "update" "-g"
npm ERR! cwd /Users/Adam
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! path /usr/local/bin/npm
npm ERR! code EEXIST
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Adam/npm-debug.log
npm ERR! not ok code 0 To fix it, change the formula's symlink to be
instead of
|
This issue is that the way the prepackaged npm is installed by the node build system is fundamentally incompatible with how Homebrew manages its own packages symlinks. |
Ah I see. That makes sense. No simple solution then besides manually changing the symlink. |
@aradabaugh could you help manually change the symlink? Not sure how to proceed. |
@oskarrough Sure. /usr/local/bin/npm should be a symlink to the Cellar version. Remove it and symlink the npm installed npm update: $ rm /usr/local/bin/npm
$ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm |
@aradabaugh Couldn't those lines just be added to the brew formula for node? |
Probably not from Homebrew's perspective. As @jacknagel commented, Homebrew likes to manage everything under the Cellar and npm stores it's updates outside that in /usr/local/lib. I suppose npm is just the exception here. |
I know this is annoying. I want it to just work. But I need to think through potential ramifications before committing to a fix. |
Yeah, I just noticed that by symlinking |
Is there any update on this issue? Thanks. |
How about adding a caveat for aradabaugh's workaround?
|
How about symlinking /usr/local/bin/npm to /usr/local/lib/node_modules/npm/bin/npm-cli.js and make sure homebrews upgrade of node don't upgrades npm (--without-npm)? I believe the composer package only installs composer and lets composer upgrade it self instead of upgrading via homebrew. |
aradabaugh's workaround still resulted in some error messages when I attempted to update. |
Something has changed since I posted my workaround; StevenACoffman's On Thu, Nov 21, 2013 at 6:00 AM, Jan Varwig [email protected]:
|
Yup, I can confirm that homebrew update, and system up to date, this issue still exist and should be open.
|
The proposed workaround has stopped working with the newest node. I'm on OS X 10.9.1 with node 0.10.23. After updating to the newest node I can't do $ rm /usr/local/bin/npm
$ ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm and then do npm ERR! error rolling back Error: Refusing to delete: /usr/local/share/man/man1/npm-README.1 not in /usr/local/lib/node_modules/npm
npm ERR! error rolling back at clobberFail (/usr/local/Cellar/node/0.10.23/lib/node_modules/npm/lib/utils/gently-rm.js:41:12)
npm ERR! error rolling back at next (/usr/local/Cellar/node/0.10.23/lib/node_modules/npm/lib/utils/gently-rm.js:27:14)
npm ERR! error rolling back at /usr/local/Cellar/node/0.10.23/lib/node_modules/npm/lib/utils/gently-rm.js:36:12
npm ERR! error rolling back at Object.oncomplete (fs.js:107:15)
npm ERR! error rolling back [email protected] { [Error: Refusing to delete: /usr/local/share/man/man1/npm-README.1 not in /usr/local/lib/node_modules/npm]
npm ERR! error rolling back code: 'EEXIST',
npm ERR! error rolling back path: '/usr/local/share/man/man1/npm-README.1' }
npm ERR! Refusing to delete: /usr/local/share/man/man1/npm-README.1 not in /usr/local/lib/node_modules/npm
File exists: /usr/local/share/man/man1/npm-README.1
Move it away, and try again. So for now I'm unable to do |
For now I'm using the following script to update all global packages except npm -g list --depth 0 | grep -v "^/" | cut -f2 -d" " | cut -f1 -d@ | grep -v "^npm$" | xargs npm -g update |
Once all files for npm package are symlinks from node module, it can be updated. #!/bin/bash
for man in 1 3 5 7; do
ln -sf /usr/local/lib/node_modules/npm/man/man${man}/* /usr/local/share/man/man${man}
done
ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
npm update npm -g It may be better to do the symlink fix at homebrew formula. |
@chulkilee Thanks for the script, it works. :) |
@chulkilee saved my day. Thanks. |
+1 @chulkilee -- Thanks for the script. Spent ages trying to sort this. |
I'm not sure about others, but the script from @chulkilee broke my install. I kept getting |
I've just run into this issue myself. It baffles that this issue was closed to due there not being any information on how to fix this issue, @MikeMcQuaid. Isn't it sufficient to describe symptoms and steps to reproduce when opening an issue? Please fix this, if possible. |
As @jacknagel said already:
The above needs to be fixed by upstream or someone knowledgable enough to make a pull request. |
To provide a little more detail, the way npm determines what files belong to a package and resolves symlinks seems to get confused by the symlink Homebrew makes from |
I second @janv’s suggestion of just using nvm – which you can, in turn, install via homebrew.
and you’re done. |
@jarrodldavis I restorted to:
alias brewuu='brew update && {brew upgrade node --without-npm; brew upgrade}' In this way, node doesn't update npm with itself so it doesn't cause these conflicts. When I want to update npm, I just do |
I definitely support @moeffju suggestion, handling package managers with package managers has always been tricky, |
@chulkilee thanks! |
Just to close off this issue, as of 02 April 2014 npm is now installed using a tarball so it is installed by Homebrew when installing Node.js but it is free to manage and upgrade itself. None of the above workarounds should be necessary. You just need |
Closes #34413. Signed-off-by: Mike McQuaid <[email protected]>
thanks @chulkilee this worked for me too #22408 (comment) |
Here's the issue on
npm
https://github.com/isaacs/npm/issues/3794This should be fixed in the way Homebrew handles
npm
The text was updated successfully, but these errors were encountered: