husky icon indicating copy to clipboard operation
husky copied to clipboard

error Command "husky-run" not found.

Open SeyyedKhandon opened this issue 5 years ago • 8 comments

I've faced an issue with husky which prevents me from committing, It's kind of confusing because it was working before that, but now, I'm getting an error which says error Command "husky-run" not found.

I've checked it and it was in package.json and also I upgraded it and removed and installed it again, but it doesn't fix that, image How can we fix it? (someone on stackoverflow said we should remove git hooks and so on, which seems not a very good solution).

this is my pre-commit: image

SeyyedKhandon avatar Feb 20 '21 04:02 SeyyedKhandon

@SeyyedKhandon The API changed a lot from v4 to v5. Downgrade to v4 and your issue should be fixed or look at the migration guide https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v5

lorisdev avatar Feb 20 '21 17:02 lorisdev

@SeyyedKhandon The API changed a lot from v4 to v5. Downgrade to v4 and your issue should be fixed or look at the migration guide https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v5

I had the problem with v4 which made me think it may be fixed with the upgrade to v5, which it didn't😢.

SeyyedKhandon avatar Feb 21 '21 05:02 SeyyedKhandon

A few action to take in order to narrow the problem source:

  • place an echo "pre-commit hook" in pre-commit file
  • try to run it directly from shell
  • check if there is any relics from v4 in .git/hooks and delete them (you can keep everything else)

Could you please tell us if you are committing from your terminal or from a GUI app (if so, which one)?

So far, your pre-commit file is empty, is it normal?

nicolas-goudry avatar Feb 21 '21 08:02 nicolas-goudry

Are you using yarn or npm?

typicode avatar Feb 21 '21 23:02 typicode

I had this issue when Dependabot bumped Husky to v5. To resolve I did the following:

  • Renamed the Husky git hooks found in .git/hooks of my repo to *.bak
  • Ran yarn husky init which created a new .husky directory in the root with a pre-commit hook that runs npm test (which can be changed to whatever you wanna run)

This worked for me, and I then cleaned the old Husky git hooks out once I was sure everything was good.

schinery avatar Feb 27 '21 08:02 schinery

After struggling with this issue, I ended up with a new clone of my project and use yarn again to fix this issue by renewing husky.

SeyyedKhandon avatar Feb 28 '21 04:02 SeyyedKhandon

Yarn doesn't seem to run husky's uninstall script when upgrading husky, which leaves some files in .git/hooks.

Two ways to fix that:

  • Check that you don't have anything personal in .git/hooks (this should be the case for most people) and delete .git/hooks.
  • šŸ‘‰ Use @schinery solution and run yarn husky init (recommended) (you can still remove everything in .git/hooks, if you want to clean any artifact lefts by husky v4 :)

typicode avatar Mar 04 '21 03:03 typicode

for husky version 6 run yarn husky install (@typicode solution)

abubakir1997 avatar Apr 01 '21 21:04 abubakir1997