standard-version icon indicating copy to clipboard operation
standard-version copied to clipboard

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

Open lydemann opened this issue 7 years ago • 8 comments
trafficstars

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.

lydemann avatar Jul 08 '18 20:07 lydemann

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!

Cotspheer avatar Jul 19 '18 08:07 Cotspheer

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

lmachens avatar Jul 20 '18 09:07 lmachens

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

someoneinatree avatar Sep 26 '18 10:09 someoneinatree

I had similar issue after installing husky and I have noticed that my pre-commit file had a space between # and !/bin/sh Finally after removing the white space and setting the firest line to #!/bin/sh it worked

pinich avatar Sep 15 '21 07:09 pinich

In my case, I changed #!/bin/bash to #!/bin/sh and the error went away.

🤦‍♂️

ackvf avatar Mar 04 '22 03:03 ackvf

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

the solution is very good

initialization avatar Nov 06 '22 15:11 initialization