21

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?

orome
  • 45,163
  • 57
  • 202
  • 418

5 Answers5

31

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.

Mike S.
  • 2,048
  • 1
  • 32
  • 55
  • This is different than the original issue, which was a bug in older versions. What you describe is the normal behavior (pretty much). – orome Oct 12 '22 at 16:25
  • @orome I answered the author's question about watchman permissions on M1. That's all that is required. – Mike S. Oct 12 '22 at 18:29
20

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.

Andreas Oetjen
  • 9,889
  • 1
  • 24
  • 34
  • 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 Jun 03 '22 at 13:15
  • Should I be using `/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb` instead? – orome Jun 03 '22 at 13:28
  • 1
    @orome Yes, for Intel-Macs, it's located in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula – Andreas Oetjen Jun 03 '22 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 Jun 03 '22 at 13:58
  • That's strange. On my Intel mac: `$git status /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula On branch master Your branch is up to date with 'origin/master'.` – Andreas Oetjen Jun 03 '22 at 15:55
  • I guess that's [another question](https://stackoverflow.com/q/72492307/656912) then. – orome Jun 03 '22 at 16:04
  • A small mistake of mine: command should be `git -C status`, thanks to @torek – Andreas Oetjen Jun 03 '22 at 16:18
  • OK, `staus` works now but I still get an error with `it checkout -- /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/watchman.rb`: `fatal: not a git repository (or any of the parent directories): .git`. Should I have other flags there too, or be in a particular location when I execute? – orome Jun 03 '22 at 16:24
  • 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. – Andreas Oetjen Jun 03 '22 at 19:43
  • Yeah what threw me off was `-C` wasn’t working. All set now. Thanks! – orome Jun 03 '22 at 19:56
  • I've run `git checkout watchman.rb` but it returns "Updated 0 paths from the index". What happens now? – JCraine Jun 04 '22 at 04:06
  • Best answer, I've been finding the solution for so long. Thanks. – Nikhil Thakur Aug 18 '22 at 02:45
  • Thanks, it works for me. To unpin: ```brew unpin watchman``` – Huan Huynh May 18 '23 at 08:54
7

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

0

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.

Pranav Kasetti
  • 8,770
  • 2
  • 50
  • 71
-1

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.