I was upgrading Node.js node
through Homebrew's brew upgrade
, and it didn't link correctly.
$ brew update
(snip-snip formulae were updated)
$ brew upgrade
(snip-snip other upgrades)
==> Upgrading node
==> Downloading http://nodejs.org/dist/v0.8.11/node-v0.8.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.11
==> make install
==> Caveats
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
/usr/local/share/npm/bin
Warning: Could not link node. Unlinking...
Error: Thebrew link
step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
/usr/local/Cellar/node/0.8.11: 856 files, 13M, built in 108 seconds
(snip-snip other upgrades)
I followed the recommended steps to force linking it.
$ brew link node
Linking /usr/local/Cellar/node/0... Warning: Could not link node. Unlinking...Error: Could not symlink file: /usr/local/Cellar/node/0.8.11/lib/node_modules/npm/scripts/relocate.sh
Target /usr/local/lib/node_modules/npm/scripts/relocate.sh already exists. You may need to delete it.
To force the link and delete this file, do:
brew link -f formula_nameTo list all files that would be deleted:
brew link -n formula_name
$ brew link -f node
Linking /usr/local/Cellar/node/0.8.11... 756 symlinks created
I was stunned with the number of symlinks, so out of curiosity I tried linking it again.
$ brew unlink node
Unlinking /usr/local/Cellar/node/0.8.11... 755 links removed
$ brew link node
Linking /usr/local/Cellar/node/0.8.11... 352 symlinks created
$ brew link node
Warning: Already linked: /usr/local/Cellar/node/0.8.11
$ which node
/usr/local/bin/node
$ brew unlink node
Unlinking /usr/local/Cellar/node/0.8.11... 351 links removed
$ brew link node
Linking /usr/local/Cellar/node/0.8.11... 304 symlinks created
$ brew unlink node
Unlinking /usr/local/Cellar/node/0.8.11... 303 links removed
$ brew link node
Linking /usr/local/Cellar/node/0.8.11... 304 symlinks created
$ brew unlink node
Unlinking /usr/local/Cellar/node/0.8.11... 303 links removed
The process stabilizes at 304/303.
- Why so many symlinks?
- Why does the link/unlink number change from 756 to 303?
Edit: ran the same update/upgrade/link/unlink procedure on a colleague's computer - in this case the symlinks went from 775 to 318 to 226, where it stabilized. Does anyone else have similar numbers? Do they depend on other installed brew recipes, or perhaps on npm modules?
brew doctor
? That's the first thing to do in case of problems. The culprit seems to be/usr/local/lib/node_modules/npm/scripts/relocate.sh
. Could it be that you installed a non-Homebrew version of Node? In that case, the file above would have non-Homebrew ownership andbrew
gets confused. There are apparently other such files.brew doctor
only gives me warnings about having Mono (conflictingpkg-config
) installed. Don't think I've had another node installed, but it's possible. My colleague, who had the same problem, may have added manual node compilation to a shared project setup script (he's working in both Ubuntu & Mac) to get the latest version on Ubuntu. Haven't seen this linking warning in a while now, and unlinking/linking node 0.8.18 is stable on 307/307 symlinks =)