macos - usr - uninstall brew




How to use Homebrew on a Multi-user MacOS Sierra Setup (4)

Hombrew installs packages in /usr/local, there is nothing you can do about that without breaking many of the packages it installs. Add read and write permissions for all users like this:

sudo chmod -R +rw /usr/local

Be aware the since this is a system folder, all users will share the same brew installation. One user can remove packages that others have installed, and so on. So make sure to coordinate to avoid problems.

I have a Mac that is shared between two engineers. Both have separate user accounts. Both need to run brew update and brew install... occasionally.

How do I set this up without getting errors like: /usr/local must be writable!?

Yeah, I could have UserA take over the permissions of /usr/local every time he wants to use brew (and same with UserB), but that seems like a lot of unnecessary trouble.



The best solution is to add a sudoers record to allow unprivileged user 'joe' to execute any 'brew' related command as the administrative user.

Create a file at /etc/sudoers.d/joe with following content:

joe ALL=(administrator) NOPASSWD: /usr/local/bin/brew

Then you can run brew like this:

sudo -Hu administrator brew install <smth>

You can also change the group permissions to admin or another group that both of your users are in:

chgrp -R admin /usr/local
chmod -R g+w /usr/local

Original source: https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925

UPDATE:

In macOS High Sierra you can't change the owner, group or permissions of /usr/local. So you have to change the group and permissions of the subfolders:

chgrp -R admin /usr/local/*
chmod -R g+w /usr/local/*

UPDATE September 2018, High Sierra 10.13.6

  1. Determine the path of the brew prefix, ie. the path that will be used to store files related to working with homebrew
  2. Check that all users on the system who need access to brew are in the admin group
  3. Optional Add a user to the admin group if a user needs access to brew

    Will require access / privileges to use the sudo command

  4. Set the brew prefix path to be recursively owned by the admin group
  5. Set the brew prefix path to be recursively writable by all users who are in the admin group
  6. Verify the permissions of the brew prefix
  7. brew 🍻

echo $(brew --prefix)
echo $(groups $(whoami))
sudo dseditgroup -o edit -a $(whoami) -t user admin
sudo chgrp -R admin $(brew --prefix) 
sudo chmod -R g+rwX $(brew --prefix)
ls -lah $(brew --prefix)




multi-user