Apple - How To Make files in `/usr/local` Writable For Homebrew?

This should be solved changing the perms on that directory in the following way:

$ cd /usr/local
$ sudo chown -R <your-username>:<your-group-name> *

If you don't know your group, just type id -g.


You have to use sudo to run the command with elevated priledges, like this:

sudo chown -R `whoami` /usr/local

I was facing this issue yesterday with macOS 10.13.4 and I tried to sudo chgrp -R admin /usr/local or sudo chown -R <your-username>:<your-group-name> /usr/local which get Operation not permitted error even though using sudo

So I tried to just chgrp for Homebrew related folder to admin (My user is in admin group, depends on the user you are running, you might need to change to a different group) and grant admin group write access to those folders using these commands

sudo chgrp -R admin /usr/local/Homebrew/
sudo chmod -R g+w /usr/local/Homebrew/
sudo chgrp -R admin /usr/local/var/homebrew/
sudo chmod -R g+w /usr/local/var/homebrew/

After running these commands, I am able to install a new package without any issue. If you hit any permission issue again try to run the first two commands by replacing the folder name with the one that you are hitting permission issue.

Hope this will help the other users with macOS 10.13.

Note: Even though changing the owner for /usr/local or changing the group of /usr/local and grant the access for you group might work, you should NEVER do that as you are modifying the other unrelated folder as well. Modifying the folder(s) you need is much more secure.