Skip to content

prek install --install-hooks does not install commit-msg stage git hook? #1762

@JonasCir

Description

@JonasCir

Summary

Hi there,
thank you for creating this project! From the description of prek install --install-hooks ("Create environments for all hooks used in the config file"), I would expect it to setup hooks under .git/hooks/ for the commit-msg stage as well if needed.

Currently, this does not appear to be the case:

I have this prek.toml:

[[repos]]
repo = "https://github.com/commitizen-tools/commitizen"
rev = "v4.13.9"
hooks = [
    { id = "commitizen" }, # commit-msg stage
    { id = "commitizen-branch", stages = [
        "pre-push"
    ] },
]

Reproduction:

  1. prek install --install-hooks -> prek installed at '.git/hooks/pre-commit'
  2. echo "hello world" >> msg.txt
  3. git add msg.txt and git commit -m "hello world commit" -> passes
  4. prek install --hook-type commit-msg -> prek installed at '.git/hooks/commit-msg'
  5. echo "hello world" >> msg_2.txt
  6. git add msg_2.txt and git commit -m "hello world commit#2" -> fails with commitizen as expected

I don't know if the "environments" mentioned in the help text mean something different than stages, but I find this behavior surprising.

Willing to submit a PR?

  • Yes — I’m willing to open a PR to fix this.

Platform

Nix - Prek downloaded from GH realease

Version

prek 0.3.4

.pre-commit-config.yaml

repo = "https://github.com/commitizen-tools/commitizen"
rev = "v4.13.9"
hooks = [
    { id = "commitizen" }, # commit-msg stage
    { id = "commitizen-branch", stages = [
        "pre-push"
    ] },
]

Log file

2026-03-09T16:54:51.701157Z DEBUG prek: 0.3.4
2026-03-09T16:54:51.701178Z DEBUG Args: ["prek", "install", "--install-hooks"]
2026-03-09T16:54:51.701256Z TRACE Executing `/nix/store/8x49w8i0vafv34rlc6h4a0f7z0z2qpb5-git-2.53.0/bin/git config --get core.hooksPath`
2026-03-09T16:54:51.702909Z TRACE get_root: close time.busy=736µs time.idle=1.38µs
2026-03-09T16:54:51.702925Z DEBUG Git root: /home/user/projects/rust/test-project
2026-03-09T16:54:51.702932Z DEBUG Found workspace root at `/home/user/projects/rust/test-project`
2026-03-09T16:54:51.702935Z DEBUG Found project root at ``
2026-03-09T16:54:51.702940Z DEBUG Loading project configuration path=prek.toml
2026-03-09T16:54:51.702984Z TRACE Executing `/nix/store/8x49w8i0vafv34rlc6h4a0f7z0z2qpb5-git-2.53.0/bin/git rev-parse --git-common-dir`
2026-03-09T16:54:51.703713Z TRACE Include selectors: ``
2026-03-09T16:54:51.703720Z TRACE Skip selectors: ``
2026-03-09T16:54:51.703810Z DEBUG Found workspace root at `/home/user/projects/rust/test-project`
2026-03-09T16:54:51.703814Z TRACE Include selectors: ``
2026-03-09T16:54:51.703816Z TRACE Skip selectors: ``
2026-03-09T16:54:51.703892Z DEBUG discover{root="/home/user/projects/rust/test-project" config=None refresh=false}: Cache is too old (5201s > 3600s), invalidating
2026-03-09T16:54:51.703943Z DEBUG discover{root="/home/user/projects/rust/test-project" config=None refresh=false}: Performing fresh workspace discovery
2026-03-09T16:54:51.703954Z TRACE discover{root="/home/user/projects/rust/test-project" config=None refresh=false}:list_submodules{git_root="/home/user/projects/rust/test-project"}: close time.busy=2.17µs time.idle=598ns
2026-03-09T16:54:51.704832Z DEBUG Loading project configuration path=prek.toml
2026-03-09T16:54:51.705972Z TRACE discover{root="/home/user/projects/rust/test-project" config=None refresh=false}: close time.busy=2.15ms time.idle=769ns
2026-03-09T16:54:51.706129Z TRACE Checking lock resource="store" path=/home/user/.cache/prek/.lock
2026-03-09T16:54:51.706141Z DEBUG Acquired lock resource="store"
2026-03-09T16:54:51.706298Z TRACE Skipping pyproject.toml metadata extraction because language_version is already configured hook=commitizen
2026-03-09T16:54:51.706323Z TRACE Skipping pyproject.toml metadata extraction because language_version is already configured hook=commitizen-branch
2026-03-09T16:54:51.706439Z TRACE Executing `/home/user/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/bin/python3.12 -I -c import sys, json
info = {
    "version": ".".join(map(str, sys.version_info[:3])),
    "base_exec_prefix": sys.base_exec_prefix,
}
print(json.dumps(info))
 [...]`
2026-03-09T16:54:51.724762Z DEBUG Found installed environment for hook `commitizen` at `/home/user/.cache/prek/hooks/python-B3BzMRFC7MtGNpsZpVSA`
2026-03-09T16:54:51.724777Z DEBUG Found installed environment for hook `commitizen-branch` at `/home/user/.cache/prek/hooks/python-B3BzMRFC7MtGNpsZpVSA`
2026-03-09T16:54:51.724872Z TRACE Released lock path=/home/user/.cache/prek/.lock

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions