Today I Learned: Homebrew on multi-user systems

Brendan Thompson • 27 July 2021

If you're like me and you've followed the macOS Security and Privacy Guide then you will likely have a standard user account, and an admin account. This is perfect in the majority of cases but what happens if you have a multi-user system? Simply, homebrew dies in the pants on applications that require the use of sudo to install.

A solution to this is to create a homebrew group and add your standard and admin users to it, and then adjust the permissions on the homebrew directories.

  1. Create a group called homebrew:
sudo dscl . create /Groups/homebrew
  1. Add users to the homebrew group:
sudo dscl . /Groups/homebrew GroupMembership <username> <admin_username>
  1. Change the group of the homebrew directories:
sudo chgrp -R homebrew $(brew --prefix)/*
  1. Adjust permissions of the homebrew directories allow the group members to write inside them:
sudo chmod -R g+w $(brew --prefix)/*

To validate that everything is working in the way that we want it to, run the following commands from each user account:

brew doctor

This solution is not perfect, I have had to redo it a few times but it is the most reliable way I have found so far to ensure that homebrew is working correctly.