14

I installed homebrew using my other user account (which I use during work), but it is impossible to install software from my newly created personal account:

$ brew install unrar
Error: Cannot write to /usr/local/Cellar

A ls -dl /usr/local/Cellar/ shows that the directory is owned by my other user account.

How do I configure homebrew to allow multiple users to install software?

1
  • You can take control from the other user by doing sudo chown -R $(whoami) /usr/local Commented Aug 20, 2018 at 22:14

3 Answers 3

13

set umaskfor each user first. (.basrc or .profile or .bash_profile)

umask 0002 # group write permission

then give write permission for groups via /usr/local recursively:

sudo chmod -R g+w /usr/local/

then change the owner to staff

sudo chgrp -R staff /usr/local

now, each user, who is in staff group can use brew install and other brew related operations... Mostly every user is in that group.

2
  • 1
    I had to do the same for /Library/Caches/Homebrew to make this actually work. And since all my users have Administrator Access enabled I skipped the chgrp
    – Duvrai
    Commented Dec 16, 2014 at 16:50
  • Is it good idea also set setgid bit on directories like /usr/local/Homebrew /usr/local/Cellar and /Library/Caches/Homebrew. This makes all new directories belong to group or does Homebrew has some group it uses. chgrp -R staff /usr/local/Homebrew ... and all 3 dirs etc Commented Mar 9, 2021 at 15:17
3

In case your account has root / su / sudo access, you can try the following workaround:

su - myother_user_account -c "brew install ..."

sudo alternative:

sudo -u myother_user_account brew install ...

A handy shell alias (for .bashrc/.zshrc/...):

alias brew="sudo -u myother_user_account brew"
2
  • 1
    This is not a recommended solution to the multiple-users problem. It requires users to be able to have root access and/or direct access to run commands as another user which kind of defeats the purpose of having user level privileges in the first place. You can break the model for your own use case given you own the box and both accounts, but it would be ill advised for anybody else to use this and your own system usage would be safer for using proper privilege separations.
    – Caleb
    Commented Sep 18, 2015 at 9:46
  • 1
    I don't agree that this is "not recommended". This is a solution that requires the other user to have root / sudo access. And if this does happen in your specific case, I would totally recommend this. I tried other ways of managing Homebrew permissions and it was a nightmare. Never-ending permission denied errors, although I'd swear I did everything as "recommended".
    – cubuspl42
    Commented Nov 18, 2019 at 18:42
1

On the homebrew wiki, it mentions that you can install it anywere, try having local installations for each user.

2
  • I don't want that, actually. I want the software to go to a common place irrespective of who installed it. Commented Jun 22, 2011 at 3:36
  • I've tried this and wish I hadn't as you get messed up user permissions Commented Jul 12, 2011 at 11:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .