Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

How to make Husky run git hook?

+4
−0

How to make Husky run git hook? I have a working git hook, prepare-commit-message, but the moment Husky was installed, the hook stopped working.

Not finding much luck, I then tried to make it a "Husky git hook" and run it like that, so I installed it via npx husky add prepare-commit-message content, but this did not help.

Summary of the situation:

  1. git hook on it's own - works
  2. two other husky git hooks - work on their own (pre-commit, pre-push)
  3. git config -e and hooksPath set as .husky
  4. my script as a husky hook, installed like above - makes commit-related two Husky hooks no longer work. git commit never happens, instead pre-commit hook fails with a message that

.husky/pre-commit: 2: .: cannot open .husky/husky.sh: No such file

or, if I move pre-commit one out:

.husky/prepare-commit-msg: 8: .: cannot open .husky/_/husky.sh: No such file

However, interestingly, if I REMOVE the config bit about .husky dir, git commit opens normally, but without what I'd expect from prepare-commit-message.

At this point I'm kind of stumped, so any help is welcome.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+4
−0

Breakthrough, I found it, mere minutes after posting here. A workaround more than an answer, but it gets the script working.

  1. Reading up on husky.sh I decided that I don't have it and I don't want it (need to push the work forward). How did this work before though? Why could I push, commit, see Husky's messages?
  2. So, I have a workaround! A) Comment out the line . "$(dirname -- "$0")/_/husky.sh". B) Add the same script to .git/hooks.

Made it run now with those two steps. And I'm now thinking that perhaps I botched Husky install somehow. Will probably reinstall and see then, but for now, have spent already hours on it, so need to do something. :-)

I'm still looking for better answers, or comments.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »