65

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 --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2018-03-23T11:33:13,360: [0x7fff9755f3c0] the owner of /usr/local/var/run/watchman/root-state is uid 501 and doesn't match your euid 0

bfontaine
  • 18,169
  • 13
  • 73
  • 107
Mandar Belkunde
  • 744
  • 1
  • 5
  • 10

16 Answers16

187

Testing with jest:

Step 1:

watchman watch-del-all

Step 2:

watchman shutdown-server
cigien
  • 57,834
  • 11
  • 73
  • 112
Jeffox
  • 2,341
  • 2
  • 8
  • 8
  • 1
    I tried all the solutions from the GitHub issue page but none of them worked. Then I came to the StackOverflow solution and its first answer worked. Thanks to its Trending Sort functionality and you @Jeffox. – Kishan Bharda Jun 29 '22 at 05:06
  • This worked for me, on mac, but only after I first uninstalled watchman and then reinstalled it. – Green Sep 16 '22 at 16:44
  • 1
    After OS updates on macos, watchman needs admin privileges to work again. `watchman shutdown-server` helped to ask the access to my documents and to have watchman working again. – Guillaume Nov 28 '22 at 14:24
  • The issue comes back after opening a new session, so the above commands, while they do make the warning go away, only work temporarily (running from inside an IDE)... – benomatis Jan 25 '23 at 09:41
  • This command worked for me. I am on M1 Mac – John Dollosa Aug 06 '23 at 10:03
  • For me as well, on mac M1 this command fixed it, thanks! – Lucas Ramos Aug 25 '23 at 10:51
27

You're running watchman as root but the state dir, which may contain trigger definitions and thus allow spawning arbitrary commands, is not owned by root. This is a security issue and thus watchman is refusing to start.

The safest way to resolve this is to remove the state dir by running:

rm -rf /usr/local/var/run/watchman/root-state

I'd recommend that you avoid running tools that wish to use watchman using sudo to avoid this happening again.

Wez Furlong
  • 4,727
  • 1
  • 29
  • 34
  • What about windows OS. I get this error on windows too. – Saeed Zhiany Feb 05 '19 at 05:20
  • you don't have the same issue as the OP because the Windows version of watchman doesn't have this same check. I'd recommend that you reach out to the React Native folks for assistance. – Wez Furlong Feb 09 '19 at 03:39
  • Thanks. I got this error in Android Studio, and was running as root to upgrade the program. Closing Studio and opening again not as root seems to have solved it for me. I was building a React Native app. – Jesse W. Collins Oct 29 '20 at 01:00
14

As Jodie suggested above I tried the below and it worked well, for the benefit of others mentioning below steps which I tried in my mac to fix this issue

  1. First, Kill all the server running and close your terminal.
  2. Go to 'System preferences' -> 'Security & Privacy' -> privacy tab
  3. Scroll down and click 'Full Disk Access'
  4. Make sure you checked on 'Terminal' and 'Watchman'.
  5. Now relaunch terminal and simply try running again it works!!
jaishankar
  • 249
  • 1
  • 4
  • 13
4

-June 8 2022

Giving Full Disk Access to all terminals or where you're getting started your server, is fixed the error. Also, it would be good to give access (Files and Folders) to VSC.

Here are the steps to do it!

  1. Open System Preferences

enter image description here

  1. Find Security & Privacy option and open it

enter image description here

  1. Give Full Disk Access to your terminals, Xcode and VSC.

enter image description here

Happy Hacking!!!

Erencan
  • 185
  • 6
  • 1
    Your answer can be improved by adding additional information. You should provide step by step procedures to reach the "Full Disk Access" option and accomplishing the whole setting process. That would help much to anyone reading your answer. – Dilunga the Great Jun 09 '22 at 08:32
  • Additional Step - On click Security & Privacy , Got to Privacy Tab .Scroll down to see Full Disk access – deva11 Dec 18 '22 at 12:10
4
  1. watchman watch-del-all

  2. watchman shutdown-server

Worked on MAC with no problem.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 14 '23 at 08:11
  • help me, thank you! was switching between 3 RN projects, and restarting watchman server fix this issue – nastassia Aug 29 '23 at 14:18
3

I had a real issue with this one but finally found the answer.

Here's a screenshot of the post that helped me.

https://github.com/facebook/watchman/issues/751#issuecomment-542300670

The whole forum has multiple different solutions which I hadn't actually tried, but this one is the solution that worked for me! Hope this helps.

Jodie
  • 31
  • 2
  • 2
    Welcome to Stack Overflow! While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Vasil Velichkov Mar 02 '20 at 11:37
2

I solved this, on linux by using the following commands on terminal.

$ echo 256 | sudo tee -a /proc/sys/fs/inotify/max_user_instances

$ echo 32768 | sudo tee -a /proc/sys/fs/inotify/max_queued_events

$ echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches

$ pkill node

Then:

$ npm start

or

$ expo start (if you are using expo)
blackgreen
  • 34,072
  • 23
  • 111
  • 129
2
watchman watch-del-all && rm -f yarn.lock && rm -rf node_modules && yarn && yarn start -- --reset-cache
cigien
  • 57,834
  • 11
  • 73
  • 112
Bilal Yaqoob
  • 790
  • 1
  • 10
  • 22
1

Step 1: $ npm cache clean --force

Step 2: Delete node_modules: $ rm -rf node_modules

Step 3: npm install

Step 4? (Optional): yarn start / npm start

This worked for me. Hopes it works for you too.

1

If you're not actually using watchman with Jest just set watchman: false in your jest.config.js to stop this message when running tests.

Luke Watts
  • 601
  • 7
  • 15
0

On a Mac, remove all watches and associated triggers of running process, then shutdown the service. See screenshot below: enter image description here

Felix Too
  • 11,614
  • 5
  • 24
  • 25
0

Put your project in a shared folder (ie, Macintosh HD/Users/Shared. I kept getting operation denied on the Desktop, because of further protection policies, even though Full Disk Access was granted.

Dwaine
  • 163
  • 6
0

To solve this issue on my end, i had to stop the other node instance running on my other terminal. Just make sure you don't have another node running on your machine.

0

check for .watchmanconfig and add this {}.

Inside the file .watchmanconfig

{}

Simple as that just try it.

0

Watchman config file

I set my .watchconfig file to be extra permissible: Add this code to your .watchmanconfig file


{
  "ignore_dirs": [],
  "fsevents_latency": 0.5,
  "fsevents_try_resync": true
}
cigien
  • 57,834
  • 11
  • 73
  • 112
0

// In jest.config.js, set watchmen to false.

module.exports = {
  //other options ...
  watchman: false,
};
KISHORE K J
  • 186
  • 2
  • 4