21

Trying to run react-native run-ios or build RN project from xcode, as soon as metro bundler starts, this error appears in the terminal:

Loading dependency graph...jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty `.watchmanconfig` file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:183
      throw er; // Unhandled 'error' event
  ^

Error: resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted
    at BunserBuf.<anonymous> (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/fb-watchman/index.js:95:23)
    at emitOne (events.js:116:13)
    at BunserBuf.emit (events.js:211:7)
    at BunserBuf.process (/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:292:10)
    at /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA/node_modules/bser/index.js:247:12
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

This never happened before the Catalina update. I've had an empty watchman config file in the root of my project since the beginning. On first boot post-update, there was a popup in terminal saying something about permissions but i dont remember exactly. there's also a notice in my terminal in visual studio code saying "the default shell changed to zsh" run chsh -s /bin/zsh to change, so i did.

I've tried:

  • watchman watch-del-all

  • watchman server-shutdown

  • adding full disk access to terminal from within system preferences->privacy tab

  • npm uninstall watchman & npm uninstall -g watchman

Jim
  • 1,988
  • 6
  • 34
  • 68

14 Answers14

33

You need to grant disk access to watchman. To do this You need to:

  • Go to System preferences > Security & Privacy then scroll down
  • Select Full Disk Access
  • Unlock it and click + button to add new app/tool
  • Select Macintosh HD in the folders list
  • Press this combination shift Command . at the same time to see all the directories list
  • Click opt > brew > bin (watchman is installed in this folder for MacOS Catalina) || usr > local > Cellar > Watchman > 21***** > bin (watchman is installed in this folder MacOS Monterey)
  • Look for watchman in the list then select it

Here we go, this should fix the issue.

kartik tyagi
  • 6,256
  • 2
  • 14
  • 31
Juba Fourali
  • 740
  • 9
  • 10
  • 6
    I had the same problem after upgrading to Mac OS Monterey and this solved it for me except my watchman is located in usr/local/Cellar – ragamufin Oct 28 '21 at 08:22
  • Worked perfectly, thank you! – Amanda Koster Jan 05 '22 at 00:52
  • Unfortunately this didn't work for me. And watchman already had Files & Folders permission. – shoopi Jun 03 '22 at 17:54
  • 2
    So it seems v2022.05.30.00 is broken. See: [here](https://github.com/facebook/watchman/issues/1030) – shoopi Jun 03 '22 at 18:48
  • 2
    It may be necessary to restart the watchman service (`watchman shutdown-server` then `watchman`) after doing these steps for them to take effect. Also consider clearing its cache with `watchman watch-del-all` or opening a new terminal window if that doesn't work. – user56reinstatemonica8 Jan 30 '23 at 17:23
  • When still doesn't work try to restart your device – newbie Mar 18 '23 at 03:50
  • I had two different listings of `watchman` there, I enabled both, enabled `iTerm` too then restarted it, then it worked. Thanks! – Yuniac Jul 25 '23 at 09:49
27

I had the same issue after updating to Catalina. Wez Furlong's answer worked for me, but I had to provide full disk access to watchman in order to run watchman watch-project command without getting "Operation not permitted" error. As part of prior troubleshooting, I also had provided full disk access to Xcode and Terminal (not sure if this also contributed to the fix).

enter image description here

B--rian
  • 5,578
  • 10
  • 38
  • 89
Eric
  • 504
  • 4
  • 4
  • ultimately i never had the .plist file Wez Furlong suggested to remove, i reinstalled watchman, gave full disk access to one of like 13 watchman programs, ran `watchman watch-project` as suggested here and everything worked. thanks so much – Jim Oct 10 '19 at 18:29
  • Where is your project located?(~ or somewhere else inside ~) – onuriltan Feb 20 '20 at 16:03
  • 1
    This is the correct answer. Helped me fix the issues after Catalina upgrade. System Preferences -> Security & Privacy -> Privacy -> Full Disk Access -> Enable watchman – KunalMZ Mar 22 '20 at 13:09
  • 6
    What to do if watchman isn't in that list of apps? – Callum Thomas Jun 02 '22 at 00:44
  • @CallumThomas I am facing the same issue, I cannot see watchman in the list of apps even after installing it using brew. How did you fix the issue? – Zahir Masoodi Jan 21 '23 at 15:07
  • 1
    @ZahirMasoodi It must be hidden in the homebrew cellar directory. After clicking on the plus icon in Full Disk Access, select Macintosh HD folder, press command+shift+. (period) and you will see hidden folders. From there, go to opt > homebrew > Cellar > watchman > 2023.01.16.00 (Folder name based on watchman installation date) > bin and select the watchman. Hope this helps! – danish Jan 23 '23 at 11:45
27

First run watchman watch-del-all then run watchman shutdown-server fixed my issue

Patrick Muhire
  • 384
  • 3
  • 6
14

To change the permissions for Watchman regarding the Documents folder, it's under Security & Privacy -> files & folders in the system preferences

My issue was resolved by checking Watchman in the list under Document folder

d36williams
  • 389
  • 1
  • 12
2

The error message indicates a permission problem on /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA.

However, it may be something funky with launchd, so I would suggest:

$ watchman shutdown-server
$ launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
$ rm ~/Library/LaunchAgents/com.github.facebook.watchman.plist
$ watchman watch-project /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA

and see if that works or shows more context.

Cross linking back to an issue in our GitHub tracker: https://github.com/facebook/watchman/issues/751

Wez Furlong
  • 4,727
  • 1
  • 29
  • 34
  • 1
    result: `Jamess-MacBook-Pro:TicTacWHOA vorousjames$ watchman watch-project /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA { "version": "4.9.0", "error": "resolve_projpath: path `/Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA`: open: /Users/vorousjames/Desktop/Development/TicTacWHOA/app/TicTacWHOA: Operation not permitted"}` – Jim Oct 10 '19 at 18:13
2

You need to change something its works for me. follow only following steps:

1. Go to System preferences > Security & Privacy then scroll down.
2. Select    Full Disk Access.
3. Look for all watchmen on the list.
4. check(Mark) all Folders in all watchman files. 
5. then go to vs code.
6. rebuilt your code.
I hope it will work smoothly
sherkhan
  • 811
  • 8
  • 8
0

Try to change the directory of your project. I had mine on desktop and was getting that error, moved to the home folder and the error is gone

0

Just uncheck the repeated boxes in Mac:

System Preferences -> Security and privacy -> Privacy

enter image description here

Caro Pérez
  • 476
  • 4
  • 4
0

For me above scenario didn't work, so I tried with different solution which solved the problem for me. (I am using MacBook Pro, chip: Apple M1 pro)

At first you have to update the setting of your Mac OS

System Preference >> security & privacy >> privacy tab >> Full disk access >> click on the lock icon >> checkmark for terminal

Sometime using this steps you are able to resolve the issue, but after this, if you are still facing issue, please use this link: #1030 (comment)

0

on macos. brew uninstall watchman it works for me

pabios
  • 9
  • 4
  • 2
    Please read [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). While this code block may answer the OP's question, this answer would be much more useful if you explain how this code is different from the code in the question, what you've changed, why you've changed it and why that solves the problem without introducing others. – Saeed Zhiany Aug 17 '22 at 03:23
0

It is related that Documents or another folder permission is privacy. Try to sudo to access terminal as below.

  1. brew reinstall watchman (optional)
  2. sudo npx react-native startterminal.
  3. Apply watchman permission popup.
  4. Done
Jeff Gu Kang
  • 4,749
  • 2
  • 36
  • 44
-1

npx react-native start --port=8088 resolved mine

Favour Emmanuel
  • 111
  • 3
  • 11
-1

There is only one solution at the moment. Move your project from the "Desktop" or "Documents" folder to the main folder (~/). None of the other ways worked for me.

This is because MacOS now asks for permissions for these folders (example in the image below). I guess this hasn't been added to the watchman yet.

Example permission

yusufusta
  • 399
  • 3
  • 7
-1

As a temporary workaround, you can move your project to your home folder and it should run successfully.

To open your home folder, press Command-Shift-H.

(As of June 2022, there seems to be an issue with the 2022.05.30.00 version of Watchman, and this temporary solution is the only way I have been able to get around the issue.)

Green
  • 507
  • 10
  • 20