Closed zeitamin closed 2 years ago
Hi @zeitamin,
what do you get if you manually run $ yarn run --silent husky-run pre-commit
in projectb
?
Hey, @typicode... I'm having the same error, just to add something to the discussion, running the command you asked, I receive the following error:
/usr/bin/bash: C:UsersdouglDocumentsProjectsSomeProjectnode_modules.binhusky-run: command not found
What I've tried:
.git/hooks
folder and create it againUsing with Windows 10 Husky version: "husky": "^4.2.5"
I've tested with version 3 and it is running fine without it. I'll try to track the version that it started.
Alright, it looks like it was introduced on 4.0.0-beta.0. Strangely, if I run yarn run --silent husky-run pre-commit
it throws the same error, even in 3.1.0 which is the one that works. But committing by using VSCode works fine.
Have the same issue after migration to yarn (v1.22)
Using with Windows 7 Husky version: "husky": "^4.2.5"
I have the same error on Win10. Here's the log from running HUSKY_DEBUG=1 git commit -m test
:
husky:debug husky v4.0.10 (created at 8/6/2020, 10:51:00 PM)
husky:debug pre-commit hook started
husky:debug Current working directory is PROJECT_PATH
husky:debug pre-commit hook started
husky:debug npx --no-install husky-run exited with 0 exit code
husky:debug husky v4.0.10 (created at 8/6/2020, 10:51:00 PM)
husky:debug prepare-commit-msg hook started
husky:debug Current working directory is PROJECT_PATH
husky:debug prepare-commit-msg hook started
husky:debug npx --no-install husky-run exited with 0 exit code
husky:debug husky v4.0.10 (created at 8/6/2020, 10:51:00 PM)
husky:debug commit-msg hook started
husky:debug Current working directory is PROJECT_PATH
husky:debug commit-msg hook started
husky:debug npx --no-install husky-run exited with 0 exit code
husky:debug husky v4.0.10 (created at 8/6/2020, 10:51:00 PM)
husky:debug post-commit hook started
husky:debug Current working directory is PROJECT_PATH
husky:debug post-commit hook started
husky:debug npx --no-install husky-run exited with 0 exit code
[development 7ee9b6f] test
1 file changed, 1 insertion(+), 1 deletion(-)
The change was in package.json
file:
"pre-commit": "echo \"this should fail\" && exit 1"
I had the same problem on Win10 / git 2.27 / yarn 1.22.4 / husky 4.2.5 and found a solution that permits to run husky-run :
npm config set script-shell "C:\\Windows\\System32\\cmd.exe"
It's possible to use it with "C:\\Windows\\SysWOW64\\cmd.exe"
or "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe"
because the problem is with bash.exe
which doesn't accept backslash path.
Don't hesitate to execute npm config get script-shell
before to know your previous script-shell (maybe null).
On my side, using cmd.exe
or powershell.exe
cause another problem with NODE_ENV so I need to juggle ...
Hope backslash path will be corrected and replaced by slash path as soon as possible !
Removing .git/hooks
folder and then running npm rebuild
worked for me
This is an issue of Yarn (https://github.com/yarnpkg/yarn/issues/8340). See how to fix it: https://github.com/typicode/husky/issues/749#issuecomment-691531840
Yep, using npm instead of yarn solved the issue.
@douglas-pires Yes, that's a temporary fix. Given npx
runner is shipped with node.js
, that should always work.
npm rebuild
worked for me
Thank you!
The latest npm release appears to have broken this again. npm rebuild
did not work. npx
also doesn't work with the latest default 7.5.2 release of npm.
Having the same issue as @robross0606 but with npm v7.5.3 and on Linux.
Having the same issue with npm v7.5.3 on Windows too
I had this issue on WSL 2. After few hours of seeking answer I've decided to downgrade version from 5.0.9
to 4.3.8
(latest of 4.*
) - and it's resolved my problem. Now I can add hooks.
Same here with WSL2
In my case the latest version (5.x) of Husky on Windows 10 was the problem
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
not stale
I'm running Husky v.7.04 on a WSL 2 machine and I don't seem to be having an issue. However, I'd like to know if there are still issue with using Husky on a Windows machine. Has there been any update to fix the previous issues?
@CasuallyCaffeinated the only known issue is https://typicode.github.io/husky/#/?id=yarn-on-windows (it may have been fixed since).
Otherwise no particular issue.
To avoid confusions, I'm going to lock this issue as it's an old one and concerns husky 4 which works quite differently than husky 7.
Feel free to create a new issue if needed :)
as a windows user I have a hard time to configure it to work, the hooks works on WSL, but not in git bash nor in Powershell.
this is the command I ran
the output: