-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hooks not working #326
Comments
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 |
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. |
I know that hooks don't work on WebStorm IDE because of the way how WebStorm uses Git |
@ramakrishnasomepalli |
Have you fixed your issue? @ramakrishnasomepalli you've checked the right things... maybe I would check the value of |
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 #!/bin/sh
# husky
# v1.0.0... |
I have the same problem. Hooks do not run. |
@Undistraction you can simply re-run 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 |
@Undistraction thanks for the update, I was running out of ideas 😅 |
@typicode Please find the below log. $ npm i husky@next -D
> husky@1.0.0-rc.13 preuninstall D:\workspace\TW-Workspace\Q2A\svc-q2a-quote-pricecheck\node_modules\husky
> node husky uninstall
husky > uninstalling git hooks
husky > done
> husky@1.0.0-rc.14 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 svc-q2a-quote-pricecheck@1.0.9 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ husky@1.0.0-rc.14
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. |
@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
Is there anyone here who can help me with this problem?? Thanks p.s I want to use |
Hi @MincheolC, can you check that |
I seem to be having the same issue when upgrading from
I noticed that I am no longer getting any My
Not sure what's going on, but I hope this info helps narrow the issue a bit. 😄 EDIT: I also attempted to re-install |
Hi, @typicode I just have thanks~ |
Hi @MincheolC, Yes, they're needed. They should be created automatically for you when you run I'd suggest running |
Hi @jakewies, To confirm that #!/bin/sh
# husky
# v1.0.1 darwin
echo "pre-commit" # should be visible in the console when doing a git commit
... |
@typicode thanks it works well. now~ |
@typicode I'll update that file and see what happens 👍 |
@typicode I updated #!/bin/sh
# husky
# v1.0.1 darwin
echo "pre-commit"
... I added a test file and committed to source. Unfortunately "pre-commit" was not logged to the console when running |
@standayweb AFAICT it doesn't seem to be related to husky. Do you have a |
@typicode The developer who was having this issue is no longer at the company and has reset his laptop |
This was the solution to me after a battle of tries. The current 5.0.9 version did not work to me... |
If you have trouble installing husky@next, try installing version 4 directly: npm install husky@4 --save-dev |
|
Version |
4.3.8 should also work. |
To get husky to work for me, I had to uninstall version 5 of husky and run |
Yes! Apparently version 5 is only available to use in open-source projects! Version 4 is free to use for everyone! Also, I had to |
I solved it simply calling install from husky binary
|
I had to remove husky and then add it again on version 4.3.8 and worked just fine |
It looks like from Husky version 5 onwards you no longer add the husky pre-commit command to the package.json file. I removed the following from package.json
Then ran the following
Hope this helps |
If you've tried everything listed in this issue and still can't get the damn hooks to install while using older versions of husky (I was using
No idea why it wouldn't run for me during installation of the husky package, but that did the trick for me.
Seems pretty brittle, but I guess |
This works for me with the expectation that I had to use yarn to run the lint-staged command for me in pre-commit (since I have not installed lint-staged globally in my laptop):
I also did not have to make the .huskypre-commit executable. In the husky version I installed, it's executable by default. |
None of the above answers were working for me! But something finally solved the problem: There has to be something messed up in .git, but I don't know what it is. Removing .git/hooks was not resolving the problems for me. |
This is bug on the husky side |
Well, I'll be damned. Busted my brain for hours and finally came down this thread enough to read this comment and tried. Everything started working as expected. v4.3.8 |
If you downgrade from a newer version to v4, ensure to run |
and then you can do it success |
Delete project and re-pull remotely |
Thanks for sharing the fix, this is the only version that worked for macos. |
Hii @xenoterracide @aguynamedben @Undistraction @pke @samer-nowrx @sapegin @pke @samer-nowrx Documentation of husky is telling that you automatic configure husky but that is not working correctly. I have figured it out. You neeed unisntall the husky first using command
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm run type-check"
}
"lint-staged": {
"*.@(ts|tsx)": [
"npm run lint",
"npm run format"
]
}
|
What worked for me was:
|
The only thing that helped me out of all the above options! Thanks! |
I found that when |
@kostyanp95 and others in this thread. The problem is likely due to file permissions of your hooks. Please check.
|
I'm going to lock this issue, since it goes back to 2018 and solutions provided at the beginning may not be relevant anymore. I think it can create more confusion and harder to debug to leave multiples issues/versions in a single thread. Feel free to create new issues if needed. Thanks. |
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
The text was updated successfully, but these errors were encountered: