38

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 3 '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 5: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 0:44
32

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.

  • 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 3 '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 6 '15 at 19:54
  • 1
    @MichaelWelch The answer was posted before that edit. – DisplayName Oct 7 '15 at 0:08
  • 1
    Sorry @DisplayName I should have looked at the timestamps. – Michael Welch Oct 7 '15 at 1:32
  • 2
    This is the correct answer. See github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/… - 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
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

  • So how to solve this issue? – Rajesh Maurya May 3 '18 at 9:00
  • @RajeshMaurya use the solution by karolus – JannieT May 3 '18 at 11:32
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

  • chown: /usr/local: Operation not permitted – Rajesh Maurya May 3 '18 at 9:01
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/

  • 1
    sudo chown -R $USER /usr/local/ worked for me on the latest macOS – Alex Trott Sep 25 '16 at 10:38
  • chown: /usr/local/: Operation not permitted – Rajesh Maurya May 3 '18 at 9:01
  • add sudo then type in root level password – Brian Spiering May 3 '18 at 15:12
  • Still chown: /usr/local/: Operation not permitted even if I type in the root password. – 2myCharlie Jul 13 '18 at 0:03
0

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

-1

please look at the SIP with :

csrutil status

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

csrutil 
  • 3
    How does this solve the problem stated in the question? – nohillside Oct 9 '15 at 6:30
-1

It worked for me.

sudo chgrp -R admin /usr/local
sudo chmod -R g+w /usr/local
  • Both of these solutions do not work for me. It still shows: chown: /usr/local: Operation not permitted – 2myCharlie Jul 13 '18 at 0:02
-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.

  • 3
    There is no need to disable SIP in order to change ownership below /usr/local. – nohillside Oct 17 '15 at 14:30

protected by nohillside Jul 30 '16 at 15:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.