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

Husky cannot execute hooks #445

Open
Brolly0204 opened this issue Jan 19, 2019 · 13 comments

Comments

@Brolly0204
Copy link

@Brolly0204 Brolly0204 commented Jan 19, 2019

version

husky: "^1.3.1",
os: Mac
node: v10.7.0

.huskyrc

{
  "hooks": {
    "pre-commit": "npm run lint"
  }
}
@shamatov

This comment has been minimized.

Copy link

@shamatov shamatov commented Jan 28, 2019

Same here.

husky: "^1.3.1"
os: Windows 10
node: v10.15.0

There is no custom hooks that prevents Husky.

@danielhdz56

This comment has been minimized.

Copy link

@danielhdz56 danielhdz56 commented Jan 28, 2019

same here, this is a recurring issue with husky. previous version of husky you could fix this by doing
rm -rf .git/hooks
and then installing husky
npm install -D husky

this doesn't work for me, but maybe it does for y'all.

@tuananh

This comment has been minimized.

Copy link

@tuananh tuananh commented Jan 29, 2019

@danielhdz56 this does fix it for me. thank you!

@vitalii

This comment has been minimized.

Copy link

@vitalii vitalii commented Feb 1, 2019

doesn't work for me

@bmesin

This comment has been minimized.

Copy link

@bmesin bmesin commented Feb 4, 2019

Does not work for me either. Commit and push pass without executing any hooks.

"husky": {
"hooks": {
"pre-commit": "ng lint",
"pre-push": "ng lint && ng build --aot true"
}
},

...

"husky": "^1.3.1",

@vitalii

This comment has been minimized.

Copy link

@vitalii vitalii commented Feb 4, 2019

check .git/hooks
if it's empty try to uninstall husky and install again. my sh history

 ls .git/hooks
 npm uninstall husky
 npm i husky -D
 ls .git/hooks

it helped me

@SammyIsra

This comment has been minimized.

Copy link

@SammyIsra SammyIsra commented Feb 7, 2019

Yup, deleting .git/hooks directory and reinstalling husky did it for me.

Is there any reason why this runs this way? Is there no command that we can run within husky to check and create the hooks?

Do you also have to do the same thing every time you change your hooks? It seems a bit inconvenient if that's the case.

Maybe we can submit an MR to get around the issue?

@radiocity

This comment has been minimized.

Copy link

@radiocity radiocity commented Feb 12, 2019

@shamatov, try to uninstall Windows Subsystem for Linux (WSL) by running lxrun /uninstall /full /y. The problem caused by custom bash executable.

@zhixuanziben

This comment has been minimized.

Copy link

@zhixuanziben zhixuanziben commented Mar 3, 2019

@vitalii It does work for me, Thanks!

@chat-du-cheshire

This comment has been minimized.

Copy link

@chat-du-cheshire chat-du-cheshire commented Mar 6, 2019

Hi, I'm trying to run custom hook from husky. I have package.json file and folder "custom-hooks" where I've my custom pre commit. But config like this

@wataruoguchi

This comment has been minimized.

Copy link

@wataruoguchi wataruoguchi commented May 20, 2019

Hi, I had the same issue. The hooks didn't work. Here's what I did.

Make sure you understand it changes the valid location of hook files. If you're not familiar with this, talk to your peer before you run the commands.

  1. Check where your git hooks are: $ git rev-parse --git-path hooks
  2. Then if it's not .git/hooks, run git config core.hooksPath .git/hooks/ to solve the problem.

It seems like the hooks files are created in .git/hooks/ no matter what the core.hooksPath is.

@403studio

This comment has been minimized.

Copy link

@403studio 403studio commented Jul 29, 2019

first,you shoule check the .git/hooks if there are some hooks,such as pre-commit ,and check its content,if husky is corrected configed,you can see some content
second,if the .git/hook does not has hooks,that means husky isnt take place.you shoule reinstall husky.for me at this moment i find the problem

when i uninstall husky,the terminal show:
Husky requires Git >= 2.13.2, please update Git
so i update my git and reinstall husky, everything is ok

@championchap

This comment has been minimized.

Copy link

@championchap championchap commented Aug 22, 2019

I was installing husky via the official node docker image for 10.16. These are based on Debian, which does not have access to a version of Git as high as is required for Husky to work. I've bashed together a new Dockerfile based off of the Ubuntu images instead to get around this.

It's also worth noting that while running npm install does give the "please update git" message, it doesn't appear to show when using Yarn to install your dependencies. This left me scratching my head for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.