Homebrew - repeated “linking” bug. What is the und

2019-05-05 05:42发布

So I've been using homebrew to install various packages/libraries/programs on my mac. I keep running into a problem in which homebrew tells me that I have unlinked kegs in my Cellar.

For instance, upon running brew install phantomjs I received the following message:

Warning: Could not link phantomjs. 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 phantomjs'

Possible conflicting files are:
/usr/local/bin/phantomjs -> /usr/local/lib/node_modules/phantomjs/bin/phantomjs

I tried running brew link phantomjs as recommended, and hit a similar problem:

Error: Could not symlink file: /usr/local/Cellar/phantomjs/1.9.2/bin/phantomjs
Target /usr/local/bin/phantomjs already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

The command brew link --overwrite --dry-run phantomjs gives the following message:

Would remove:
/usr/local/bin/phantomjs -> /usr/local/lib/node_modules/phantomjs/bin/phantomjs

I will probably go ahead and overwrite, but this appears to happen every time I try to install something with homebrew. Why? Why isn't homebrew working as expected?

Thanks.

标签: homebrew
2条回答
欢心
2楼-- · 2019-05-05 06:23

From what I can tell, looks like you have previously done:

% sudo npm install -g phantomjs

In this case, you should do the following:

% sudo npm uninstall -g phantomjs
% brew link --overwrite phantomjs
查看更多
Animai°情兽
3楼-- · 2019-05-05 06:29

I thought I'd take a crack at this. I ran into a similar problem today, and I think it may be related to this:

https://github.com/Homebrew/homebrew/issues/22408

Long story short, I think it has to do with how npm manages packages vs how brew does it. (I'm assuming you installed node with its defaults, which would have given you npm).

At some point you probably installed some package with npm. Maybe grunt, karma, etc..those by default end up in /usr/local/lib/node_modules.

Maybe one of those packages or its dependencies(or sub-dependencies) depended on phantomjs (I think Karma might use phantomjs?) Anyways, if now you are trying to brew install phantomjs, which is trying to make a symlink to it, that may be conflicting with the already existing symlink that npm created for you..

I think you can change the symlink path for that package so that brew permanently points to that already installed package in the node_modules folder. Sorry not to be more specific, I'm just figuring this out myself.

查看更多
登录 后发表回答