draft-js icon indicating copy to clipboard operation
draft-js copied to clipboard

Error: jest-haste-map: Watchman crawl failed. Retrying once with node crawler.

Open claudiopro opened this issue 6 years ago • 43 comments

Do you want to request a feature or report a bug? bug

What is the current behavior? When running jest in watch mode on the root directory of the project, jest-haste-map throws an error:

$ yarn test --watch
Using globally installed version of Yarn
yarn run v1.12.1
$ node node_modules/fbjs-scripts/node/check-dev-engines.js package.json
$ cross-env NODE_ENV=test jest --watch
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:  None of the files listed in global config root_files are present in path `/Users/procidac/Development/gh/facebook/draft-js/src` or any of its parent directories.  root_files is defined by the `/etc/watchman.json` config file and includes `.watchmanconfig`.  One or more of these files must be present in order to allow a watch. Try pulling and checking out a newer version of the project?. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: resolve_projpath:  None of the files listed in global config root_files are present in path `/Users/procidac/Development/gh/facebook/draft-js/src` or any of its parent directories.  root_files is defined by the `/etc/watchman.json` config file and includes `.watchmanconfig`.  One or more of these files must be present in order to allow a watch. Try pulling and checking out a newer version of the project?
    at BunserBuf.<anonymous> (/Users/procidac/Development/gh/facebook/draft-js/node_modules/fb-watchman/index.js:95:23)
    at BunserBuf.emit (events.js:182:13)
    at BunserBuf.process (/Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:292:10)
    at /Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:247:12
    at process._tickCallback (internal/process/next_tick.js:61:11)
Emitted 'error' event at:
    at Client.client.on.error (/Users/procidac/Development/gh/facebook/draft-js/node_modules/jest-haste-map/build/lib/WatchmanWatcher.js:130:10)
    at Client.emit (events.js:182:13)
    at BunserBuf.<anonymous> (/Users/procidac/Development/gh/facebook/draft-js/node_modules/fb-watchman/index.js:107:12)
    at BunserBuf.emit (events.js:182:13)
    at /Users/procidac/Development/gh/facebook/draft-js/node_modules/bser/index.js:249:12
    at process._tickCallback (internal/process/next_tick.js:61:11)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is similar to https://github.com/facebook/create-react-app/issues/346

What is the expected behavior? Jest starts in watch mode without errors

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? This is happening in draft-js master with Node v10.14.2

claudiopro avatar Sep 19 '19 09:09 claudiopro

I had this issue and it was because my Mac OS upgrade had removed permissions which watchman needed to watch files in the Documents directory. I went into System Preferences > Security & Privacy > Privacy > Files and Folders and manually gave watchman access.

Mas OS version: 10.15.1 Jest version: 22.1.4 watchman version: 4.9.0

nigelrobbins3 avatar Nov 20 '19 23:11 nigelrobbins3

at your root project location:

create a file named as .watchmanconfig and add {} as it's file content.

I have resolved this by doing this for my project. and @nigelrobbins3 answer also helped to solve it.

AmitPandya007 avatar Dec 18 '19 11:12 AmitPandya007

Based on @nigelrobbins3 remark above I ran brew uninstall watchman and brew install watchman to fix the problem.

jleach avatar Apr 27 '20 16:04 jleach

Don't install your application in the Documents root directory, put it in a folder. It worked for me.

No Captura de Tela 2020-07-24 às 23 07 15

Yes Captura de Tela 2020-07-24 às 23 08 03

paulohcardoson avatar Jul 25 '20 03:07 paulohcardoson

Based on @nigelrobbins3 remark above I ran brew uninstall watchman and brew install watchman to fix the problem.

brew reinstall watchman

JSONRice avatar Sep 17 '20 18:09 JSONRice

Having the same issue, none of the above worked Mac 10.15.6 Node 14

jbesraa avatar Oct 28 '20 09:10 jbesraa

I deleted the existing .watchmanconfig and created another one. Problem solved.

Ogala avatar Mar 18 '21 23:03 Ogala

Having the same issue, none of the above worked Mac 10.15.6 Node 14

Same here, but am running MacOS 12 (Monterey). Did you find a solution?

AdamGerthel avatar Dec 08 '21 15:12 AdamGerthel

Mine was due to watchman caching data from other react-native projects.

After I ran yarn clean (i.e. rm -rf $TMPDIR/react-* && watchman watch-del-all && yarn cache clean), the error went away.

zrichardson8039 avatar Dec 21 '21 02:12 zrichardson8039

@zrichardson8039 solution did the trick for me. I'm working with react-native in a yarn workspaces monorepo.

Enricopv avatar Dec 23 '21 00:12 Enricopv

Running watch-del-all && yarn cache clean && react-native start --reset-cache solved it for me!

Dajust avatar Jan 06 '22 23:01 Dajust

none of the above answers worked for me. Restarted my Mac and it worked.

yosoyafa avatar Jun 02 '22 20:06 yosoyafa

Related issue

shoopi12 avatar Jun 03 '22 18:06 shoopi12

I have a Mac M1. I solved the issue by uninstalling watchman via brew. I had more luck using watchman installed via MacPorts.

brew uninstall watchman

Install MacPorts

sudo port install watchman

gamble2020 avatar Jun 04 '22 14:06 gamble2020

For react-native projects, I went into System Preferences > Security & Privacy > Privacy > Full Disk Access and manually gave access permission to the following.

  • watchman
  • Android Studio
  • Visual Studio Code (If running command from VS code terminal)

AnuragHarod avatar Jun 06 '22 06:06 AnuragHarod

@gamble2020 thanks. nothing was working but your solution worked.

sahilbakoru avatar Jun 06 '22 06:06 sahilbakoru

I just reinstall watchman (brew reinstall watchman) and restart my macBook. It helps. Note: make sure that your terminal has Full Disk Access permission in MacBook settings

ziginsider avatar Jun 09 '22 10:06 ziginsider

https://stackoverflow.com/a/72571937/15190933

yusufusta avatar Jun 10 '22 09:06 yusufusta

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

kaushal-yadav avatar Jun 10 '22 12:06 kaushal-yadav

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

Thank You it`s help full me

hetramjanghu avatar Jun 11 '22 13:06 hetramjanghu

@kaushal-yadav It helped me too. Why is that?

dev-chief avatar Jun 19 '22 19:06 dev-chief

If you uninstall watchman you don't get any of its benefits..

shoopi12 avatar Jun 20 '22 05:06 shoopi12

uninstall watchman worked for me.

but it's so weird... I tried several hours to make it work with watchman...

And actually if I uninstall watchman, I ran into this issue https://github.com/facebook/watchman/issues/923

So I got a catch-22.

chinalwb avatar Jun 20 '22 09:06 chinalwb

@kaushal-yadav It helped me too. Why is that?

The thing that I found

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 refuses to start. 

It wants full disk access if you give that it will work. But we don't want to give full disk access 

kaushal-yadav avatar Jun 21 '22 04:06 kaushal-yadav

I tried to just uninstall watchman and it worked for me. brew uninstall watchman

thanks! its works for me

nguyenthanh1205tb avatar Jun 21 '22 07:06 nguyenthanh1205tb

I found a solution. Move the folder from the project to the directory: Users/shared folder Снимок экрана 2022-06-21 в 11 35 51

dev-chief avatar Jun 21 '22 08:06 dev-chief

My computer is controlled by the company who I work for, and I'm not able to add watchman to the system preferences/Security and privacy/Privacy.... , so I moved the project to /Users/myusername/ ...and it started to work.

gersonmontenegroepam avatar Jun 22 '22 13:06 gersonmontenegroepam

Hope this will be helpful. worked for me.

You should move the entire project directory outside of the Documents or Download directory for mac

https://github.com/facebook/watchman/issues/977

manirikhi avatar Jul 02 '22 23:07 manirikhi

So just to add more context to this. I had a similar issue in the react native project. It turns out this started when I was trying to install watchman to eject the project from expo. I uninstalled the watchman and did not re-install it. That worked for me and expo started working again for me!

shazimajaz1 avatar Jul 04 '22 22:07 shazimajaz1

First run watchman watch-del-all then run watchman shutdown-server

rishiankush avatar Jul 20 '22 07:07 rishiankush

Running watch-del-all && yarn cache clean && react-native start --reset-cache solved it for me!

watchman watch-del-all && yarn cache clean && react-native start --reset-cache work for me!

saronlujan avatar Jul 20 '22 10:07 saronlujan

In my case, I have an m1 MacBook pro, I had to just uninstall watchman with brew uninstall watchman and it worked.

josephflerime avatar Jul 26 '22 17:07 josephflerime

In case reinstalling watchman on macOS does not work, do:

brew uninstall watchman
killall watchman
brew install watchman

This will prompt for access to the Documents folder on the next launch of watchman, which should resolve the permissions issue.

slhck avatar Jul 28 '22 06:07 slhck

Just Restart your system. Helped in my case.

mohit2605 avatar Jul 28 '22 11:07 mohit2605

I deleted the existing .watchmanconfig and created another one. Problem solved.

Saved my life. Thanks.

hokimtam avatar Aug 01 '22 09:08 hokimtam

none of the above answers worked for me. Restarted my Mac and it worked.

Yes, restarted my Mac worked for me also. At login it asked Watchman for permission in the project folder. Odd.

Also: if you created a .watchmanconfig empty file in the root of the project following some of the above suggestions: remove it or fill it with

{}

nemwiper avatar Aug 03 '22 14:08 nemwiper