Bryan Lee
Bryan Lee

Reputation: 1107

How do I resolve .husky/_/husky.sh: No such file or directory error?

A project that I'm working on with colleagues uses husky versions ^5.1.0 and I keep getting this error when I'm trying to push my commit.

.husky/_/husky.sh: No such file or directory

How do I resolve this?

I'm currently using git version 2.18.0.

I have referred to https://github.com/typicode/husky/issues/712 and https://github.com/typicode/husky/issues/242 but it didn't help much.

Upvotes: 22

Views: 16194

Answers (5)

rainerhahnekamp
rainerhahnekamp

Reputation: 1136

You might have deleted this file. To re-instantiate it properly, run npx husky install.

It will not just add the husky.sh but also the necessary .gitignore in _.

Upvotes: 1

Bryan Lee
Bryan Lee

Reputation: 1107

I solved the issue by deleting node_modules and running:

yarn install

However, this added .husky/_/husky.sh to the commit, which my colleagues didn't want. To fix this, I updated Git via Homebrew:

brew update && brew upgrade

This updated Git to version 2.30.2, which allowed the nested .gitignore to correctly ignore the .husky/_/husky.sh file.

Upvotes: 12

Taras Shevhyk
Taras Shevhyk

Reputation: 161

You can use this command after remove file: _/husky.sh

git config --unset core.hooksPath

Upvotes: 5

ZEN-Oh-sama
ZEN-Oh-sama

Reputation: 46

If this could help someone who had same issue as me

I had the following code in the .husky/commit-msg

npx --no -- commitlint --edit "${1}"

and just removing the ", it worked for me i.e npx --no -- commitlint --edit ${1}

Upvotes: 0

Roger Barreto
Roger Barreto

Reputation: 2284

In my current scenario I was able to resolve the problem running npx husky-init and discarding all the changes it made to the files.

Upvotes: 7

Related Questions