Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
While running jest --watch
on already changed JS files on Zsh, we have an error:
Determining test suites to run...Error: spawn git ENOENT
at exports._errnoException (util.js:1023:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
While running jest --watch
on already changed JS files on Bash, Jest acts like there's no changes at all.
Determining test suites to run...
--no-cache
doesn't change anything in both of this processes.
What is the expected behaviour?
I want to see no error and the result of all the tests of the _diff shit_.
Jest v19.0.2
Node v7.5.0
Windows 8
Do you have git
installed and available through terminal?
I am also seeing this behavior using the Jest that comes bundled with the create-react-app (Jest v 18.1.0). I'm running Windows 7 and node v4.4.3
Determining test suites to run...Error: spawn git ENOENT
at exports._errnoException (util.js:870:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
at onErrorNT (internal/child_process.js:344:16)
at nextTickCallbackWith2Args (node.js:442:9)
at process._tickCallback (node.js:356:17)
Git is definitely available:
C:\bitbucket\pumping-station-calculator>git --version
git version 2.4.5
If I remove the git repository or set the CI
environment variable then everything works as expected.
I'm facing the same error on Windows 10. Only doesn't work on Zsh shell.
禄 npm 3.10.10
禄 node 6.10.3
禄 git 2.12.3
禄 jest 20.0.4
Setting CI flag doesn't seem to fix it.
I'm facing the same error on Windows 10, too.
Current workaround to avoid this error is:
Use cmd.exe, instead of MSYS2 bash/zsh.
* git 2.1.2.windows.1 # Installed via MSYS2 pacman
* nodist 0.8.8 # Installed via windows installer
* node v7.10.0 # Installed via nodist
* npm 4.0.5 # Installed via nodist
* create-react-app 1.3.1 # Installed via npm
* jest 20.0.3 # Installed via npm
The Error: spawn git ENOENT
error occurs in MSYS2 systems with .git directory.
> create-react-app sample1
> cd sample1
> npm test # This works
> git init
> npm test # This works, too
% create-react-app sample2
% cd sample2
% npm test # This works
% git init
% npm test # This causes 'Error: spawn git ENOENT'
In git.js, there are childProcess.spawn calls.
const child = childProcess.spawn('git', args, { cwd });
The 3rd argument cwd
value is like following:
If replace unix style path with windows style path,
jest works on MSYS2 bash or zsh.
Now I just found this, so I don't know who need to care about this.
But I post this on this issue for other developers.
Thanks!
@meltedice would you like to work on a proper fix and send a PR if you have some time?
@thymikee
I tried some to create PR.
But it seems it's not jest-changed-files issue...
Maybe it's due to my and others' development environment issue.
On windows, it's easy to mix tools that uses different path style.
It causes this problem.
If node.js version manager, git and hg use different path style, jest doesn't work.
(It's hard to solve this mixed path style problem in jest-changed-files)
I think a better way is make sure tools' path style, then use the same path style.
(Better to notice in README.md?)
My cmd.exe on windows environment:
where nodist
=> "C:\Program Files (x86)\Nodist\bin\nodist"where git
=> "C:\Git\cmdgit.exe"yarn test
works!My zsh on msys2 on windows environment:
which nodist
=> "/c/Program Files (x86)/Nodist/bin/nodist"which git
=> "/usr/bin/git"yarn test
doesn't work.My fixed zsh on msys2 on windows environment:
which nodist
=> "/c/Program Files (x86)/Nodist/bin/nodist"PATH=/c/Git/cmd/:$PATH git
=> /c/Git/cmd/gitPATH=/c/Git/cmd/:$PATH yarn test
works!alias yarn="PATH=/c/Git/cmd/:\$PATH yarn"
alias npm="PATH=/c/Git/cmd/:\$PATH npm"
yarn test
and npm test
work!So my solution is add following into .bashrc or .zshrc for msys2:
alias yarn="PATH=/c/Git/cmd/:\$PATH yarn"
alias npm="PATH=/c/Git/cmd/:\$PATH npm"
If I can install another node.js version manager into msys2 system,
I don't need to do above trick.
node.js | git/hg | jest
-------------- | -------------- | -----
Windows system | Windows system | works
Windows system | msys2 system | doesn't work
msys2 system | Windows system | maybe doesn't work
msys2 system | msys2 system | maybe works
If there are unclear parts or something what I can do, let me know.
Thanks,
We currently don't have bandwidth to support these use cases, nor do we have Windows machines. If you'd like this to be fixed, please send us a PR. From our side, this is not really actionable, so I'm closing this issue.
I was facing the same issue when using Cygwin.
I was able to solve it renaming "C:\cygwin64\bin\git.exe"
to "C:\cygwin64\bin\git.exe.bak"
. That way, jest will use the same git that cmd uses, and everything works fine (at least until now)
@GabrielDuarteM at this point of time this answer is incorrect :(,
but i found out that root of git repo is injected incorrectly
from: getRoot
https://github.com/facebook/jest/blob/481334b6/packages/jest-changed-files/src/git.ts
git rev-parse --show-toplevel
is returning /cygdrive/c/Users/...
instead of C:\Users\...
to fix this we should parse this with cygpath -w
, but this would fix this bug only for cygwin, what with other unix emulators on windows like msys2 or mingw
we need a way to obtain root of git project as a WINDOWS path instead of cygwin path..., but without cygpath -w
any ideas? im able to do PR to fix this but sadly only for cygwin which is bad.
damn windows, why i'm still with you
edit:
we can replace --show-toplevel
with --show-cdup
and use path.join(cwd, result.stdout)
Most helpful comment
I was facing the same issue when using Cygwin.
I was able to solve it renaming
"C:\cygwin64\bin\git.exe"
to"C:\cygwin64\bin\git.exe.bak"
. That way, jest will use the same git that cmd uses, and everything works fine (at least until now)