Do this once
sudo dseditgroup -o create brewCreate a brew groupsudo dseditgroup -o edit -a USER1 -t user brewAdd first usersudo dseditgroup -o edit -a USER2 -t user brewAdd second user
This might need to be repeated on occasion
brew doctorCheck to see how wrong things aresudo chgrp -R brew $(brew --prefix)/*Change the group of homebrew installation directorysudo chmod -R g+w $(brew --prefix)/*Allow group members to write inside this directorybrew doctorCheck to see how correct things are
If the error below appears when running brew upgrade, change the ownership and permissions with the commands further down
Error: Permission denied @ rb_sysopen - /usr/local/var/homebrew/locks/node@10.formula.lock
sudo chgrp -R brew /usr/local/var/homebrew/*sudo chmod -R g+w /usr/local/var/homebrew/*
If you get these errors
Error: Failure while executing; `cp -pR /var/folders/.../. /usr/local/Cellar/...` exited with 1. Here's the output:
cp: utimes: /usr/local/Cellar/.../.: Operation not permitted
cp: chmod: /usr/local/Cellar/.../.: Operation not permitted
Per this Homebrew Community Discussion maybe the user currently running the Homebrew upgrade procedure has to the owner of all the Homebrew files? Because the brew group and it's membership are no longer sufficient?
sudo chown -R $(whoami):wheel $(brew --prefix)/*
I don't know, but this works.