How to use Homebrew for MacOS Sierra Multiuser

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

How to configure this without errors: /usr/local must be writable! ?

Yes, I could have UserA accept /usr/local permissions every time it wants to use brew (and the same with UserB ), but that seems like a ton of unnecessary problems.

+32
source share
7 answers

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

 sudo chmod -R +rw /usr/local 

Remember that since this is a system folder, all users will use the same brew installation. One user can remove packages that others have installed, and so on. Therefore, be careful to avoid problems.

+11
source

You can also change the access rights of the group to admin or to another group in which both of your users are located:

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

Source: https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925

UPDATE:

On macOS High Sierra, you cannot change the owner, group, or permissions of /usr/local . Thus, you must change the group and subfolder permissions:

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

UPDATE September 2018, High Sierra 10.13.6

  1. Determine the way the set top box is cooked, i.e. path to be used to store files related to working with homebrew
  2. Make sure that all users of the system who need access to brew are in the administrators group .
  3. Optional Add the user to the administrators group if the user needs access to brew

    Access / privileges required to use sudo command

  4. Set the brew prefix path that will recursively belong to the admin group
  5. Set the brew prefix path to recursively write to all users in the administrators group .
  6. Check brew prefix permissions
  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) 
+61
source

Disclosed solution for macOS Mojave 10.14

This is an edited version of user4815162342 answer that does not work for me out of the box.

  1. In System Preferences, go to the "Users and Amplifiers" section. Groups, click the lock symbol in the lower left corner to unlock the creation of the user / group, then create a new group called brew-usergroup . Add to the group all users who work with brew (as in the screenshot from German macOS).

enter image description here

  1. In the terminal, do this:

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

    Please note that this no longer changes the Brew folder permissions (as in other answers), it changes the subfolders / folder files. Brew brew install should now work without errors.

+7
source

The above works fine, but if you want new files to automatically inherit these permissions, set the ACL that is inherited (otherwise only the user who pours the bottle can delete it). Found tips on how to do this here: https://gist.github.com/nelstrom/4988643

Since root started only once (provided that all users of the admin group must have access):

 cd /usr/local chmod -R +a "group:admin allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,file_inherit,directory_inherit" Homebrew Caskroom Cellar bin chgrp -R admin Homebrew Caskroom Cellar bin chmod -R g+rwX Homebrew Caskroom Cellar bin ls -lae . 

-e on ls shows the ACL.

Update : now I use certain directories (see above), since it failed (something like out of memory)

+5
source

Every answer that tries to crack permissions or sudo is incorrect. Do not use sudo and do not use the same brew installation for user accounts.

The correct answer is to use no more than one "normal" brew installation on the machine, and for all other users to install a local version of brew. You can do this by expanding the tarball into some directory owned by your user and including the bin directory at the beginning of your PATH. Alternatively, you can make a git checkout from two source repositories.

For the git approach you will need homebrew-core and brew .

Arbitrarily choosing my user home directory to check this:

cd $ HOME; git clone git@github.com : Homebrew / homebrew-core.git; git clone git@github.com : homegrown /brew.git

and then change your PATH by choosing our new brew bin directory.

export PATH = $ HOME / brew / bin: $ PATH

Since this is a new installation, you must install all the brew packages you need (again).

+4
source

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

Create a file in /etc/sudoers.d/joe with the following contents:

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

Then you can run Brew like this:

 sudo -Hu administrator brew install <smth> 
+1
source

The above solutions do not work for me. But running the command below worked for me.

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

Source: https://github.com/Homebrew/brew/issues/3228#issuecomment-333858695

-one
source

Source: https://habr.com/ru/post/1014393/


All Articles