1

Homebrew brew doctor is printing many permissions errors, on a system that has multiple users.

Some of the users are fully trusted, and need to be able to run typical brew commands such as brew install and brew update.

Some stackoverflow posts are recommending things like:

  • changing the user via chown
  • changing the group via chgrp
  • changing permissions via chmod

Some posts suggest these:

  • set the user to the current "$USER", or create a user "brew"
  • set the group to the built-in OS X group "admin" or "staff", or create a group "brew"
  • set permissions recursively to group-read and group-write
  • create a custom brew directory, such as "/opt/brew"

Is there a script that "does the right thing", such as by creating any custom user or group as needed, setting the user, setting the group, setting the permissions for directories and files?

Or is there any better way to accomplish the core goal, i.e. how to use brew on a system that has multiple users, and enable some of these users to be able to run all the usual brew commands successfully?

joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
  • 1
    That is why installing as yourself in /usr/local is not a manageable thing - better use a specific user e.g. hombre to install executables – mmmmmm Jan 30 '16 at 20:06
  • 1
    You might try https://www.macports.org/ instead. One of the differences is that macports does (one version of) "the right thing" by default, by performing system-wide installs as root (and by using a "custom" directory `/opt/local`). – ShadSterling Jul 19 '18 at 16:56

1 Answers1

1

My work-in-progress is open source here.

#!/bin/sh
#
# brew-authorize
#
# https://github.com/sixarm/sixarm_brew_scripts/brew-authorize
#
user="$USER"
group="admin"
path=$(brew --prefix)
sudo chown -R "$user" "$path"
sudo chgrp -R "$group" "$path"
sudo find "$path" -type f -exec chmod g+rw {} \;
sudo find "$path" -type d -exec chmod g+rwx {} \;
joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119