You will first want to create a group that both users are a part. Afterward, we will assign ownership of the Homebrew directories to that group so that both users can share.
sudo chgrp -R brew $(brew --prefix)/*
# If you also have Intel Brew as a backup to the M1, run the following
sudo chgrp -R brew $(intel-brew --prefix)/*
Allow anyone in the "brew" group to the write to the Homebrew directories.
sudo chmod -R g+w $(brew --prefix)/*
sudo chmod -R g+w $(brew --prefix)/.*
# If you also have Intel Brew as a backup to the M1, run the following
sudo chmod -R g+w $(intel-brew --prefix)/*
Test by running brew doctor for both users. Also test by installing a small package for both users. To test you can try:
Run brew install cowsay for one user. Log into the other user and run cowsay Helo. Run brew install figlet for the other user. Log back into the first user and run figlet Helo.
If there are any issues. Run ls -la $(brew --prefix) You'll want to ensure that "brew" is set as the group owner, and "w" is assigned for the group. You want to see something like the following:
-rw-rw-r-- 1 admin brew 159 Jun 12 22:28 .gitignore
drwxrwxr-x 2 admin brew 68 Jun 12 22:33 Cellar
drwxrwxr-x 6 admin brew 204 Jun 12 22:28 Library
^ ^^^^
Group Write Group Owner
If you think this note resonated, be it positive or negative, send me a direct message on Twitter or an email and we can talk.