Open piozygmunt opened 2 months ago
+1
I have a similar problem. I use GitKraken which uses WSL to execute its git commands, but I selected the Windows installed Git executable. The following script inside all of the default hook files
#!/usr/bin/env sh
. "${0%/*}/h"
works on my Windows terminal but not through GitKraken because it uses the Windows path separator \
in the file path variable 0
. For example, the path in the script variable will be .husky\_\post-checkout
, and instead of it being modified to .husky\_\h
, it will be .husky\_\post-checkout/h
and fail.
+1 for gitkraken issue
I have issue like this, when I did upgrade from v8 to v9
According to migration guide paths to husky.sh should be removed
v8:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
cd desktop && yarn test
v9:
cd desktop && yarn test
But if remove the path, it works on MAC/Unix, but on Windows I can't commit anymore
error: cannot spawn desktop/.husky/pre-commit: No such file or directory
I have created a PR that fixes the issue on my end: https://github.com/typicode/husky/pull/1402
Thanks for the report.
@hyperupcall do you have any thoughts on this?
I find this behavior surprising as I'm not aware of other Git GUI tools on Windows having this issue?
But if remove path, it works on MAC/Unix, but on windows I can't commit anymore error: cannot spawn desktop/.husky/pre-commit: No such file or directory
I'm facing the exact same issue as @sergei-lobanov mentioned above. I'm using Windows 10.
When I restore these two script lines:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
It works again perfectly as it did, even after keeping the change of "prepare": "husky"
from "prepare": "husky install"
.
Should I update to v9 with these scripts restored? Please advise.
cc @typicode
Any news on this issues?
I have the same problem. It is not working in SourceTree and not in VS Code. When adding the lines back, it works.
Same here on Windows 10 with Webstorm
Hi. After upgrading to version 9 from 8 hooks on windows stopped working. Based on some quick debugging it seems that path to the actual script is not being resolved correctly. To confirm this i echo'ed script path in
h
file:which gives me this output:
Notice that path contains both forward and back slashes and because of that
s="${0%/*/*}/$h"
returns incorrect path. Could it be something with my setup or the regexp needs to be updated ?OS:
Microsoft Windows [Version 10.0.19045.4046]