You can also change the group permissions to admin or another group that both of your users are in:
chgrp -R admin /usr/local
chmod -R g+w /usr/local
Original source: https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925
UPDATE:
In macOS High Sierra you can’t change the owner, group or permissions of /usr/local. So you have to change the group and permissions of the subfolders:
chgrp -R admin /usr/local/*
chmod -R g+w /usr/local/*
UPDATE September 2018, High Sierra 10.13.6
- Determine the path of the brew prefix, ie. the path that will be used to store files related to working with homebrew
- Check that all users on the system who need access to
breware in the admin group - Optional Add a user to the admin group if a user needs access to brew
Will require access / privileges to use the sudo command
- Set the brew prefix path to be recursively owned by the admin group
- Set the brew prefix path to be recursively writable by all users who are in the admin group
- Verify the permissions of the brew prefix
- brew 🍻
echo $(brew --prefix)
echo $(groups $(whoami))
sudo dseditgroup -o edit -a $(whoami) -t user admin
sudo chgrp -R admin $(brew --prefix)
sudo chmod -R g+rwX $(brew --prefix)
ls -lah $(brew --prefix)