conventional-changelog / standard-version

:trophy: Automate versioning and CHANGELOG generation, with semver.org and conventionalcommits.org
ISC License
7.7k stars 796 forks source link

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

Open lydemann opened 6 years ago

lydemann commented 6 years ago

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.

Cotspheer commented 6 years ago

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!

lmachens commented 6 years ago

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

someoneinatree commented 6 years ago

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

pinich commented 3 years ago

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

ackvf commented 2 years ago

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

🤦‍♂️

initialization commented 2 years ago

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

egarkavy commented 4 days ago

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

husky managed to run pre commit scripts without specifying this line. I have it like that in my newest project. But for some reason when I tried doing the same in one of my old ones I had to put this line you mentioned