orome
orome

Reputation: 48576

Can't use Watchman: "Operation not permitted"

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?

Upvotes: 46

Views: 44737

Answers (9)

Mustapha GHLISSI
Mustapha GHLISSI

Reputation: 1730

The clean solution is to kill the server and restart the metro builder:

  1. Kill watchman server:

    watchman shutdown-server

  2. Restart metro:

    yarn start --reset-cache

Upvotes: 2

Praise
Praise

Reputation: 328

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.

Upvotes: 0

LuciFer
LuciFer

Reputation: 88

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".

Upvotes: 2

Gustavo Méndez
Gustavo Méndez

Reputation: 21

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

Upvotes: 2

Pranav Kasetti
Pranav Kasetti

Reputation: 9935

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.

Upvotes: 1

Şuayip Işık
Şuayip Işık

Reputation: 588

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

Upvotes: 49

Ramūnas Mališauskas
Ramūnas Mališauskas

Reputation: 81

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.

Upvotes: 0

Mike S.
Mike S.

Reputation: 2818

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.

Upvotes: 97

Andreas Oetjen
Andreas Oetjen

Reputation: 10209

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.

Upvotes: 23

Related Questions