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

孤街浪徒 提交于 2019-12-07 04:14:20

问题


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!


回答1:


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.




回答2:


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



回答3:


You may want to change writing permissions with chmod on /usr/local/share/emacs/site-lisp/autotest-mode.elc

After that you should get something like this: Linking /usr/local/Cellar/autoconf/2.69... 21 symlinks created



来源:https://stackoverflow.com/questions/20514084/how-to-fix-brew-doctor-errors-on-mac-osx-10-9-unlinked-kegs-in-cellar-and-hom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!