2

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: The brew 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_name

To 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.

  1. Why so many symlinks?
  2. 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?

3
  • Did you run 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 and brew gets confused. There are apparently other such files.
    – Dominique
    Jan 30, 2013 at 13:01
  • @Dominique: brew doctor only gives me warnings about having Mono (conflicting pkg-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 =)
    – Joel Purra
    Jan 30, 2013 at 14:03
  • For anyone else experiencing this problem, I think this question may be helpful: Can't brew link an unlinked keg (re: Errors upgrading node/npm)
    – blong
    Feb 26, 2013 at 19:23

1 Answer 1

5

Do you have several versions of Node installed via homebrew? Every time it updates node homebrew puts the newest version alongside the old one and then updates the symlinks to the newest version. Running the brew cleanup should reduce that up a bit for you.

3
  • Didn't know about brew cleanup, thanks! Removed 7 old node versions. Repeating unlink/link still gave the 303/304 cycle though, so it made not difference.
    – Joel Purra
    Sep 30, 2012 at 18:01
  • 1
    Those are probably the rest of the symlinks created by homebrew for other apps. You can also run the command 'brew prune' to remove all of the dead symlinks.
    – rchrdg
    Oct 9, 2012 at 11:27
  • Running brew prune is silent on my machine, so can't be sure what difference it made. I'm down to a 303/303 cycle now though, so it's possible it affected one symlink =)
    – Joel Purra
    Oct 9, 2012 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .