Use Homebrew to install packages being a Standard user

Merce Bauza
2 min readOct 26, 2018

--

Hombrew installs packages in /usr/local and it is advisable not to change that directory as it might break some dependencies and the packages that are installed, as they are pre-compiled.

Standard users might not have permissions to read and write /usr/local, creating issues when using brew install .

Problem:

Being a Standard user and using brew to install a program

brew install <program>

the following error showed up:

Error message when trying to install a program with brew

Solution:

To avoid the ownership/permission error, make the standard user an admin user.

Firstly, check if the user already belongs to the Admin group. To check this, the following command in the terminal will list all the groups the user belongs to:

dscacheutil -q group | grep -C 3 <username>

If Admin is not in the list of groups, it means that <username> is not part of it yet and it needs to be added.

A user that has Admin permissions could include the user name to the Admin group running the following command:

sudo dscl . -append /Groups/admin GroupMembership <username>

The line above is a command line shortcut of navigating to User Group Preferences > username > enable Allow user to administer this computer.

Although the user is now an Admin, you might still get permission errors as the settings to access the /usr/local folders also need to be amended.

Example of permission issue for a new Admin user when trying to install ruby with brew

To give permissions to the new Admin User to use Hombrew, run the following command:

sudo chown -R $(whoami) $(brew --prefix)/*

Make sure you are in the new Admin User session when running this command.

--

--