Hooks not working
I have set up husky commit hooks to run on commit and push, it works for me and another dev, but for one dev the commit hooks do not get run. Not sure what the issue is here
I have the same issue... I don't know why but it seems that husky don't install correctly git hooks
Same here
I was experiencing this with a pre-push hook until I saw this other ticket in which somebody mentioned needing to use version 1.0.0-rc.13, then it worked.
Unfortunately, we are already using 1.0.0-rc.13 but thanks for the suggestion
I have the same issue i tried both the versions (1.0.0-rc.13 and the stable 0.14.3 ) but no hook (pre-commit,post-push ..etc) is triggering . I verified the hooks folder and all the respective scripts are available and husk is also installed as expected. I also verified the " npm config get ignore-scripts" and the flag is set to false. Any suggestion how to make it work.
I know that hooks don't work on WebStorm IDE because of the way how WebStorm uses Git
@ramakrishnasomepalli hello i met the same problem.And i find that the husky must install after git init . When installed it will show setting up git hooks ~
Have you fixed your issue?
Are you getting any output from husky when running npm install husky@next -D or when commiting/pushing with Git? Also which Git client or IDE are you using?
@ramakrishnasomepalli you've checked the right things... maybe I would check the value of git config core.hooksPath
I am still facing the error but the same configurations are working fine in another machine.
@typicode When i am committing i am not getting any logs related to husk.
@ramakrishnasomepalli when running git config core.hooksPath what do you get? When checking .git/hooks/pre-commit (or the failing hook) does it start with:
#!/bin/sh
# husky
# v1.0.0...
I have the same problem. Hooks do not run. git config core.hooksPath returns nothing. I can't see anything in the docs. Does Husky expose a command to install the hooks if they fail on install?
@Undistraction you can simply re-run npm install husky@next --save-dev
If it shows something different than the outpout below, could you copy/pate it here please?
husky > setting up git hooks
husky > done
@typicode I found the problem. Husky is a dependency of another package. It seems that even though it is installed when I install that package, it doesn't set up the git hooks. This only happens when I install explicitly using npm i husky@next -D.
@Undistraction thanks for the update, I was running out of ideas 😅
@typicode Please find the below log.
$ npm i husky@next -D
> [email protected] preuninstall D:\workspace\TW-Workspace\Q2A\svc-q2a-quote-pricecheck\node_modules\husky
> node husky uninstall
husky > uninstalling git hooks
husky > done
> [email protected] install D:\workspace\TW-Workspace\Q2A\svc-q2a-quote-pricecheck\node_modules\husky
> node husky install
husky > setting up git hooks
husky > done
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ [email protected]
added 2 packages and updated 1 package in 203.131s.
And it is still not working also as suggested by @Undistraction I have noticed the below packages are missing from being installed under nodule modules of husky but the same are available under my project node modules. "cosmiconfig": "^5.0.6","get-stdin": "^6.0.0","please-upgrade-node": "^3.1.1","run-node": "^1.0.0",
@typicode Thanks for all your help. Can you confirm that husky should install hooks if installed via the dependency of another package?
For example if my project installed a package called 'alpha' and that package has a dependency on 'husky', should husky install the githooks for my project? Or will this only happen if husky is installed directly in the project?
The developer who was having this issue is no longer at the company and has reset his laptop, I'll leave this open though as other people seem to be having the issue.
Hi, I encounter with similar issue. I'm using husky v1.0.0-rc.14 and package.json as follow.
"husky": {
"hooks": {
"pre-push": "npm test"
}
}
pre-push hook doesn't not working, but pre-commit work fine as follow
"husky": {
"hooks": {
"pre-commit": "npm test"
}
}
Is there anyone here who can help me with this problem?? Thanks
p.s I want to use pre-push for unit test and pre-commit for lint.
Hi @MincheolC, can you check that .git/hooks/pre-commit and .git/hooks/pre-push have the same content?