39

I just upgraded to El Capitan, and when I tried updating brew I got the following error:

$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local

Before I proceed with the chown recommendation, given that El Capitan just came out, is that the right way to proceed here? Why is this step necessary, and what are any potential undesirable consequences of running this command?

In case it helps, I found two issues about El Capitan in brew: 40837 and 41665 but a solution to this problem wasn't immediately clear. What can I do to continue to use brew in El Capitan reliably?

  • 2
    Well did you do as the message suggested, change ownership of /usr/local? – user3439894 Oct 03 '15 at 22:32
  • This raises an excellent question for the case of multiple users (or one user with multiple accounts having different profiles) on the same machine. – Walt Stoneburner Dec 20 '15 at 15:23
  • 4
    Typing sudo chown -R gives me the willies. It doesn’t matter what the other parameters are. I have more than Homebrew in /usr/local, and it’s not an obviously-safe command. I confirmed via Time Machine that installing El Capitan chowned, exclusively, /usr/local, and not subdirectories. I was thus able to get away with doing a non-recursive reversion, i.e. sudo chown $(whoami):admin /usr/local. YMMV. – duozmo Jan 11 '16 at 05:02
  • @duozmo is right. The -R in sudo chown -R is really heavy handed. That's tantamount to Brew claiming domain over the entirety of /usr/local – HairOfTheDog Nov 22 '16 at 00:44

8 Answers8

31

I mean they give you the solution right there. I had the same problem and I just ran:

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

and it worked.

DisplayName
  • 2,003
  • 1
    +1 I also needed to reset my user's permissions as described. No further issues after this little tweak - homebrew and my packages have been very reliable on 10.11. – bmike Oct 03 '15 at 22:40
  • 22
    This doesn't really answer the question: One might assume that Apple locked down /usr/local for a reason and that this fix is NOT appropriate for El Capitan. I'm googling now to see if Apple provides some guidance. The question is "... given that El Capitan just came out, is that the right way to proceed here?" – Michael Welch Oct 06 '15 at 19:54
  • 1
    @MichaelWelch The answer was posted before that edit. – DisplayName Oct 07 '15 at 00:08
  • 1
    Sorry @DisplayName I should have looked at the timestamps. – Michael Welch Oct 07 '15 at 01:32
  • 2
    This is the correct answer. See https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md - I ran $ brew doctor and discovered that a flac dependency was missing. After $ brew install flac I had to stubbornly run $ brew update a couple more times. – Ando Oct 13 '15 at 17:30
  • chown: /usr/local: Operation not permitted – Rajesh Maurya May 03 '18 at 08:59
  • With Mac OS High Sierra 10.13, this sudo chown -R $(whoami):admin /usr/local does not work for me. After I re-install using: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew works for me. Source: https://github.com/Homebrew/brew/issues/3285 – 2myCharlie Jul 13 '18 at 00:17
9

We no longer need to break our heads about this. I risked the advice and did the suggested permission change. Then, on updating to the latest homebrew I got this reassuring message:

Homebrew no longer needs to have ownership of /usr/local. If you wish you can return /usr/local to its default ownership with: sudo chown root:wheel /usr/local

JannieT
  • 401
8

Per some of the security questions above, the dialog does give instructions to reset after a successful brew update. After running

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

And then

brew update

After the update has successfully run, the dialog should indicate doing this:

sudo chown root:wheel /usr/local

After that has been run, that should alleviate any security concerns with MacOS 10.12

karolus
  • 502
6

The given solution did not work for me:

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

This variation worked for me:

sudo chown -R $USER /usr/local/

0

I fix it by use this command sudo chown -R admin /usr/local.

nohillside
  • 100,768
Lee Li
  • 9
-1

please look at the SIP with :

csrutil status

the system integrity protection is fixed at "enable", with the last Apple attribute 'restricted":

csrutil 
bigben
  • 1
-1

It worked for me.

sudo chgrp -R admin /usr/local
sudo chmod -R g+w /usr/local
Mahfuz
  • 117
-2

the system integrity protection needs to be disabled. You can do it with this.

sudo nvram boot-args="rootless=0";osascript -e 'tell app "loginwindow" to «event aevtrrst»’

This disables System Integrity Protection system wide. I believe you can also do it from the Recovery Mode. You still have to type in your root password when doing things with sudo, but you aren't locked out by SIP. You also don't then go opening up directories inadvertently trying to set permissions.