Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@jmbldwn

This comment has been minimized.

Copy link

jmbldwn commented Dec 11, 2016

Curious, why do we need all of /usr/local to be admin, vs. just /usr/local/Cellar?

@mhariri

This comment has been minimized.

Copy link

mhariri commented Jan 25, 2017

some brew applications use other directories under /usr/local, for example mysql that uses /usr/local/var

@miketwo

This comment has been minimized.

Copy link

miketwo commented Apr 27, 2017

Might want to wrap the calls on /Library/Caches with an "if exists" -- mine didn't.

@Weltraumschaf

This comment has been minimized.

Copy link

Weltraumschaf commented Jun 6, 2017

Why is this not the default for brew?

@luanzhu

This comment has been minimized.

Copy link

luanzhu commented Jun 11, 2017

Thank you!

@carande

This comment has been minimized.

Copy link

carande commented Jun 11, 2017

Very useful!

@brianlow

This comment has been minimized.

Copy link

brianlow commented Jul 4, 2017

Changing perms on all of /usr/local breaks postgres (data directory has group of world access)

@jschank

This comment has been minimized.

Copy link

jschank commented Aug 12, 2017

I get the following when I attempt to use this:

chgrp: /Library/Caches/Homebrew: No such file or directory
chmod: /Library/Caches/Homebrew: No such file or directory
chgrp: /opt/homebrew-cask: No such file or directory
chmod: /opt/homebrew-cask: No such file or directory

Should the script create these directories, if they don't exist, so that they get created with the right permissions, when they get created by homebrew (assuming they get created by homebrew) or will the chgrp do the right thing if the directories get created later?

@ismdcf

This comment has been minimized.

Copy link

ismdcf commented Nov 21, 2017

Thanks was really helpful

@FrancoSabadini

This comment has been minimized.

Copy link

FrancoSabadini commented Dec 3, 2017

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.

@karwalbubble

This comment has been minimized.

Copy link

karwalbubble commented Apr 16, 2018

@FrancoSabadini Thanks, /usr/local/* helped.

@AlJohri

This comment has been minimized.

Copy link

AlJohri commented May 7, 2018

Unsure why the * didn't fully work for me, but I needed to also run this for High Sierra.

chgrp -R admin /usr/local/var
chmod -R g+w /usr/local/var
@AlJohri

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

simplenotezy commented Sep 10, 2018

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

@danstreeter

This comment has been minimized.

Copy link

danstreeter commented Jan 10, 2019

Worked great, thanks.

@alexcroox

This comment has been minimized.

Copy link

alexcroox commented Apr 25, 2019

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.