Standard-version: error: cannot spawn .git/hooks/pre-commit: No such file or directory on Windows

Created on 8 Jul 2018  路  3Comments  路  Source: conventional-changelog/standard-version

Hi,
I'm using a windows machine.
When I run standard-version I get:
error: cannot spawn .git/hooks/pre-commit: No such file or directory.
.git/hooks/pre-commit exists and it works if I run the standard-version git commit command manually.
In my project I use Husky which makes my pre-commit hook look like this:

#!/bin/sh
# husky
# v1.0.0-rc.2 win32

export HUSKY_GIT_PARAMS="$*"
node ./node_modules/husky/lib/runner/bin `basename "$0"`

Thanks.

Most helpful comment

I got this issue and solved it by putting #!/bin/sh as the first line of the pre-commit file. YMMV

All 3 comments

I have the same issue:

My package.config

{
  "name": "a-project",
  "version": "1.0.0",
  "husky": {
    "hooks": {
      "pre-commit": "npm run validate",
      "commit-msg": "commitlint -e %HUSKY_GIT_PARAMS%"
    }
  },
  "scripts": {
    "validate": "npm run lint",
    "release": "standard-version"
  },
  "devDependencies": {
    "@commitlint/cli": "^7.0.0",
    "@commitlint/config-conventional": "^7.0.1",
    "husky": "^1.0.0-rc.13",
    "standard-version": "^4.4.0"
  }
}

Error

warning: LF will be replaced by CRLF in CHANGELOG.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CHANGELOG.md.
The file will have its original line endings in your working directory.
error: cannot spawn .git/hooks/pre-commit: No such file or directory

Command failed: git commit CHANGELOG.md -m "chore(release): 1.0.1"
warning: LF will be replaced by CRLF in CHANGELOG.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in CHANGELOG.md.
The file will have its original line endings in your working directory.
error: cannot spawn .git/hooks/pre-commit: No such file or directory

Any idea about that? Would be great!

Thank you guys in advance!

Same issue here.
I think it is related to Husky and not standard-version.
There is an open pull request which might solve the issue:
https://github.com/typicode/husky/pull/292

I got this issue and solved it by putting #!/bin/sh as the first line of the pre-commit file. YMMV

Was this page helpful?
0 / 5 - 0 ratings