Jun 13

Currently I’m setting up a new SSD. One of my first installations is homebrew, a must have IMO.

I have two users. Allen the admin and Stan the standard user. Stan is a developer who works most of his time inside our company network. Allen is responsible for installing apps and so on. For security reasons Stan don’t want to be admin. Nevertheless Stan wants to use homebrew, he loves it too. Allen don’t want to have two homebrew installations so that he allows Stan to use his homebrew.

Update 2013-05-31: considering /Library/Caches/Homebrew

Setup

  1. Create a group brew and add Stan
  2. brew doctor (Allen checks if he installed brew correctly)
  3. sudo chgrp -R brew /usr/local (Change the group of homebrew installation directory)
  4. sudo chmod -R g+w /usr/local (Allow group members to write inside this directory)
  5. sudo chgrp -R brew /Library/Caches/Homebrew (Change the group of homebrew cache directory)
  6. sudo chmod -R g+w /Library/Caches/Homebrew (Allow group members to write inside this directory)
  7. brew doctor (Stan checks if he can use homebrew)
  8. We are done!

Detailed Setup

Create a group brew and add Stan
One way to create a group brew is to open the System Preferences and select Users & Groups. Unlock this screen and press the lower left +. Select the account type Group and name it brew. After creating this group add Allen and Stan.

Allen checks if he installed brew correctly

allen$ brew doctor
Your system is raring to brew.

Change the group of homebrew installation directory

allen$ sudo chgrp -R brew /usr/local
Password:
allen$ ls -la /usr/local
total 16
drwxrwxr-x 8 root brew 272 Jun 12 22:31 .
drwxr-xr-x@ 13 root wheel 442 Jun 12 22:36 ..
-rw-r--r-- 1 admin brew 159 Jun 12 22:28 .gitignore
drwxr-xr-x 2 admin brew 68 Jun 12 22:33 Cellar
drwxr-xr-x 6 admin brew 204 Jun 12 22:28 Library
-rw-r--r-- 1 admin brew 789 Jun 12 22:28 README.md
drwxr-xr-x 3 admin brew 102 Jun 12 22:28 bin
drwxr-xr-x 3 admin brew 102 Jun 12 22:28 share

Allow group members to write inside this directory

allen$ sudo chmod -R g+w /usr/local
allen$ ls -la /usr/local
total 16
drwxrwxr-x 8 root brew 272 Jun 12 22:31 .
drwxr-xr-x@ 13 root wheel 442 Jun 12 22:36 ..
-rw-rw-r-- 1 admin brew 159 Jun 12 22:28 .gitignore
drwxrwxr-x 2 admin brew 68 Jun 12 22:33 Cellar
drwxrwxr-x 6 admin brew 204 Jun 12 22:28 Library
-rw-rw-r-- 1 admin brew 789 Jun 12 22:28 README.md
drwxrwxr-x 3 admin brew 102 Jun 12 22:28 bin
drwxrwxr-x 3 admin brew 102 Jun 12 22:28 share

Change the homebrew cache directory accordingly

sudo chgrp -R brew /Library/Caches/Homebrew
sudo chmod -R g+w /Library/Caches/Homebrew

Stan checks if he can use homebrew
In my case Allen and Stan is one person, so that a simple login do the trick.

allen$ login stan
Password:
stan$ brew doctor
Your system is raring to brew.

13 Responses to “My Homebrew Multi User Setup”

  1. Robert says:

    Thanks for posting your instructions, it worked perfectly. I have the same setup: admin account to install apps, and a regular user account for using.

  2. jimothy says:

    I also had to run:

    chgrp -R brew /Library/Caches/Homebrew
    chmod -R g+w /Library/Caches/Homebrew

    ‘brew install ruby’, at a minimum, would not work without this.

  3. Craig McDaniel says:

    I think I found another one. Added group read to this .gitignore file:

    chmod g+r /usr/local/Library/Formula/.gitignore

  4. This approach is cool, but breaks launchctl:

    $ launchctl load -w homebrew.mxcl.redis.plist
    launchctl: Dubious permissions on file (skipping): homebrew.mxcl.redis.plist
    nothing found to load

    It seems that launchctl does not like permissions on a linked file being different to those on the original file, or something. I’m not sure if this problem will occur in the situation where this process is performed _before_ installing a package that installs a launchctl command.

  5. asn says:

    Thank you for this great blog post!!

  6. Jon says:

    Thanks this was clear and helpful, I can now brew on both my accounts.

  7. Matt says:

    This was extremely helpful, I wanted the same setup. Glad you documented it , thanks!

  8. Tobias says:

    Will the group permissions on subdirectories created by homebrew have the brew group and write access?

  9. Shane says:

    Awesome!!!

  10. [...] Hanack has blogged a similar solution, where he creates and configures a dedicated user group brew for the [...]

Leave a Reply

preload preload preload