husky: Husky(v7) fails when .git/hooks directory is missing
Since v7 , I have an error on docker with node 14.17
yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "@typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning "@wdio/cucumber-framework > @cucumber/cucumber > @cucumber/html-formatter > @cucumber/react > react-markdown@5.0.3" has unmet peer dependency "@types/react@>=16".
[4/4] Building fresh packages...
$ husky install
husky - Git hooks failed to install
spawnSync git ENOENT
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Command failed with exit code 1.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 19
- Comments: 20 (2 by maintainers)
Links to this issue
- chore(deps): update dependency husky to v7 - autoclosed (!39) · Merge requests · René Stalder / Eleventy Kirby CMS Plugin · GitLab
- chore(deps): update dependency husky to v7 - autoclosed (!39) · Merge requests · René Stalder / Eleventy Kirby CMS Plugin · GitLab
- Update dependency husky to v7 (!92) · Merge requests · nano8 / core / httpcode · GitLab
- Update dependency husky to v7 (!118) · Merge requests · nano8 / core / display · GitLab
- Update dependency husky to v7 (!83) · Merge requests · nano8 / core / security · GitLab
- Update dependency husky to v7 (!90) · Merge requests · nano8 / core / config · GitLab
- Update dependency husky to v7 (!105) · Merge requests · nano8 / core / request · GitLab
- Update dependency husky to v7 (!102) · Merge requests · nano8 / core / validate · GitLab
Commits related to this issue
- chore: bump husky to v7.0.1 This fixes the following issue: https://github.com/typicode/husky/issues/1003 — committed to aziiee/ember-uikit by deleted user 3 years ago
- chore: bump husky to v7.0.1 (#744) This fixes the following issue: https://github.com/typicode/husky/issues/1003 Co-authored-by: Akanksh Saxena <akanksh.saxena@adfinis.com> — committed to adfinis/ember-uikit by aziiee 3 years ago
- bump husky to ^7.0.1 to fix build error https://github.com/typicode/husky/issues/1003#issuecomment-874667232 — committed to nhall97/sfdx-monorepo-npm-workspace by nhall97 3 years ago
I’ve published
v7.0.1
. Ifgit
command is not found, husky should not fail anymore.still getting the same issue with
v7.0.1
I’m also seeing this in CI, but builds with Husky 6 seem to handle it gracefully? ↓
Similar to others, but I’m seeing this error instead after upgrading to v7:
This is happening on our CI as well since not all our Docker images there have the
.git
directory. It would be great ifhusky
’s installation steps could handle this gracefully and throw a warning instead instead of failing.Hi team, this still fails for husky 7.0.4
For me the final solution was:
"prepare": "husky install"
with"prepare": "[ -d '.husky' ] && (husky install && shx rm -rf .git/hooks && shx ln -s ../.husky .git/hooks) || true"