Can't update Homebrew because of permissions issue in Terminal

When I go into Terminal and I want to update my Homebrew version I cd into / and from there I key in

brew update


It returns this error

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


When I type whoami it returns:

GraphicDesign 

Which is basically my Account Name on my Mac


and I don't know how I can set the /usr/local folder to it's correct permissions so that I can simply upgrade/update my homebrew version. I thought I'd had to do a

chmod a+w /usr/local

or

chown admin:GraphicDesign /usr/local


But I am not sure. I messed up yesterday and was able to fix it back but this time I'd thought I'd reach out to y'all.


Ta very much!

MacBook Pro 13", macOS 10.13

Posted on Mar 7, 2019 9:00 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 8, 2019 4:43 AM

My current implementation of homebrew works fine on High Sierra and Mojave 10.14.3.


Once you have it reinstalled, you need to tweak permissions on the folders within /usr/local which is owned by root:wheel.


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


This will set everything inside of /usr/local to your username and the group admin. This should be sufficient for normal operation of homebrew. However, if you do not want homebrew talking to Google Analytics, you need to gag that default with the following in your ~/.bash_profile:


export HOMEBREW_NO_ANALYTICS=1


Purposeful use of uppercase.


Regularly, I will follow this ordered workflow with brew:


brew update

brew upgrade

brew cleanup (if any prior installed packages upgraded)


That cleanup command will remove prior package version installations, and help keep storage freed up.


There is no need to use sudo, or switch directory to root when running brew.

Similar questions

11 replies
Question marked as Top-ranking reply

Mar 8, 2019 4:43 AM in response to BassPlaya

My current implementation of homebrew works fine on High Sierra and Mojave 10.14.3.


Once you have it reinstalled, you need to tweak permissions on the folders within /usr/local which is owned by root:wheel.


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


This will set everything inside of /usr/local to your username and the group admin. This should be sufficient for normal operation of homebrew. However, if you do not want homebrew talking to Google Analytics, you need to gag that default with the following in your ~/.bash_profile:


export HOMEBREW_NO_ANALYTICS=1


Purposeful use of uppercase.


Regularly, I will follow this ordered workflow with brew:


brew update

brew upgrade

brew cleanup (if any prior installed packages upgraded)


That cleanup command will remove prior package version installations, and help keep storage freed up.


There is no need to use sudo, or switch directory to root when running brew.

Mar 7, 2019 10:22 PM in response to BassPlaya

Brute-force... First, make a complete backup of your entirely macOS environment. Then...


Remove Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"


Re-install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


The older Homebrew versions didn't (don't) do well on High Sierra and Mojave, due to tightened security.


There are various previous Homebrew discussions around the 'net, though with no clear answers over in the Homebrew forums and FAQ, unfortunately.


Mar 8, 2019 7:33 AM in response to VikingOSX

I've been running with the following settings on /usr/local on High Sierra for quite some time, and Homebrew works just fine:


$ ls -aled /usr/local

drwxr-xr-x  21 root  wheel  714 May  2  2018 /usr/local


Changing ownership on the /usr/local directory shouldn't be necessary for Homebrew, and that change may well head toward "fun" on upgrades and quite possibly on a multi-user system.


More generally, I'd recommend against changing the ownership of a system-wide directory. Add an ACL if you really need that write access.


There's a hole in the Homebrew docs and FAQ around that particular error, and I'd suggest asking the Homebrew folks about the error directly. There have been many approaches suggested around the 'net for this and related, and some of the suggestions look stale, some look entirely problematic, and some may well hose the whole of /usr/local and which isn't restricted to Homebrew. Other apps and tools can and do use that same path.


Remove and reinstall gets you the latest bits, too.

Mar 8, 2019 7:43 PM in response to BassPlaya

Back up your environment. All of it. Use Time Machine, Disk Utility, or some other locally-preferred backup tool.


Remove Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"


Re-install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


The ACL in this context is an Access Control List, and which can be a way of granting file snd directory access and without changing ownership, among other uses. Probably not necessary here, too.

Mar 8, 2019 9:48 AM in response to MrHoffman

As it turns out, my /usr/local permissions and ownership match what you have shown, and I certain agree with not changing the permissons on /usr/local itself — not what I erringly posted earlier, or what homebrew recommends. Within /usr/local, the folders are uid:admin, and right or wrong, this works smoothly for homebrew, or other packages that I have installed in /usr/local.

Mar 8, 2019 6:20 PM in response to VikingOSX

Thanks for this however, I believe that the problem is that I have certain applications that have been installed by Homebrew in the past that are fully located (unsure of that actually) somewhere in the /usr/local/ folder and I think the remove script you’re linking to says that it will remove all the files in library. (not sure if it was the “library” or the “lib” folders). I can’t do a full back up right now and so going about with your solution, that might actually work, is going to be tricky for me. I think I need me to find out which applications have been installed by Homebrew in the past, where they have been installed and if I have to reinstall all these again, and if so, that’s going to set me back. I don’t have time for that. I just need to be able to install “simpLess. I do appreciate your reply.

Mar 8, 2019 6:26 PM in response to MrHoffman

I tried your ls command and it gave me back this:

drwxr-xr-x  34 root  wheel  1088 Mar  7 14:05 /usr/local

I don't know what an ACL is (other than a ligament 😂 ) but maybe my returned message from Terminal might help you to help me. I also understand that there isn't actual documented on Homebrew doc pages, and I agree to ask there as well. What did you exactly mean with "hose the whole of /usr/local"?

Mar 8, 2019 6:28 PM in response to MrHoffman

Thanks for this however, I believe that the problem is that I have certain applications that have been installed by Homebrew in the past that are fully located (unsure of that actually) somewhere in the /usr/local/ folder and I think the remove script you’re linking to says that it will remove all the files in library. (not sure if it was the “library” or the “lib” folders). I can’t do a full back up right now and so going about with your solution, that might actually work, is going to be tricky for me. I think I need me to find out which applications have been installed by Homebrew in the past, where they have been installed and if I have to reinstall all these again, and if so, that’s going to set me back. I don’t have time for that. I just need to be able to install “simpLess. I do appreciate your reply.

Mar 8, 2019 6:42 PM in response to MrHoffman

@MrHoffman

I tried your ls command and it gave me back this:

drwxr-xr-x  34 root  wheel  1088 Mar  7 14:05 /usr/local


I don't know what an ACL is (other than a ligament 😂 ) but maybe my returned message from Terminal might help you to help me. I also understand that there isn't actual documented on Homebrew doc pages, and I agree to ask there as well. What did you exactly mean with "hose the whole of /usr/local"?

Mar 8, 2019 7:37 PM in response to BassPlaya

The permissions for the /usr/local directory are what MrHoffman has shown. Mine are the same. Do not change this.


My recommendation, and that of the hombrew developer, is wrong for the sudo chown -R $(whoami):admin /usr/local command. This would change the user and group of the /usr/local directory itself, instead of just the folders within it.


You would do the following:

  • Change directory into /usr/local
    • cd /usr/local
  • Now, recursively change the folders (and their content) within /usr/local
    • sudo chown -R $(whoami):admin
  • Return to your home directory by typing cd and return
    • cd


Once that is behind you, just type the following (in order) to let homebrew do some of its housekeeping, and upgrade itself to the latest version, as well as any packages that you have previously installed. You should not need to uninstall, and then reinstall it homebrew — unless it is royally screwed up.


brew update

brew upgrade


You can see a tree diagram of all installed packages and their dependencies:


brew deps --tree --installed

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't update Homebrew because of permissions issue in Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.