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.
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
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.
Related
When I installed 7zip via home brew (Formula sevenzip), i noticed that i cannot run it via sevenzip and even brew info sevenzip did not tell me the name of the binary.
Only after looking in the script file on Github I noticed a command 7zz but there must be an easier way to find out the binaries or commands associated with a homebrew package.
The simplest I know is:
brew ls PACKAGE
and you can normally see it pretty quickly. Personally, I use p7zip as PACKAGE.
Alternatively, as brew --prefix tells you where binaries are installed (via symlinks), you can find the newest installed binary with:
ls -lrt $(brew --prefix)/bin
and it's the last one listed.
I am not sure how badly I have hosed this. I updated dbt to v20 globally too soon. I did uninstall v20. I need to return the project to version 19.1. I am running into errors doing this. As background I am running a virtual. I am on macos.
These two commands work as expected:
brew tap dbt-labs/dbt
brew unlink dbt
Then I run brew install dbt-labs/dbt/dbt#0.19.1
I get (I expect this) Warning: dbt-labs/dbt/dbt#0.19.1 0.19.1_1 is already installed, it's just not linked. To link this version, run: brew link dbt#0.19.1
Then I run brew link dbt#0.19.1 or brew link dbt-labs/dbt/dbt#0.19.1 and I get:
Error: Formulae found in multiple taps:
* dbt-labs/dbt/dbt#0.12.2-rc1
* fishtown-analytics/dbt/dbt#0.12.2-rc1
Please use the fully-qualified name (e.g. dbt-labs/dbt/dbt#0.12.2-rc1) to refer to the formula.
So I try brew link dbt-labs/dbt/dbt#0.12.2-rc1
Disclosure...I code dbt modules but I do not get too far into the installation since I rarely need to do it. Any help would be highly appreciated.
You might find this issue in the dbt-labs/dbt repo helpful.
TL;DR:
You may be running into issues due to the repo name change. It could help to do a full re-install, i.e.:
brew untap fishtown-analytics/dbt --force
brew tap dbt-labs/dbt
brew install dbt#x.y.z
You can then follow the instructions here as normal for managing several versions with homebrew.
Please help understand what is going on--or whether any action is required. I've gone through a lot of posts on dealing with brew, node, symlink, uninstalled and reinstalled node, npm, yarn, tried brew cleanup. When brew doctor produced these warnings--
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/lib/node_modules/npm/node_modules/.bin/JSONStream
/usr/local/lib/node_modules/npm/node_modules/.bin/errno
/usr/local/lib/node_modules/npm/node_modules/.bin/is-ci
/usr/local/lib/node_modules/npm/node_modules/.bin/node-gyp
/usr/local/lib/node_modules/npm/node_modules/.bin/opener
/usr/local/lib/node_modules/npm/node_modules/.bin/qrcode-terminal
/usr/local/lib/node_modules/npm/node_modules/.bin/rc
/usr/local/lib/node_modules/npm/node_modules/.bin/semver
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-conv
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-sign
/usr/local/lib/node_modules/npm/node_modules/.bin/sshpk-verify
/usr/local/lib/node_modules/npm/node_modules/.bin/uuid
/usr/local/lib/node_modules/npm/node_modules/.bin/which
When I tried brew prune, I got:
newmbp$ brew link node
Warning: Already linked: /usr/local/Cellar/node/10.11.0
I noticed the files (to be linked or unlinked) are in separate folders, but have been struggling to understand the implications of having files in /usr/local/Cellar vs in /usr/local/lib
The precipitating factor that led to all of this was the fan on my laptop runs furiously from time to time, often while MAMP is running.
brew cleanup --prune-prefix (ex- brew prune) removed the broken symlinks, so the issue should be gone.
The fact that brew link node complains has nothing to do with this; it’s a completely different command. It’s not even an error, just a warning: "you asked me to link node but it’s already linked" so everything’s fine here.
Homebrew installs its files in /usr/local/Cellar. On the other hand, /usr/local/lib is a shared directory commonly used for libraries. In order for software to find libs Homebrew installed, it symlinks them in it.
For example, let’s say you have a formula foo version 1.2.3 that installs a library bar. After running brew install foo you should get something like this:
# the library files
/usr/local/Cellar/foo/1.2.3/lib/bar
# a symlink to the library files from /usr/local/lib
/usr/local/lib/bar -> /usr/local/Cellar/foo/1.2.3/lib/bar
If you brew uninstall foo, it removes both the library files and the symlink.
Those Homebrew symlinks can be manipulated with brew unlink <formula> (remove them) and brew link <formula> (add them). brew install runs brew link for you so you don’t need to. This is the reason why you get a warning: your Node symlinks already exist.
brew doctor performs various checks, including check_for_broken_symlinks. This one looks into directories such as /usr/local/var or /usr/local/lib for broken symlinks. A broken symlink is a symlink whose target doesn’t exist, often because it has been removed.
The important point to understand here is that Homebrew looks at all symlinks, not just the ones it created. Broken symlinks may cause issues, which is why Homebrew warns you about them, but if everything’s working fine for you feel free to ignore the warning.
After installing and uninstalling some programs through brew and brew cask, now I get brew doctor saying "unlinked kegs in your Cellar".
It suggests to link them, to avoid build trouble with later brews, but instead I'd rather delete them, as they're leftovers from brew programs or formulas that I don't use anymore.
How or where do I remove these? (I don't even know what a keg, or the Cellar, is)
Run:
brew remove packageName
for each unlinked package.
2018 Update
$ brew link --help
If --overwrite is passed, Homebrew will delete files which already exist
in the prefix while linking.
$ brew link --overwrite [package]
$ brew doctor
running brew link will bring up optional commands that you can use, along with that you'll need an argument to go with it or it'll prompt you with an error saying just that.
so I would suggest running:
brew doctor
This will give you the:
'Warning: You have unlinked kegs in your Cellar...'
message
underneath this message it will prompt which kegs are there with the potential problem.
My personal warning was:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
mongodb
brew link
read your options, so you understand what is happening with this command.
brew link --dry-run <yourArgument>
Homebrew will list all files which would be linked or which would be deleted by brew link --overwrite, but will not actually link or delete any files.
brew link --overwrite <yourArgument>
This will execute what the dry-run did, for real this time.
My experience with this was:
cli cmnd:brew link --overwrite mongodb
cli response: Linking /usr/local/Cellar/mongodb/3.2.7... 0 symlinks created
brew doctor
Finally I ran this command and my response no longer had issues.
cli response: Your system is ready to brew.
I figure it will either make the link or if there is none to be had it will just delete the file; which was a previous solution above (this just seems to follow the brew cli prompts vs. just "smashing" the issue with a hammer).
I hope this helps you!
don't cry over spilt code, keep supporting the community.
After installing homebrew on Mac I had the following error:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
libtool
libksba
libyaml
libgpg-error
After running brew link libtool I would get the following error:
$ brew link libtool
Linking /usr/local/Cellar/libtool/2.4.6_1...
Error: Could not symlink include/libltdl
/usr/local/include is not writable.
But as it turned out I didn't have a folder /usr/local/include at all.
So I created it. And then changed the owner and group of the new folder to match the other folders in /usr/local. The next error was the same for /usr/local/lib, so I followed the same process.
After creating those two folders, brew link [package] worked.
brew 1.9.0
brew cleanup [options] [formula|cask]
Remove stale lock files and outdated downloads for all formulae and casks, and
remove old versions of installed formulae. If arguments are specified, only do
this for the given formulae and casks.
--prune Remove all cache files older than specified
days.
-n, --dry-run Show what would be removed, but do not
actually remove anything.
-s Scrub the cache, including downloads for
even the latest versions. Note downloads
for any installed formula or cask will
still not be deleted. If you want to delete
those too: rm -rf "$(brew --cache)"
--prune-prefix Only prune the symlinks and directories
from the prefix and remove no other files.
-v, --verbose Make some output more verbose.
-d, --debug Display any debugging information.
-h, --help Show this message.
Older versions
brew prune [--dry-run]:
Remove dead symlinks from the Homebrew prefix. This is generally not
needed, but can be useful when doing DIY installations. Also remove broken
app symlinks from /Applications and ~/Applications that were previously
created by brew linkapps.
If --dry-run or -n is passed, show what would be removed, but do not
actually remove anything.
rm /usr/local/Library/Taps/josegonzalez
-or if you are frightened-
mv /usr/local/Library/Taps/josegonzalez /usr/local/Library
Alike for other conflicting, but unlinked kegs/taps.
You can also use the provided info from the console and link them again:
Run `brew link`
Do this for each item listed, and everything should be fixed soon.
How can I prevent the following warning from Homebrew appearing whenever I install something?
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Note that I've never (that I recall) installed Fink on this machine and I just uninstalled Macports. I've tried removing /opt/local/bin from my PATH to no avail.
Did you follow the official guide? (specially the "rm" part)
Looking at the source (in def macports_or_fink_installed?), it seems to check something like this:
$ which port
$ which fink
$ ls /sw/bin/fink /opt/local/bin/port # if they exist
$ ls -ld /sw /opt/local # if either directory exists it must be readable
It's a dirty hack but if you just want to silence the warning you can comment out the relevant parts of check_macports in $(brew --prefix)/Library/Homebrew/cmd/install.rb.