1

I have two users on my Mac. Both are me, but one is work mode, the other is non-work mode. I have an ongoing issue with installing via homebrew.

$ brew install x
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
sudo chown -R $(whoami) /usr/local/var/homebrew

Of course, executing this suggested code solves the problem -- until I need to brew install using my other user, then I need to change ownership again. How can I set the permissions so that both users can install with homebrew?

2

I don't know about homebrew in particular, but in theory you could use sudo to install software. Then files are accessed with root privileges, which may or may not be what you want.


In general though, if you want multiple unprivileged users to be able to write to the same location, it isn't the owner of that location that you want to change, but its group. You could create a group called homebrewers:

sudo dscl . -create /Groups/homebrewers

You'll then want to find a group ID that doesn't exist. For this I used:

dscl . -list /Groups                          \
| sed 's@^@/Groups/@'                         \
| ( while read grp;                           \
    do dscl . -read "${grp}" PrimaryGroupID;  \
    done )                                    \
| sort -snk 2

I found that the highest group number in use was 501, so 4200 was available. So, I set the PrimaryGroupID to 4200 and the Password to * (unused). Do not forget to set these! If you do, your groups list will be corrupted and you will likely have to boot into single-user mode to correct it.

sudo dscl . -append /Groups/homebrewers PrimaryGroupID 4200
sudo dscl . -append /Groups/homebrewers Password '*'

Then add your two users to that group. The example here uses shortnames (from whoami) of user1 and user2:

sudo dscl . -append /Groups/homebrewers GroupMembership user1
sudo dscl . -append /Groups/homebrewers GroupMembership user2

Note that you may have to log out and log back in for these changes to take effect.

Finally, you'll want to change the directory's group to be homebrewers and its permissions to be group-writable:

chown -R :homebrewers /usr/local/var/homebrew
chmod -R g+w /usr/local/var/homebrew

If you want, you can even change the owner to root to no ill effects:

sudo chown -R root /usr/local/var/homebrew

All commands shown here were tested on Mac OS X 10.4.11 on a PowerBook G4. Much has changed since the move to Intel, so the commands as shown may not work exactly as given on a newer release. The underlying concepts will remain the same.

  • Congrats on holding on to such a relic of a machine. I noticed that you mentioned 10.4. Were you testing with Tigerbrew? – jsejcksn Jan 5 '18 at 3:50
  • 1
    As I said, I don't know about homebrew, but I do understand UNIX permissions. I use the G4 because I don't like x86 as an architecture, and I use 10.4.11 because I never bought a copy of 10.5. At some point I did obtain an x86 machine, but I still prefer my SPARCs and PPCs. My 68k machines, while still functioning, are less useful than I'd like – Fox Jan 5 '18 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.