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.
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/*