husky: Disabling hooks on CI doesn't work anymore with Husky 4.3.4 on Jenkins

Even when setting the env var HUSKY=0 in the CI, Husky still tries to set up git hooks.

Step 4/17 : ENV HUSKY=0

> husky@4.3.4 install /app/node_modules/husky
> node husky install

husky > Setting up git hooks
fatal: not a git repository (or any of the parent directories): .git
husky > Failed to install

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 15 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I too am seeing this problem in my CI system with version 6.0.0

I am using v6 and using HUSKY=0 doesn’t work.

Did the env name got changed again?

HUSKY=0 is for v5. Please try HUSKY_SKIP_INSTALL=1 for husky v4.

Resolved with the following in our package.json:

  "scripts": {
   ...
    "prepare": "if [ -z \"$AN_ENV_VAR\" ]; then husky install ; fi"
  },

AN_ENV_VAR is an ENVin our Dockerfile that always has a value assigned

Thanks.

@wojtekKrol See https://github.com/typicode/husky/issues/822. 4.3.5 should resolve this. ^4.3.0 will resolve to any version that is “compatible with” 4.3.0, which would have included the broken build, 4.3.4 any time you re-installed. It’s for this reason that it’s generally recommended to pin your dependencies to a specific version, such as "husky": "4.3.0" (no ^) to prevent unforeseen issues.

HUSKY_SKIP_INSTALL=1 solves the issue but I don’t think it’s a great solution. We could instead try/catch the installation of husky, what do you think ? @typicode