Repository navigation
Closed
Description
Describe the bug
When attempting to commit or push a branch I am given an error about cygpath not being found.
Git For Windows is installed on my system and running the commands manually in a command prompt works fine. GitHub desktop preferences has the shell set to Command Prompt also which I would have thought would solve the issue, but it does not. Changing it to Git Bash also does not appear to have any effect.
Version & OS
Version 2.5.7
Windows 10 Pro - 10.0.18363 Build 18363
Steps to reproduce the behavior
- Make a commit on a project that uses pre-commit hooks using husky.
- Observe the error message
OR
- Create a branch on a project that uses pre-commit hooks using husky
- Push the branch
- Observe the error message
Expected behavior
Should commit and run the pre-commit hooks.
Actual behavior
Throws the following error;
/c/dev/work/SomeProject/node_modules/.bin/npm: line 5: cygpath: command not found
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'C:\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
error: failed to push some refs to 'https://github.com/SomeUser/SomeProject.git'
Logs
2020-11-09T11:33:23.145Z - info: [ui] Executing createCommit: git commit -F - (took 1.401s)
2020-11-09T11:33:23.149Z - error: [ui] `git commit -F -` exited with an unexpected code: 1.
stderr:
husky > pre-commit (node v12.16.1)
/c/dev/work/SomeProject/node_modules/.bin/lint-staged: line 5: cygpath: command not found
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'C:\lint-staged\bin\lint-staged.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Reacted by Victor Cortez, William Intan, n-kulic, Murat Büyükçelebi and Zakher Masri
Metadata
Metadata
Assignees
Labels
No labels
Activity
steveward commentedon Nov 9, 2020
Thanks for the report @owenashurst. This looks similar to #9278.
GitHub Desktop ships with an internal version of Git which we use for all actions inside the app. As such the environment within which your commit hooks execute will likely not exactly match that of your normal environment.
You can take a look at #9351 and see if the workaround in #9351 (comment) is applicable to your situation. One user also had success by changing the husky command from
"pre-commit": "lint-staged"to"pre-commit": "npx lint-staged". I hope that helps!owenashurst commentedon Nov 12, 2020
@steveward Unfortunately neither of those solutions worked in my case. That seems like a different issue possibly?
Could this bug be reopened please since the issue is still on-going?
steveward commentedon Nov 13, 2020
@owenashurst unfortunately this is a specific issue with the configuration of your pre-commit hook script so there isn't much we can do on our end. Did you try running the
git config stash.usebuiltin falsecommand to see if that worked?owenashurst commentedon Nov 14, 2020
vicortez commentedon Dec 21, 2020
(windows 10) I was having the same problem as @owenashurst. Some commands on husky worked, but the vast majority threw errors like the one described here and on #9278. All of them seemed to be because Github Desktop's shell was looking for the commands on the C:\ folder, and with a .js extension, ex if i ran the npm command:
Error: Cannot find module 'C:\npm\bin\npm-cli.js', or the commitlint command:Error: Cannot find module 'C:\@commitlint\cli\cli.js'.I was using husky v4 and this is my husky.config.js file:
module.exports = { hooks: { 'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS', }, }Changing the hook command from
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',to'commit-msg': 'commitlint.cmd -E HUSKY_GIT_PARAMS',fixed the problem for me, but that would probably affect others working on linux, so its not viable in my case.Deleting my husky files in .git/hooks and downgrading to v3 (
npm uninstall husky && npm install --save-dev husky@3) solved the issue for me. Now it sucessfully goes after the correct commitlint cli file in my project's node_modules.Sanitize pre-commit rush invocation
Sanitize pre-commit rush invocation
Sanitize pre-commit rush invocation (#152)
pmachapman commentedon Jun 22, 2021
I fixed this by installing the latest Git for Windows, then copying
C:\Program Files\Git\usr\bin\cygpath.exeto%HOMEPATH%\AppData\Local\GitHubDesktop\app-2.9.0\resources\app\git\usr\bin.Not elegant, but it showed only one command was missing.
longergrass commentedon Jul 13, 2021
@pmachapman Thanks, that worked perfectly!
realdeepak commentedon Jul 14, 2021
@pmachapman it worked. Thanks
radziksh commentedon Aug 17, 2021
I fixed this error by starting GitHub Desktop as administrator. Not sure why, but it worked for me.
04487 commentedon Aug 17, 2021
04487 commentedon Aug 17, 2021
owenashurst commentedon Aug 17, 2021
@pmachapman Thanks! Just tried it then and solved it. Looks like it's missing in the version GitHub desktop ships with.
@steveward Any comments on this?
rnwonder commentedon Apr 5, 2022
@pmachapman Thanks a lot
axelvalles commentedon Dec 8, 2022
@pmachapman it worked. Thanks
1071125093 commentedon Apr 12, 2023
@pmachapman not elegant,but the only way and worked , thanks
Mobbbb commentedon Jul 22, 2024
@pmachapman Nice! It worked. By the way. GitHubDesktop is indeed inferior to Sourcetree.
AndreasOngCWANZ commentedon Aug 11, 2024
Thanks this is working
C:\Program Files\Git\usr\bin\cygpath.exeto%HOMEPATH%\AppData\Local\GitHubDesktop\app-3.4.3\resources\app\git\usr\binNote the App Version folder will be available once you install the new GITHUB desktop