Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch mode stopped working on macOS Sierra #1767

Closed
Anahkiasen opened this issue Sep 22, 2016 · 140 comments
Closed

Watch mode stopped working on macOS Sierra #1767

Anahkiasen opened this issue Sep 22, 2016 · 140 comments

Comments

@Anahkiasen
Copy link

Anahkiasen commented Sep 22, 2016

This is a bug that seems to happen ever since I've updated to Sierra.

Whenever I want to run Jest in --watch mode it crashes:

$ jest --watch
2016-09-22 10:49 node[79167] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2016-09-22 10:49 node[79167] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2016-09-22 10:49 node[79167] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Error watching file for changes: EMFILE
    at exports._errnoException (util.js:1036:11)
    at FSEvent.FSWatcher._handle.onchange (fs.js:1406:11)

Tried reinstalling the node modules, checking for any updates and anything. I can't seem to reproduce it on a new project but on the other hand even if I just run an empty test suite with --testPathPattern it still crashes, so I'm guessing it's a dependency conflict somewhere. I don't have any setup files or anything, it's literally running an empty file and crashing.

I don't get any more output with --debug so not sure what else to provide to help. This does not happen with --watchman

$ node --version && npm --version && jest --version
v6.6.0
3.10.8
v15.1.1
@robzolkos
Copy link

I had the same issue. Upgrading watchman with brew install watchman to v4.7.0 fixed it.

@cpojer
Copy link
Member

cpojer commented Sep 22, 2016

I'm quite confident this is not a Jest issue but either an underlying module or something else on your system. Unsure how to troubleshoot, everything is fine here on Sierra.

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

I also got a similar report about Sierra: facebook/create-react-app#713

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

@cpojer Do you have a Sierra? Have you tried 6.6.0 on it?

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

Per facebook/create-react-app#713 (comment), uninstalling Watchman fixes the issue so it’s either a problem with Watchman, or its Jest integration on Sierra.

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

A few other possibly related threads:

ember-cli/ember-cli#6259
facebook/watchman#358

Can you try any suggestions there and report back?

@cpojer
Copy link
Member

cpojer commented Sep 24, 2016

@gaearon I'm using node 6.6.0 on Sierra with watchman and everything is fine.

@cpojer
Copy link
Member

cpojer commented Sep 24, 2016

Definitely seems like a watchman/upgrading issue. I'm gonna close this out for now but happy to reopen in case this is actually a Jest problem. Since many people reported this on other projects (rn) it is unlikely though.

@cpojer cpojer closed this as completed Sep 24, 2016
@gnoff
Copy link

gnoff commented Sep 27, 2016

I do not believe I have ever had watchman installed and I just now am experiencing this issue with jest in watch mode. I also recently upgraded to macOS Sierra. My guess is watchman can help (and I will try it as a workaround) but I don't think the problem is native to having or using watchman

@bedeoverend
Copy link

FWIW I don't have watchman installed and still had this bug, but deleting my node_modules folder and reinstall did the trick for me

@hmeerlo
Copy link

hmeerlo commented Sep 30, 2016

I think it is a bit short through the corner to close this issue. Jest reports an error, so maybe the problem is in one of the dependencies which need to be updated? I removed my node_modules and reinstalled, but to no avail. I never installed watchman and even if I did, the dependencies should be coming from my package.json, not from any external program I installed.

@cpojer
Copy link
Member

cpojer commented Sep 30, 2016

I was thinking that fsevents is the issue. I would recommend reinstalling the node binary, wiping away all node_modules folders and doing a fresh npm install.

@hmeerlo
Copy link

hmeerlo commented Sep 30, 2016

I installed new node binary (6.7.0), removed node_modules again, reinstalled everything but still the same error. But I guess the problem is that it is trying to watch too many files at once: http://stackoverflow.com/questions/8965606/node-and-error-emfile-too-many-open-files

@robzolkos
Copy link

robzolkos commented Sep 30, 2016

The folks over on react-native fixed the too many files at once issue I think here

However for me, it was still an upgrade of watchman that fixed it.

@cpojer
Copy link
Member

cpojer commented Sep 30, 2016

Usually when this happens it is a sign to restart the computer. This happens frequently at FB too (unrelated to Jest) :(

@hmeerlo
Copy link

hmeerlo commented Sep 30, 2016

Sorry to be such a pain in the *ss. I raised the ulimits as pointed out in the issue @robzolkos pointed at, but why would I need to install watchman? It is not a dependency of Jest, I just use Jest out of the box as is. This is my setup now:

14:31 $ ulimit -n
100000
14:31 $ node --version
v6.7.0
14:31 $ npm -v
3.10.3

The project contains about 45k files (including node_modules) so I don't see why it could still give me an EMFILE. I will check if installing watchman is a workaround.

@cpojer
Copy link
Member

cpojer commented Sep 30, 2016

@hmeerlo watchman is a file watching service built by FB to make file system operations faster. Jest will run much faster on a big repo if watchman is installed and it brings the startup overhead of Jest to practically nothing as it will only statically analyze files that have changed.

@hmeerlo
Copy link

hmeerlo commented Sep 30, 2016

Thanx, I just checked it and it works flawless now, but there still is another issue somewhere for people who do not have watchman installed, as it is not a requirement for jest.

@cpojer
Copy link
Member

cpojer commented Sep 30, 2016

It's not a strict requirement but just like react-native, on big repositories with large dependency trees (lots of node modules, for example), we do recommend watchman for better performance and to avoid the problems mentioned in this issue. I would recommend your team to install it to speed up common file system operations.

@gaearon
Copy link
Contributor

gaearon commented Sep 30, 2016

@cpojer Should we document Watchman in CRA User Guide?

@cpojer
Copy link
Member

cpojer commented Sep 30, 2016

@gaearon Yeah, I don't think there is any problem with that. I would recommend adding it to the Jest docs as well.

I'm unsure how big the dependency tree of cra's node_modules is. If it is sufficiently large we should probably recommend watchman to most people.

@bedeoverend
Copy link

FYI Even though reinstall all node_modules initially did the trick for me, seems it was temporary, borked again. But installing watchman resolved this for me.

+1 to documenting it in Jest as a recommended install.

@davidtheclark
Copy link

It's unclear what the outcome of this issue is. Just now I've freshly installed Jest (with fresh node_modules) on Sierra and run into this problem, which makes --watch unusable. Is that the resolution of this issue just that Jest's watch mode does not work on Sierra? Or it only works on Node 6 with Watchman?

@gaearon
Copy link
Contributor

gaearon commented Oct 8, 2016

Do you have problems if you uninstall Watchman completely? Jets should use the Node based watcher if you do so. Do you have issues with it as well?

@davidtheclark
Copy link

@gaearon I only got it to work by installing Watchman. Without Watchman, no luck.

@Anahkiasen
Copy link
Author

Same here, it's without watchman that it doesn't work for me

@carl-altvr
Copy link

I was having this problem using node 4.6.0 after upgrading to Sierra. After upgrading node to v6.7.0, clearing node_modules and running a new npm install, jest watch started working again. I had to both upgrade node and then clear node_modules, though; those things individually didn't fix the problem.

@yisding
Copy link

yisding commented Oct 24, 2016

Mac OS Sierra (10.12.1). Node 6.7. If I don't install watchman, I get the error. Please reopen. This is a jest problem, and also creates problems when using create-react-app.

@adrianhelvik
Copy link

I get this error with jest 21, but not with jest 20.

@dchambers
Copy link

I didn't have Watchman installed, but a brew install watchman fixed this for me.

@shellbryson
Copy link

shellbryson commented Jan 5, 2018

Also didn't have Watchman installed & brew install watchman fixed. Bizarrely, everything was working until I installed Enzyme into my project, after which the problem appeared in twice before the test run aborted. Rolling the project back did not fix. I've had to document this work around, but I'm not understanding why it happened, or how to avoid it in the future (given homebrew isn't always an option).

Node: v6.9.5

@BookOfGreg
Copy link

@dchambers I had the opposite issue:
I did a brew uninstall watchman and Jest started running!
See facebook/watchman/issues/20

@ghost
Copy link

ghost commented Feb 6, 2018

Incredibly strange, I was trying to figure this out, I uninstalled watchman using brew uninstall watchman like @BookOfGreg and it now works.

@CamJN
Copy link

CamJN commented Feb 12, 2018

This is still broken in High Sierra with a create-react-app generated app, node v9.5.0,
npm 5.6.0, and jest 18.1.0.

@jaredwilli
Copy link

I had to install watchman, which is weird that everyone is saying they had to uninstall it.

I'm just happy it's working :)

@adrianhelvik
Copy link

I once again had to downgrade Jest because of some cryptic error. Love Jest and downgrading worked. But I'm not getting the most recent version of Jest to play along in any way!

@billfienberg
Copy link

#1767 (comment)

brew install watchman fixed it for me.

@russellf9
Copy link

I was working on a simple React project created from Create React App.

I was simply trying to add some Jest tests running npm run test

Resulted in an error:

the owner of /usr/local/var/run/watchman/factornine-state is uid 0 and doesn't match your euid 501

Watchman:  watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= 2018-03-25T14:38:11,538: [2754904896] the owner of /usr/local/var/run/watchman/factornine-state is uid 0 and doesn't match your euid 501

OSX - 10.13.3
Node - v6.13.0
NPM - 3.10.10
watchman 4.7.0

Project Enviroment
React 16.2.0
Jest 22.4.3

I tried brew upgrade watchman -> watchman 4.9.0 to no avail.

Setting the permissions on the /usr/local/var/run/watchman directory didn't work either.

This did though:

rm -rf node_modules/
npm update
brew uninstall watchman

npm run test ran without error!

@powah
Copy link

powah commented Apr 26, 2018

brew uninstall watchman helped me too! (node_modules reinstalling had no effect)
Env:
OSX - 10.13.3
Node - 8.11.1
npm - 5.8.0
watchman 4.9.0
Jest - 22.4.3

@stevenhadcroft
Copy link

I had exactly the same problem. $ brew install watchman worked perfectly for me aswell

@farhansyed77
Copy link

brew install watchman or brew reinstall watchman or brew uninstall watchman did not work for me :(.

Whether the test succeeds or not, it just hangs after all tests are executed. Using --forceExit did not help.

node -v
v10.1.0
yarn -v
1.6.0
yarn jest --version
v21.2.1

@mynameistechno
Copy link

mynameistechno commented Jun 3, 2018

I'm using create-react-app and following instructions here:

https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components

Removing jest-enzyme fixed the error for me. I'll try downgrading jest-enzyme to see if it helps.

Edit: upgrading to the alpha version of react-scripts (which upgrades jest) ultimately fixed this for me.

@releaf
Copy link

releaf commented Jun 8, 2018

After adding Enzyme 3.3.0, this issue started for my team using an ejected version of CRA. We're all on High Sierra if that matters.
I explored all of the options outlined in the many links here and, aside from brew install watchman, nothing seemed to work. That was not an acceptable solution for me so I continued to investigate. Ultimately, updating to Jest 23.1.0 resolved the issue.

@chrisbridges
Copy link

+1 more for installing Watchman. Don't like it, but it did work

@mrdulin
Copy link

mrdulin commented Jul 31, 2018

@robzolkos thanks. But I don't want to install watchman by myself

@bdharrington7
Copy link

I just ran into this myself, but what caused it was installing these packages in my CRA as dev dependencies:

    "enzyme": "^3.4.1",
    "enzyme-adapter-react-16": "^1.2.0",
    "react-test-renderer": "^16.4.2"

removing these dependencies fixed the issue.

node: 8.9.4 || 8.11.3
npm: 5.6.0

I didn't bother to install watchman with brew.

@Peripona
Copy link

How i fixes this was.

At first i tried brew install watchman and yes it worked like charm, However i was thinking if this could be the real issue? i again uninstalled it brew uninstall watchman

then i removed my node modules rm -rf node_modules and hit npm i again
also when i hit npm list --depth=0 I had Err of UNMET PEER DEPENDENCY [email protected]
and then i moved jest from dependencies to devDependencies using npm i -D jest

in short

  1. rm -rf node_modules
  2. npm i
  3. npm i -D jest (if required)

might help someone. :)

@storrisi
Copy link

storrisi commented Oct 18, 2018

I was not using create-react-app, and i've solved removing the --watch option and using instead --no-watchman

@mynameistechno
Copy link

Upgrading Jest (or react-scripts if you use cra) fixed it for me. React-scripts 2 went stable recently.

@trollepierre
Copy link

Still have the same issue here. Someone has opened an issue on the watchman repository?

@chesleybrown
Copy link

For anyone else still having this problem, I was able to resolve it by adding my node_modules directory to watchPathIgnorePatterns in my jest config.

watchPathIgnorePatterns: ["node_modules"]

Credit owed to @reergymerej from here.

@CWSites
Copy link

CWSites commented Feb 8, 2021

I'm still having this issue. Using latest create-react-app and I spent about 30 minutes going down the watchman issues however I completely uninstalled and verified that watchman was gone and yarn test is still hanging.

@jhunterkohler
Copy link
Contributor

My tests were working perfectly fine, and all the sudden they stopped working. The reinstall of watchman by the following commands did not work. This is on MacOS Big Sur 11.2.3.

brew upgrade
brew uninstall watchman
brew install watchman

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests