So recently I decided it was far easier to have multiple profiles/accounts on my laptop than keeping my personal and work environments mixed. Yes, I am that lazy that I was using the same account and yet going through extra effort to keep things like SSH keys separate and painful to manage.
The problem came when trying to update PowerShell to preview 6 using Homebrew (it’s out by the way and comes with some extra sprinkles of fun to play with); a quick `brew update` showed permission issues.
brew doctor confirmed the same. A quick Google turned up lots of opinions about how to ‘fix’ this. Mainly people just want you to follow the instructions from brew itself and just change the owner to the current user. This is fine, until you log back in with your other account and face the same issues.
Other suggestions involved using
chown still but none actually worked for me on Catalina.
Switch to group permissions
Rather than keep switching the owner to whomever I’m logged in as, or just having one user take care of all
brew update/upgrades, you just have to ‘tweak’ the instructions and grant ownership to the `admin` group.
sudo chgrp -R admin $(brew --prefix) will switch all Brew folders to the admin group. You will get an error trying to update
/usr/local/, this is fine and doesn’t cause issues.
sudo chmod -R g+rwX $(brew --prefix) to update the permissions on the same folders and you’re done.
brew update and
brew upgrade should now work correctly.
Obviously this now means that any admin can use Homebrew but they are admins after all. On a device with only one real user, this is 100% fine by me.