Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix `brew doctor` errors on Mac OSX 10.9 (unlinked kegs in Cellar and Homebrew sbin not found)?

I'm having some trouble with brew which I'm trying to solve. When I currently run brew doctor I get the following output:

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:

    autoconf
    libevent

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
    echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile

So I went ahead and tried all the suggestions. First brew link autoconf, which results in:

Linking /usr/local/Cellar/autoconf/2.69... Warning: Could not link autoconf. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/autoconf/2.69/share/emacs/site-lisp/autotest-mode.elc
Target /usr/local/share/emacs/site-lisp/autotest-mode.elc already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

So again I tried the suggested command: brew link --overwrite autoconf:

Linking /usr/local/Cellar/autoconf/2.69... Warning: Could not link autoconf. Unlinking...

Error: Permission denied - /usr/local/share/emacs/site-lisp/autotest-mode.elc

My initial response to a permission denied is usually prepending it with sudo, which leads brew to tell me: Error: Cowardly refusing tosudo brew link`.

When trying brew link libevent I get the same results as with brew link autoconf.

Finally, I tried solving the sbin that was not found by running the suggested echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile. This runs without error, but when I run brew doctor again, the message still appears.

Does anybody know how I can solve these issues? All tips are welcome!

like image 204
kramer65 Avatar asked Dec 11 '13 08:12

kramer65


1 Answers

The general problem here is that autoconf and libevent are already installed on your system, and they are in your homebrew "Cellar" as well. Thus there are TWO copies of autoconf on your system, and TWO copies of libevent on your system.

What homebrew is trying to do is delete the previously install (system wide) version of these libraries, and replace all the relevant REAL files with symlinks from the homebrew Cellar. That would give homebrew full control over upgrading and managing these libraries for you. It would also give you just one copy of these libraries available in two places.

The problem is that homebrew doesn't have unix permissions to delete these REAL files, and you'll need to do it yourself. Here's how for autoconf:

$ sudo rm /usr/local/share/emacs/site-lisp/autotest-mode.elc
$ sudo chmod 777 /usr/local/share/emacs/site-lisp/
$ sudo rm -rf /usr/local/share/autoconf
$ brew link --overwrite autoconf

You should see:

Linking /usr/local/Cellar/autoconf/2.69... 21 symlinks created

UPDATE I just noticed the part about sbin. I'm not sure how this problem happened originally, but I can explain how to fix it.

The fix recommended by homebrew (ECHO ...) only takes effect when you next login to your Mac. To have this change take effect now, you have to force your terminal to re-read the .bash_profile file. Just $ source ~/.bash_profile after you run the ECHO command provided by homebrew.

Since this question is a few months old now, you probably already discovered that this error message has gone away.

like image 139
Rustavore Avatar answered Oct 10 '22 07:10

Rustavore