42

Since updating Watchman recently (with Homebrew) I can no longer use it to watch projects. I get

{
    "version": "2022.05.30.00",
    "error": "std::__1::system_error: open: /Users/Path/To/Project: Operation not permitted"
}

I initially assumed that this must simply be file access issue I could resolve in the normal way, but giving the watchman app access to Files & Folders does not resolve the issue (even with termination of all watchman processes and restart of Terminal).

For good measure, I also manually added the watchman executable to Full Disk Access (something I've never needed to do before and am not comfortable with) but this also had no effect.

I have also terminated every relevant process I can think of, and even rebooted, twice. As far as I know the only change since Watchman worked was my running brew update watchman (which I have of course also uninstalled and reinstalled).

One concern is that for some reason I have multiple entries for watchmen in System Preferences, which weirdly results in it taking several dozen attempts to whack-a-mole all of them into a checked state for access:

enter image description here

How do I give Watchman the permissions needs to overcome this error?

8 Answers 8

92

On my M1 Mac:

My issue was that watchman didn't have permissions to ~/Documents folder. I don't know if this was the case before or after reinstalled it. Here are the steps I took:

brew uninstall watchman
brew install watchman
watchman shutdown-server (just in case it's running)
watchman watch-del-all
yarn start --reset-cache

When I tried to launch metro, MacOS prompted me to give permissions. After accepting, the bundler ran without issue.

6
  • This is different than the original issue, which was a bug in older versions. What you describe is the normal behavior (pretty much).
    – orome
    Commented Oct 12, 2022 at 16:25
  • @orome I answered the author's question about watchman permissions on M1. That's all that is required.
    – Mike S.
    Commented Oct 12, 2022 at 18:29
  • 2
    For me, it's fixed the problem. However, I didn't do the first two steps. Commented Feb 20 at 11:09
  • 2
    watchman watch-del-all prompt me to allow directory access. Maybe it is all we needed.
    – vozaldi
    Commented Feb 28 at 9:42
  • @vozaldi whatever works for you, great! The easier, the better.
    – Mike S.
    Commented Mar 2 at 18:29
44

If the server and client versions don't match up, you should probably restart your server: watchman shutdown-server ; watchman

https://facebook.github.io/watchman/docs/cmd/version.html

1
  • 1
    this was my problem after doing a brew upgrade, just had to shut down a previous instance of watchman and built with no issues
    – Kelvin
    Commented Dec 17, 2023 at 21:54
23

Update Aug-19-2022

It looks like watchman: stable 2022.08.15.00 is working fine on my Mac M1. Upon start, you need to grant access to the local folders about to be synched.


Original

I also had the problem, like many others.

I reverted to a "working" version, e.g. 2022.05.16.00

There are multiple ways to do so; one (without private taps) would be:

  1. Uninstall watchman
  2. Downgrade the watchman.rb formula to an older version
  3. Install watchman according to that version
  4. Pin it (to prevent further watchman updates)
  5. Finally reset the watchman.rb formula to the original state again
# -- 1 -- uninstall
brew uninstall watchman
# -- 2 -- replace formula
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/8651d8e23d308e564414188509f864e40548f514/Formula/watchman.rb > /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb
# -- 3 -- install again, using replaced formula
brew install watchman
# -- 4 -- pin that version - Don't forget to unpin once this problem is solved...
brew pin watchman 
# -- 5 -- reset formula to original
cd /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/
git checkout -- watchman.rb

Then shutdown any lingering instances of Watchman with

watchman shutdown-server

Remark: On Intel-Macs, homebrews repository is located at a different place. You can find out by calling brew --repository. Typically, the Formula is expected in directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula

Once the problems with watchman are solved, you can unpin watchman again and use the normal brew update/upgrade machanism.

13
  • 1
    I get: text /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb: No such file or directory I don't even have an /opt/homebrew/, just an /opt/homebrew-cask/, which is empty.
    – orome
    Commented Jun 3, 2022 at 13:15
  • Should I be using /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb instead?
    – orome
    Commented Jun 3, 2022 at 13:28
  • 1
    @orome Yes, for Intel-Macs, it's located in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula Commented Jun 3, 2022 at 13:49
  • For me git checkout gives: fatal: not a git repository (or any of the parent directories): .git (using /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb).
    – orome
    Commented Jun 3, 2022 at 13:58
  • 1
    @orome Same problem as with git status - you need to cd into that directory and then call git checkout watchman.rb I'm not sure why git behaves this way, but it seems to be the way it's working. I'll update my answer. Commented Jun 3, 2022 at 19:43
2

As mentioned previously, you need to 'Accept' perms for watchman again. I use yarn and needed to run 'npm start' to show dialog again.

1

We can also encounter this error message when running React Native apps. To resolve the error, we need to re-request permissions for the watchman tool which RN uses.

Navigate to the project root folder and run npm start in a Terminal. This should request permissions for watchman and once granted, we can build the app again.

The typical build process outside a terminal doesn't re-request permissions which is why we need to start from a Terminal separately.

1

Just got this error earlier (Air M2), I don't know I just updated my OpenJDK and this happended, this is my solution.

  1. Go to Privacy and Security > Files and Folders > Watchman
  2. Enable the "Folders" that are present under the watchman.
  3. Restart PC
  4. Run your project, and "Watchman" will ask a permission, click "Allow".
0

It seems that the problem is that the watchman didn't have permission to access the ~/Documents folder. 🤔 Reinstalling watchmen seems to work as it triggers the grant access prompt.

1
  • 1
    This was a bug with an older version of watchman that has now been fixed.
    – orome
    Commented Jan 31, 2023 at 19:06
0

In my case, I am on the MacOS beta, which means the standard XCode does not work. In order to resolve this, I had to delete the XCode app and rename the XCode-beta to XCode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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