Skip to content

git: 'cz' is not a git command. See 'git --help'. #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martinhbramwell opened this issue Jul 21, 2016 · 12 comments
Closed

git: 'cz' is not a git command. See 'git --help'. #289

martinhbramwell opened this issue Jul 21, 2016 · 12 comments

Comments

@martinhbramwell
Copy link

I don't know how to deal with this.

I assumed it was simply a Path or symlink issue but got no where at all trying to understand how they work between bash, npm, git and commitizen.

install

 you@trykik:~/projects/tryCommitizen$  sudo npm install commitizen -g
 npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
 npm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
 npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
 npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
 npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
 /home/you/.npm/bin/git-cz -> /home/you/.npm/lib/node_modules/commitizen/bin/git-cz
 /home/you/.npm/bin/commitizen -> /home/you/.npm/lib/node_modules/commitizen/bin/commitizen
 /home/you/.npm/lib
 └─┬ commitizen@2.8.2 
   ├─┬ chalk@1.1.3 
   │ ├── ansi-styles@2.2.1 
   │ ├── escape-string-regexp@1.0.5 
   │ ├─┬ has-ansi@2.0.0 

       :

   ├── lodash@4.11.1 
   ├── minimist@1.2.0 
   ├── shelljs@0.5.3 
   └── strip-json-comments@2.0.1 

run

 you@trykik:~/projects/tryCommitizen$ git cz
 git: 'cz' is not a git command. See 'git --help'.

 Did you mean one of these?
      am
      fsck
      gc
      mv
      rm

.profile

 you@trykik:~/projects/tryCommitizen$ cat ~/.profile

       :

 # set PATH so it includes user's private bin if it exists
 if [ -d "$HOME/bin" ] ; then
     PATH="$HOME/bin:$PATH"
 fi

 export PATH=~/npm/bin:$PATH

.npmrc

 you@trykik:~/projects/tryCommitizen$ cat ~/.npmrc 
 ; cli configs
 prefix = "~/.npm"

system

 you@trykik:~/projects/tryCommitizen$ lsb_release -a
 No LSB modules are available.
 Distributor ID:    Ubuntu
 Description:   Ubuntu 16.04.1 LTS
 Release:   16.04
 Codename:  xenial



 you@trykik:~/projects/tryCommitizen$ node --version
 v4.4.7


 you@trykik:~/projects/tryCommitizen$ npm --version
 3.10.3



 you@trykik:~/projects/tryCommitizen$ 

Please let me know if you need more information.

@pmcelhaney
Copy link
Contributor

I'm not an expert on where npm puts things, but something I noticed is you have export PATH=~/npm/bin:$PATH but the symlink was created at /home/you/.npm/bin/git-cz. There's a "." before npm. Try changing that in your .profile file.

If that doesn't work, you might have more luck on superuser.com.

@martinhbramwell
Copy link
Author

That's very astute. Thank you.

I have since killed the VM I was using to try that. I believe ´NodeJS´ and ´npm´ were installed on it using ´apt´.

I am now on a different VM, where I know I installed ´NodeJS´ and ´npm´ with ´nvm´.

Now I have no problem at all.

@LinusU
Copy link
Contributor

LinusU commented Aug 14, 2016

I believe that @pmcelhaney's solution is probably the correct one, please feel free to reopen if you have problems with it...

@LinusU LinusU closed this as completed Aug 14, 2016
@elpddev
Copy link

elpddev commented Sep 15, 2019

I had to install commitizen as global npm package fot git cz to work.

@stavalfi
Copy link

stavalfi commented Apr 2, 2021

this should be documented somewhere.

@ghacosta
Copy link

If you don't want to install commitizen globally you can write the write the hooks as follows:

exec < /dev/tty && node_modules/.bin/cz --hook || true

@jacksparrow1111
Copy link

If you don't want to install commitizen globally you can write the write the hooks as follows:

exec < /dev/tty && node_modules/.bin/cz --hook || true

Can you explain what --hook || true is doing

@Parth909
Copy link

Parth909 commented Dec 19, 2021

First of all install commitizen using the package manager you prefer.
Along with it cz-conventional-changelog will also be added.

There is no need for you to install it globally

Then run

commitizen init cz-conventional-changelog --yarn --dev --exact

commitizen init cz-conventional-changelog --yarn --dev --exact --force :- to forcefully reinitialize

If you get an error that commitizen: command not found then run the binary directly npx commitizen init cz-conventional-changelog --yarn --dev --exact

Then run the binary directly using npx cz

image

@jacksparrow1111
Copy link

First of all install commitizen using the package manager you prefer. Along with it cz-conventional-changelog will also be added.

Then run the binary directly using npx cz

image

Thanks @Parth909 ! It works now

@jacksparrow1111
Copy link

If you don't want to install commitizen globally you can write the write the hooks as follows:

exec < /dev/tty && node_modules/.bin/cz --hook || true

@ghacosta This doesn't work

@anied
Copy link

anied commented Jun 16, 2022

If you don't want to install commitizen globally you can write the write the hooks as follows:

exec < /dev/tty && node_modules/.bin/cz --hook || true

@ghacosta This doesn't work

It worked for me-- OSX, using it for a Husky v8 setup.

beatrizsmerino added a commit to beatrizsmerino/vue-todolist that referenced this issue Aug 16, 2022
- For the husky v.8 not use the `.huskyrc` file for set the configuration.
Set the configuration inside the `.husky` folder, in the individual files as the `commit-msg` hook.
https://typicode.github.io/husky/#/?id=migrate-from-v4-to-v8

Steps:
- Add the next command to the `commit-msg` hook:
`npx --no -- commitlint --edit $1`

Error:
- Error: Cannot find module "@commitlint/config-conventional" from "/Applications/MAMP/htdocs/vue-todolist" at resolveId (/Users/beatrizsmerino/.npm/_npx/16d437951fea4b5e/node_modules/@commitlint/resolve-extends/src/index.ts:131:14)
- ✖   body's lines must not be longer than 100 characters [body-max-line-length]
✖   found 1 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Solution:
- Install locally the packages:
`npm install @commitlint/cli @commitlint/config-conventional --save-dev`
`npm install commitizen cz-conventional-changelog --save-dev`
- Update the configuration `commitlint`, increase the `body-max-line-length`

References:
- https://www.youtube.com/watch?v=jNxDNoYEGVU
- https://www.youtube.com/watch?v=OJqUWvmf4gg
- https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13
- https://github.com/qoomon/git-conventional-commits
- https://remarkablemark.org/blog/2019/05/29/git-husky-commitlint/
- https://typicode.github.io/husky/#/?id=husky_git_params-ie-commitlint-
- https://stackoverflow.com/a/67074398
- https://rahulgurung.com/How-to-use-the-latest-Husky-8-with-Commitizen-for-adding-git-hooks-to-your-projects/
- https://www.techiediaries.com/git-hooks-husky-commitlint/
- https://www.freecodecamp.org/news/how-to-use-commitlint-to-write-good-commit-messages/
- https://medium.com/dottech/mejorando-los-mensajes-de-git-commit-con-husky-y-commitlint-7bddf6ab22c2
- commitizen/cz-cli#289
- https://github.com/conventional-changelog/commitlint
- conventional-changelog/commitlint#613
- https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js
- https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md#body-max-line-length
@shady1440
Copy link

&& node_modules/.bin/cz

you have to make the file executable
chmod +x .husky/prepare-commit-msg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants