MacOS Multiple User Run Brew Issue

Cli

Error message

1
2
3
4
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
sudo chown -R $(whoami) /usr/local/var/homebrew
Error: Permission denied @ rb_sysopen - /usr/local/var/homebrew/locks/YOUR_PACKAGE.formula.lock

Solution

1
2
sudo chown -R $(whoami) /usr/local/Cellar/
sudo chown -R $(whoami) /usr/local/var/homebrew

Error message 2

1
Error: Permission denied - /usr/local/opt/jpeg

Solution

1
2
sudo chown -R "$USER":admin /usr/local
sudo chown -R "$USER":admin /Library/Caches/Homebrew