"cygpath: command not found" when commiting to branch
"cygpath: command not found" when commiting to branch
Github desktop version: 2.5.3 OS: Windows 10
Full error:
Commit failed - exit code 1 received, with output: '/c/Users/karlo/AppData/Roaming/npm/yarn: line 5: cygpath: command not found internal/modules/cjs/loader.js:1032 throw err; ^
Error: Cannot find module 'C:\Users\karlo\AppData\Local\GitHubDesktop\app-2.5.3\resources\app\git\node_modules\yarn\bin\yarn.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15) at Function.Module._load (internal/modules/cjs/loader.js:898:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }'
@zedd3v Thanks for the report. This looks like an error with your shell or path settings. Can you list your reproductions steps? What shell are you using in Desktop -- see the Options settings? And share your logs from that day? See the Help menu in Desktop for the logs.
The cygpath program is part of the Git for Windows installation. Please ensure that you have git installed from https://git-scm.com/download/win. In general you should be using the system installed Git (i.e. Git for Windows).
@zedd3v As we have not heard back from you on this issue, we are closing it for now. Should you have any more details or questions, please reach out and we will be happy to help. Thank you.
I believe that the problem is due to the following code from yarn's bootstrap script on Windows:
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
So if yarn is run as part of a git hook, this will be executed in Desktop's own bundled MINGW environment, which (unlike the one bundled with Git for Windows) does not include the cygpath utility.
I believe that the problem is due to the following code from yarn's bootstrap script on Windows:
case `uname` in *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; esacSo if yarn is run as part of a git hook, this will be executed in Desktop's own bundled MINGW environment, which (unlike the one bundled with Git for Windows) does not include the
cygpathutility.
Is there a way to force github desktop to use the Git for Windows version instead?
@tierninho
I have the same issue.
I am using GitHub Desktop with few repositories, but issue appears only on front-end monorepo. We are using husky and yarnhook inside it, so I suppose these may cause this error. Happens on every checkout, push, merge etc. and it's pretty annoying.
We use pnpm to manage our monorepo and this husky config inside package.json:
"husky": {
"hooks": {
"pre-push": "pnpm run prepush",
"post-checkout": "yarnhook",
"post-merge": "yarnhook",
"post-rewrite": "yarnhook"
}
}
OS: Windows 10 GitHub Desktop: version up to 2.6.0 git for Windows: 2.29.2 Using git bash shell Node: 10.23.0 npm: 6.14.8 pnpm: 5.12.0
I also have been having this issue in a number of repositories. Love github desktop for visualizing commits but I have never been able to commit through the GUI.
npm global installs are in my PATH. i.e. yarn can be run in bash
very same error
Commit failed - exit code 1 received, with output: '/c/Users/ryan.guild/AppData/Roaming/npm/yarn: line 5: cygpath: command not found internal/modules/cjs/loader.js:1032 throw err; ^
Error: Cannot find module 'C:\Users\ryan.guild\AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\node_modules\yarn\bin\yarn.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15) at Function.Module._load (internal/modules/cjs/loader.js:898:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }'
OS: Windows 10 GitHub Desktop: version up to 2.6.0 git version: 2.27.0.windows.1 Using git bash shell Node: >=14 npm: 6.14.9 pnpm: ??? - never heard of this
@RyanGuild-TF I was actually able to make this work by manually copying the .../AppData/Roaming/npm/node_modules into the ...AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\ folder. Wish I could figure out a better way to make it work but that is what I had to resort to.
I'm having the same issue with GitHub Desktop, and can confirm @donna-marijne's reply that the issue seems to be with the yarn bootstrap script:
case `uname` in *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; esac
This is only happening in GitHub Desktop's bundled MINGW (but not system Git Bash), and according to @steveward, GitHub Desktop ships with an internal version of Git which, again, seems to not include the cygpath utility.
Removing this case from the script lets the configured hooks run correctly in GitHub Desktop without affecting other terminals (probably).
Looks like either GitHub Desktop's MINGW should include cygpath, or maybe yarn should not rely on this command...
My config:
| OS | Windows 10, 20H2 (build 19042.685) |
| GitHub Desktop | 2.6.1 |
| Git for Windows | 2.29.2.windows.3 |
| node | v15.5.0 |
| npm | 7.3.0 |
| yarn | 1.22.10 (global) / 2.4.0 (project) |
| husky | v4.3.6 |
(using yarn 2 with PnP)
I had this issue using pnpm as the package manager in one of my git repos. I added C:\Program Files\Git\usr\bin which contains cygpath.exe to my PATH environment variable, and that resolved the issue.
I had the same problem and it turns out it was because of a pre-commit script.
In case you're having the same problem, you can either commit from the command line while skipping the pre-commit script
git commit -m "fixed something" --no-verify
or if you don't need the pre-commit script, you can delete the file YourRepository/.git/hooks/pre-commit
I had this issue using
pnpmas the package manager in one of my git repos. I addedC:\Program Files\Git\usr\binwhich containscygpath.exeto myPATHenvironment variable, and that resolved the issue.
This caused me another problem
0 [main] cygpath (6136) C:\Program Files\Git\usr\bin\cygpath.exe: *** fatal error - cygheap base mismatch detected - 0x18034C408/0x180347408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
internal/modules/cjs/loader.js:892
throw err;
^
@RyanGuild-TF I was actually able to make this work by manually copying the .../AppData/Roaming/npm/node_modules into the ...AppData\Local\GitHubDesktop\app-2.6.0\resources\app\git\ folder. Wish I could figure out a better way to make it work but that is what I had to resort to.
This workaround solved for me. Now the pre-commit hook can run yarn
For what it's worth, my current workaround for this is to remove yarn and similar bootstrap scripts from git hooks and use node to execute the scripts directly, e.g.
node ./node_modules/@nrwl/cli/bin/nx.js ...
The issue still reproduces. Version 2.9.4 (x64)
I had this issue using
pnpmas the package manager in one of my git repos. I addedC:\Program Files\Git\usr\binwhich containscygpath.exeto myPATHenvironment variable, and that resolved the issue.
This worked for me with yarn and cygpath.
had this issue using
pnpmas the package manager in one of my git repos. I addedC:\Program Files\Git\usr\binwhich containscygpath.exeto myPATHenvironment variable
This worked for me too, using yarn.
had this issue using
pnpmas the package manager in one of my git repos. I addedC:\Program Files\Git\usr\binwhich containscygpath.exeto myPATHenvironment variableThis worked for me too, using yarn.
This worked for me too. Thanks.
had this issue using
pnpmas the package manager in one of my git repos. I addedC:\Program Files\Git\usr\binwhich containscygpath.exeto myPATHenvironment variableThis worked for me too, using yarn.
This worked for me too. Thanks.
This works for me as well (I had problem with VS2022 husky hooks when commit via GUI, works fine on VS Code terminal). It would be nice to have more "automated" solution, but this will do for the time being.
Thanks for the insight!
This works 100%.
This works, thank you. Remember to restart Git Desktop after adding to path environment variable.