Skip to content
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

error Command "husky-run" not found. #881

Closed
SeyyedKhandon opened this issue Feb 20, 2021 · 8 comments
Closed

error Command "husky-run" not found. #881

SeyyedKhandon opened this issue Feb 20, 2021 · 8 comments

Comments

@SeyyedKhandon
Copy link

SeyyedKhandon commented Feb 20, 2021

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

@lorisdev
Copy link

@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

@SeyyedKhandon
Copy link
Author

@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😢.

@nicolas-goudry
Copy link

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?

@typicode
Copy link
Owner

Are you using yarn or npm?

@schinery
Copy link

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.

@SeyyedKhandon
Copy link
Author

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.

@typicode
Copy link
Owner

typicode commented Mar 4, 2021

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 typicode closed this as completed Mar 4, 2021
@abubakir1997
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants