"Unlinked kegs in your Cellar". How do I remove them?

38,066

Solution 1

Run: brew remove packageName for each unlinked package.

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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.

Share:
38,066

Related videos on Youtube

RocketNuts
Author by

RocketNuts

Updated on July 09, 2022

Comments

  • RocketNuts
    RocketNuts almost 2 years

    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)

    • Kaje
      Kaje about 9 years
      Have you tried brew cleanup command? Actually Cellar is a directory name where home brew places everything when you install a formula. Full path is /usr/local/Cellar
    • RocketNuts
      RocketNuts about 9 years
      Thanks. Yes, I did brew cleanup, but the unlinked kegs warning still remains. If I look in the Cellar dir, and for example do rm -r pinentry ('pinenty' being one of the unlinked kegs) it asks: override r-xr-xr-x Rocketnuts/admin for pinentry//0.9.4/bin/pinentry-curses? Is that just a readonly-warning or is there anything special with that?
  • frhd
    frhd over 5 years
    This should be higher.
  • Tarek
    Tarek almost 5 years
    Is this a fix or hiding the problem? 🤔
  • Heiner
    Heiner about 4 years
    This answers the question as it will remove the unwanted kegs