Description
During cz init, hook installation checks whether pre-commit or prek is available, but always executes pre-commit install. If only prek is installed, detection succeeds but execution fails, resulting in a FileNotFoundError.
Steps to reproduce
- Install commitizen and prek. pre-commit should not be on Path.
- Run
cz init
- Just hit enter on the question
? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) [commit-msg]
- Get
FileNotFoundError: [Errno 2] No such file or directory: 'pre-commit'
Current behavior
In the init function is a check to ensure that a pre-commit tool is available, but it checks for pre-commit and prek, while the install command is invoked with pre-commit.
Desired behavior
- Treat
pre-commit and prek as interchangeable hook installers.
- If only one is installed: use it automatically.
- If both are installed: ask the user to choose.
Screenshots
No response
Environment
Commitizen Version: 4.16.3
Python Version: 3.12.13 (main, Jun 11 2026, 04:55:13) [GCC 14.2.0]
Operating System: Linux
Description
During
cz init, hook installation checks whetherpre-commitorprekis available, but always executespre-commit install. If onlyprekis installed, detection succeeds but execution fails, resulting in aFileNotFoundError.Steps to reproduce
cz init? What types of pre-commit hook you want to install? (Leave blank if you don't want to install) [commit-msg]FileNotFoundError: [Errno 2] No such file or directory: 'pre-commit'Current behavior
In the init function is a check to ensure that a pre-commit tool is available, but it checks for pre-commit and prek, while the install command is invoked with pre-commit.
Desired behavior
pre-commitandprekas interchangeable hook installers.Screenshots
No response
Environment
Commitizen Version: 4.16.3
Python Version: 3.12.13 (main, Jun 11 2026, 04:55:13) [GCC 14.2.0]
Operating System: Linux