DEV Community

Charles Loder
Charles Loder

Posted on

Homebrew on a multi-user Mac with a silicon chip

It's not the catchiest title, but hopefully this post will be helpful if you have a specific use case — you have a Mac with a silicon chip, you have two users that are essentially you (i.e. work and personal), and you want homebrew to be accessible on both.

This isn't an unknown situation, see here.

I'll call the two users personal and work throughout this post

install homebrew

The first step is to install homebrew. I installed mine on personal.

If you run echo $PATH, you should see homebrew in your path:



/opt/homebrew/bin:/opt/homebrew/sbin


Enter fullscreen mode Exit fullscreen mode

When you run brew in the terminal, those paths are where homebrew lives, which is different on the Applie silicon chips than older chips.

update other user config

In work, update the .zshrc file by adding this:



export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
alias brew='sudo -Hu personal brew'


Enter fullscreen mode Exit fullscreen mode

The first line simply adds homebrew to your $PATH.

Because this user doesn't have permissions for the brew command, you have to hardcode the values.

The second line simply aliases the brew command to use sudo to run brew from the personal user.

Then restart your shell.

After that, while logged in as work, you can run brew install <PACKAGE>, enter the password for personal, and then the package will be accessible to both users!

This may not be the perfect way to do it, but it worked for me.

Top comments (3)

Collapse
 
charlesloder profile image
Charles Loder

lol so I've already run into issues using brew to install nvm, so maybe nobody listen to me :)

Collapse
 
theonlytruebigmac profile image
Zach Frazier

you could make a brew sec group and leverage brew prefix

sudo chgrp -R brew $(brew --prefix)/*

sudo chmod -R g+w $(brew --prefix)/*

Collapse
 
charlesloder profile image
Charles Loder • Edited

I tried that at one point, but it didn't work because I have no idea what I'm doing