Skip to content

doctor prescribes 'commitlore hooks install' for a stale commitlore.bin, but that command cannot repair it #296

Description

@MongLong0214

Summary

doctor correctly detects that the commit-msg hook fails under a restricted PATH, and prescribes commitlore hooks install as the fix. That command cannot repair this failure: it short-circuits on "already installed (unchanged)" and never re-resolves the stale commitlore.bin that is the actual cause. --force behaves identically.

The result is a fail a user cannot clear by following the printed instruction.

Environment

  • commitlore 0.4.1 (/Users/isaac/.local/bin/commitlore, compiled binary)
  • Node v24.18.0, git 2.50.1 (Apple Git-155), macOS 26.3
  • Repository already had a commit-msg hook and the PreToolUse inject hook installed from an earlier version

Reproduction

Local config in the affected repository:

$ git config --get commitlore.bin
/Users/isaac/projects/logic-pro-mcp/commitlore     <- does not exist
$ git config --get commitlore.node
/Users/isaac/.local/bin/commitlore                 <- correct

commitlore.bin points at <repo-root>/commitlore, a path that has never existed in this repository.

$ commitlore init --verbose
[1/4] hooks install
        commit-msg hook already installed: .../.git/hooks/commit-msg (unchanged)
...
[4/4] doctor --fix (final check)
        fail    commit-msg hook — ... commitlore.bin: /Users/isaac/projects/logic-pro-mcp/commitlore; commitlore.node: /Users/isaac/.local/bin/commitlore; outcome: the hook exited 1 under the restricted PATH — cause unclear: commitlore: cannot find the CLI this hook was installed with.
                fix: commitlore hooks install
        fail    hook runtime — the hook exited 1 under the restricted PATH — cause unclear: ...
                fix: commitlore hooks install

Following the prescribed fix:

$ commitlore hooks install
commit-msg hook already installed: .../.git/hooks/commit-msg (unchanged)
$ git config --get commitlore.bin
/Users/isaac/projects/logic-pro-mcp/commitlore     <- unchanged

$ commitlore hooks install --force
commit-msg hook already installed: .../.git/hooks/commit-msg (unchanged)
$ git config --get commitlore.bin
/Users/isaac/projects/logic-pro-mcp/commitlore     <- still unchanged

Direct hook invocation under the restricted PATH doctor uses:

$ env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME="$HOME" sh .git/hooks/commit-msg /tmp/msg
commitlore: cannot find the CLI this hook was installed with.
  set COMMITLORE_BIN, or re-run: <path-to>/commitlore hooks install

The hook's own remediation hint points at the same command that does not repair it.

.git/hooks/commit-msg:49 reads commitlore.bin first and only falls back to commitlore.node inside the branch at :60; with a stale-but-present commitlore.bin the resolution ends at :110.

Workaround

Repointing the config by hand clears both failures:

$ git config --local commitlore.bin /Users/isaac/.local/bin/commitlore
$ env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin HOME="$HOME" sh .git/hooks/commit-msg /tmp/msg
shape ok · references ok
$ commitlore doctor
ok      commit-msg hook — ... commitlore.bin: /Users/isaac/.local/bin/commitlore; ...
ok      hook runtime — the hook runs and validates without node on PATH

Suggested fixes

Any one of these would close it; the first two seem closest to the project's stated principle that a step it could not complete is named rather than absorbed:

  1. hooks install re-validates commitlore.bin even when the hook file is unchanged, and repairs it when the recorded path is not executable — "already installed" describes the hook file, not the config it depends on.
  2. doctor --fix repairs a stale commitlore.bin directly, since it is the check that already resolved both paths and knows one of them is dead.
  3. The hook falls through to commitlore.node when commitlore.bin does not resolve, rather than terminating — the correct path was recorded and available the whole time.

Happy to test a patch against this repository; it reproduces deterministically here.

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