Skip to content

Instantly share code, notes, and snippets.

@jaibeee
Last active February 15, 2024 22:49
Show Gist options
  • Save jaibeee/9a4ea6aa9d428bc77925 to your computer and use it in GitHub Desktop.
Save jaibeee/9a4ea6aa9d428bc77925 to your computer and use it in GitHub Desktop.
Configure homebrew permissions to allow multiple users on MAC OSX. Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
#!/bin/sh
# Configure homebrew permissions to allow multiple users on MAC OSX.
# Any user from the admin group will be able to manage the homebrew and cask installation on the machine.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew
# if you are using cask then allow admins to manager cask install too
chgrp -R admin /opt/homebrew-cask
chmod -R g+w /opt/homebrew-cask
@AlJohri
Copy link

AlJohri commented May 13, 2018

Down the line, I also needed to run:

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

maybe the permissions keep resetting themselves somehow? unsure. I was unable to run brew update because permission was denied to the .git directory until I ran the above command.

@AlJohri
Copy link

AlJohri commented May 13, 2018

Another one. I needed to do the same for /usr/local/etc:

$ brew upgrade imagemagick                                             
==> Upgrading 1 outdated package, with result:
imagemagick 7.0.7-30 -> 7.0.7-31
==> Upgrading imagemagick
Error: Permission denied @ unlink_internal - /usr/local/etc/ImageMagick-7/coder.xml

@coderxx
Copy link

coderxx commented Jul 22, 2018

Can't we just create a separate group like brew users or the like and add all users to this. Then change the ownership of these folders to that group?

@simplenotezy
Copy link

@coderxx this is exactly what I've done. Great thinking 🤓

@danstreeter
Copy link

Worked great, thanks.

@alexcroox
Copy link

This worked perfectly for me with multiple users on the same machine

https://medium.com/@leifhanack/homebrew-multi-user-setup-e10cb5849d59

@degrootestad
Copy link

In MacOS High Sierra you can't change the owner, group or permissions of /usr/local so you have to use /usr/local/*. You might want to update the script to reflect this.

Tnx, very 'insightful'

@Blackjacx
Copy link

All of this doesn't work on macOS BigSur. Only the user who installed all the Homebrew stuff is able to upgrade them afterwards. For all the other users the system complains with Operation not permitted since th folder belongs to the other user. It seems like Homebrew does not respect the groups write permission and only looks for the user... :(

@cafca
Copy link

cafca commented Aug 30, 2021

@Blackjacx I am on Big Sur and this is mostly working for me, but I have to reset permissions every now and then after upgrading.

@ylluminate
Copy link

It seems that this method might be better, any reason it may be less desirable?:
https://unix.stackexchange.com/a/714797/47012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment