Homebrew Permissions for Watchman on Multi-user Mac
Asked Answered
L

1

14

I have two users on my Macbook Pro running macOS Mojave 10.14.2 - one for work and one for personal.

I set up React Native on both users installing the react native cli & watchman:

brew install watchman

sudo npm install -g react-native-cli

This worked and I was able to run the local server with npm start.

I tried doing the same on the other user but was not able to install watchman with homebrew due to permissions issues.

I ran the following:

sudo chown -R $(whoami):admin $(brew --prefix)/*

And that fixed it. I was once again able to run the local dev server.


Except now when I went back to my other user, I was not able to run the server again.

I get the following error when running npm start:

Loading dependency graph...libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: open: /usr/local/var/run/watchman/yev-state: Permission denied

Watchman: watchman --no-pretty get-sockname returned with exit code=null, signal=SIGABRT, stderr= libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: open: /usr/local/var/run/watchman/yev-state: Permission denied

I tried running sudo chown -R $(whoami):admin $(brew --prefix)/* again which didn't fix it this time.

I also looked up how to configure Homebrew for multi-users macs and found this short article.

I created a user group called "brew", added both my work and personal users to it and ran the following:

sudo chgrp -R brew $(brew --prefix)/*

sudo chmod -R g+w $(brew --prefix)/*

Still no dice.

I am not able to get it where I can freely user homebrew or run the dev server (due to watchman permissions error) on both users. I have to "fix" the permissions issue every time I change users.

Labradorite answered 3/5, 2019 at 23:43 Comment(0)
P
60

The /usr/local/var/run/watchman directory needs to have permissions 2777 so that any user can create their own state directory inside:

sudo chmod 2777 /usr/local/var/run/watchman

In addition, watchman performs some sanity checks to see if the state directory looks like it might have compromising permissions; I suspect that your very broad recursive chmod and chown calls are triggering that, so I'd recommend this as a very safe albeit disruptive thing to do assuming that other users have a working watchman:

sudo rm -rf /usr/local/var/run/watchman/*

Edit: (see Alan's answering comment below)

On an M* Mac, homebrew doesn't place things in /usr/local, it puts them in /opt/homebrew. So the correct commands for an M1/2/3 Mac are:

sudo chmod 2777 /opt/homebrew/var/run/watchman

and

sudo rm -rf /opt/homebrew/var/run/watchman/*
Pigheaded answered 4/5, 2019 at 0:26 Comment(6)
this did it! thank you for your help and explanation – Labradorite
You saved my life. I'd been stuck per days haha – Roxanaroxane
Save my day too. I updated mongodb with brew but it also updated watchman... After a computer restart the new version was malfunctioning and producing this issue – Recycle
Thank you πŸ™ Now It's working πŸ‘ – Urbannal
I get no such file or directory for the first command – Henpeck
The above paths didn't exist for me, but this fixed it: sudo chmod 2777 /opt/homebrew/var/run/watchman/ && sudo rm -rf /opt/homebrew/var/run/watchman/* – Baranowski

© 2022 - 2024 β€” McMap. All rights reserved.