cz init raises FileNotFoundError for pre-commit if only prek is installed #2018
Copy link
Copy link
Closed
Labels
issue-status: wait-for-implementationmaintainers agree on the bug / featuremaintainers agree on the bug / featureos: Linuxissues related to linuxissues related to linuxtype: bug
Description
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-commitandprekas 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
issue-status: wait-for-implementationmaintainers agree on the bug / featuremaintainers agree on the bug / featureos: Linuxissues related to linuxissues related to linuxtype: bug
Activity
FanoyG commentedon Aug 5, 2026
I'd like to work on this planning to follow the desired behavior as described (auto-select if only one tool present, prompt if both). Let me know if that matches what maintainers want.
Lee-W commentedon Aug 7, 2026
sounds good
fix(init): use prek when installing hooks if pre-commit is missing
fix(init): use prek when installing hooks if pre-commit is missing