6

On my mac OSX Yosemite.

when I do a brew update

error: unable to unlink old 'bin/brew' (Permission denied)
error: unable to unlink old 'share/man/man1/brew.1' (Permission denied)

OK. So I do a sudo brew update

MacBook-Pro:bin$ sudo brew update
Password:
Error: Cowardly refusing to `sudo brew update`
You can use brew with sudo, but only if the brew executable is owned by root.
However, this is both not recommended and completely unsupported so do so at
your own risk.

So it doesn't let me run the update in any way.

1
  • Comments for clarifying the question - not guessing the answer : ) I've moved them to chat so we can have that meta conversation elsewhere.
    – bmike
    Commented Nov 20, 2015 at 18:30

2 Answers 2

7

Try this:

sudo chown -R $USER /usr/local; brew update
4
  • 4
    Also do not EVER use brew with sudo again.
    – D_4_ni
    Commented Nov 20, 2015 at 23:09
  • Also works on El Capitan
    – geotheory
    Commented Dec 5, 2015 at 23:11
  • Reading this issue filed on github is a good way to understand why it's designed like this and what is the recommendation by the homebrew guys. Ideally you should have permissions to your \usr\local
    – gideon
    Commented Sep 14, 2016 at 18:19
  • So with homebrew, there are apparently two options: (a) chown the brew executable to root, which means that any script it runs could be dangerous, or (b) chown all of /usr/local to yourself, which means that you could be dangerous. Like Windows: Always run as Administrator. Or chown /usr/local to me, then back to root. Except that there are some things under /usr/local that I want to own. Urgh. (The reason that I don't have everything owned by me is so that I can't f it up by accident. Learned the hard way years ago when I cated a text file in the hard drive's MBR as root.)
    – Mars
    Commented Apr 18, 2017 at 22:37
3

The homebrew has a doctor command to help with documenting any internal errors. I would start there rather than guessing what is happening.

brew doctor

Next, you could re-install the latest brew over the top of what you have if you can't get a reliable output from the doctor. It won't replace anything you downloaded from brew already - it will just get you a stable install package and the ability to take the next step (perhaps). Usually what happens is some other program or package thinks it needs to change all the permissions and ownership in /usr/local and that harms the assumptions that the brew tool makes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .