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

Viewed 10403

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!

3 Answers

Run the following commands to grant the privileges:

$ sudo chown -R $(whoami) /usr/local

Once the privileges are granted, now they have to be just linked since it is already installed:

$ brew link autoconf
$ brew link libevent
Related