Skip to content

doctor reports a working PreToolUse hook as broken: it probes a synthesised scripts/commitlore-run.sh path instead of the configured command #149

Description

@MongLong0214

doctor fails the PreToolUse check against a path that appears in no settings file, and the hook it should have tested works.

What happens

On a compiled-binary install (commitlore 0.2.1 at ~/.local/bin/commitlore), run from a repository root that has the hook configured:

$ commitlore doctor > out.txt 2>&1
$ echo "exit=$?"
exit=1
$ grep '^fail' out.txt
fail    PreToolUse hook runtime — the PreToolUse hook exits 127: /bin/bash: /Users/isaac/.local/bin/scripts/commitlore-run.sh: No such file or directory
        fix: commitlore inject install-claude-hook

Every other check in the same run is ok, including cli runtime, commit-msg hook, hook runtime and index health.

Why it is wrong

  1. scripts/commitlore-run.sh does not exist anywhere under the install prefix:

    $ find ~/.local -name 'commitlore-run.sh'    # no output
    $ ls -d ~/.local/bin/scripts
    ls: /Users/isaac/.local/bin/scripts: No such file or directory
    

    The reported path looks like dirname(argv[0]) + "/scripts/commitlore-run.sh", which only resolves in a source checkout, not for a binary installed into a bin directory.

  2. That path is not what is configured. The project's .claude/settings.json holds:

    { "matcher": "Read|Edit|Write",
      "hooks": [ { "type": "command",
                   "command": "commitlore inject --hook-input # commitlore-inject-hook" } ] }

    commitlore-run appears in no settings file — not .claude/settings.json, not .claude/settings.local.json, not ~/.claude/settings.json, not ~/.claude.json.

  3. The configured hook works. Feeding it a real PreToolUse payload:

    $ echo '{"tool_name":"Read","tool_input":{"file_path":".../Package.swift"}}' \
        | commitlore inject --hook-input > hookout.json 2>&1
    $ echo "exit=$?"
    exit=0
    $ head -c 120 hookout.json
    {"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"commitlore: active records for Package.swift
    

So doctor reports a working hook as broken, and the offered fix: would rewrite a hook that is already correct.

Impact

doctor exits 1, which makes it unusable as a CI or pre-flight gate for any binary install: the one failing check is a false negative that cannot be cleared by fixing anything real. It also mislabels the failure — "the PreToolUse hook exits 127" asserts something about the configured hook, when what exited 127 is a path doctor constructed itself.

Suggested direction

Test what is configured, not a synthesised path: read the PreToolUse entries out of the settings files doctor already locates, and execute the command string it finds there. If no entry is found, the existing warn ... not installed result is already the right answer — that is what the same version reports from a directory with no .claude/settings.json.

Separately, the check is cwd-sensitive in a way worth documenting: from a directory without .claude/settings.json the same binary reports warn PreToolUse hook runtime — not installed in <cwd>/.claude/settings.json and exits 0.

Environment

commitlore 0.2.1, compiled binary, macOS 15.3 (arm64), git 2.50.1 (Apple Git-155).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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