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

Closed
Brolly0204 opened this issue Jan 19, 2019 · 25 comments
Closed

Husky cannot execute hooks #445

Brolly0204 opened this issue Jan 19, 2019 · 25 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
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
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
Copy link

@tuananh tuananh commented Jan 29, 2019

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

@vitalii
Copy link

@vitalii vitalii commented Feb 1, 2019

doesn't work for me

@bmesin
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
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
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
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
Copy link

@zhixuanziben zhixuanziben commented Mar 3, 2019

@vitalii It does work for me, Thanks!

@chat-du-cheshire
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
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
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

@erikwatson
Copy link

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

@typicode
Copy link
Owner

@typicode typicode commented Jan 7, 2020

Closing it some fixes have been suggested. Also it's related to a pretty old husky version.

As for Debian, it seems that Debian Buster has now a version of Git without the issue. Even though not ideal for the moment and for people stuck with older versions of Debian, it should hopefully be fixed with time.

Yarn seems to hide console.log messages during install. I don't really know what could be done about that, but I would be scratching my head too.

@typicode typicode closed this Jan 7, 2020
@dboscanv
Copy link

@dboscanv dboscanv commented Jan 13, 2020

In my case, it was my Node version (should be >=10)

@azedine-batouche
Copy link

@azedine-batouche azedine-batouche commented Jan 23, 2020

add your script into package.json like this for instance:
{
"scripts": {

  • "precommit": "npm test",
  • "commitmsg": "commitlint -E GIT_PARAMS"
    },
    and then run this command line:

npx --no-install husky-upgrade

to automatically upgrade your configuration, then try again, it works for me.

@baleksandr48
Copy link

@baleksandr48 baleksandr48 commented Feb 27, 2020

Hej everyone, I tried all above and it hasn't helped me. But I solved the problem by upgrading node&npm.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
--open new terminal--
rm -rf ./node_modules/
npm i husky

I am not sure but maybe first command (sudo npm cache clean -f) would be enough.

@ghost
Copy link

@ghost ghost commented Feb 27, 2020

THIS WORKED!!!!

in the package.json file"

"husky": {
"hooks": {
"pre-commit": "npm test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},

@Arslanmajeed270
Copy link

@Arslanmajeed270 Arslanmajeed270 commented Nov 17, 2020

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.

Thanks it's worked for me.

@MarkoCen
Copy link

@MarkoCen MarkoCen commented Dec 14, 2020

The issue happened with latest node version 15.14.0
By switching to older node version 14.15.1, the issue resolved

@dayvsonsales
Copy link

@dayvsonsales dayvsonsales commented Dec 17, 2020

This problem still occurred with node version v15.3.0

@Naimdasb
Copy link

@Naimdasb Naimdasb commented Dec 21, 2020

Yes I have issues with husky using node v15.3.0

@5bsh
Copy link

@5bsh 5bsh commented Jan 31, 2021

There is also issue with Node v12.16.0. After lots of config changes multiple installation, I decided to update node version and then it works.

@lukemovement
Copy link

@lukemovement lukemovement commented Mar 31, 2021

Still getting the above issue with Windows 10 / Husky 6.0.0

@simo54
Copy link

@simo54 simo54 commented Apr 17, 2021

I am having the same issue but this is how it worked for me without specifying the custom hook inside package.json on React

OS: Windows 10
Node: v14.16.1
husky: ^6.0.0

  1. npm install husky --save-dev
  2. npx husky install
  3. npx husky add .husky/pre-commit "npm run test"
  4. git commit -m"custom message"

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

Successfully merging a pull request may close this issue.

None yet