yarn version v1.22.19
info Current version: 0.2.18
info New version: 0.2.19
error Couldn't find the binary git
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.
The root of the problem is not that yarn can not find git. The root of the problem appears to be
that this version of yarn calls
git rev-parse --show-toplevel to determine the location of the root of the project
and the cygwin version of git returns a path that is compatible with cygwin. Ex.
/cygdrive/c/Users/nnd15/work/slogger.
yarn assigns that to gitRoot and then calls
path.relative(gitRoot, pkgLoc)
where pkgLoc is expressed in DOS/Window's native syntax, ex.
C:\Users\nnd15\work\slogger\package.json.
The path returned by path.relative() is understandably nonsensical and this eventually results in the above error reported to the user.
This post
suggests that this is fixed in yarn 2.x. But some of us are not able to upgrade
because of issues like np not yet working with yarn 2.x.
My current work-around is to update a few lines in cli.js which might be found in a location like:
c:\Users\nnd15\AppData\Roaming\npm\node_modules\yarn\lib\cli.js
var gitRoot = (yield (0, (_gitSpawn || _load_gitSpawn()).spawn)(['rev-parse', '--show-toplevel'], { cwd: config.cwd })).trim();
if (true) { //jasonnet cygwin fix BEGIN
// gitRoot is sometimes expressed in cygwin form and here we need it in Windows form
let regex = /^[/]cygdrive[/]c[/]Users[/]/
gitRoot = gitRoot.replace(regex,"C:\\Users\\")
} //jasonnet cygwin fix END
I have not yet scanned the source code for other locations where this same change might be beneficial.
On yarn version 1.22.19 On cygwin vintage 2023-07
results in
The root of the problem is not that yarn can not find git. The root of the problem appears to be
git rev-parse --show-toplevel
to determine the location of the root of the project/cygdrive/c/Users/nnd15/work/slogger
.yarn assigns that to
gitRoot
and then callswhere pkgLoc is expressed in DOS/Window's native syntax, ex.
C:\Users\nnd15\work\slogger\package.json
. The path returned bypath.relative()
is understandably nonsensical and this eventually results in the above error reported to the user.This post suggests that this is fixed in yarn 2.x. But some of us are not able to upgrade because of issues like
np
not yet working with yarn 2.x.My current work-around is to update a few lines in cli.js which might be found in a location like:
c:\Users\nnd15\AppData\Roaming\npm\node_modules\yarn\lib\cli.js
I have not yet scanned the source code for other locations where this same change might be beneficial.