Skip to content

With CLAUDE_CONFIG_DIR set, rtk init -g leaves the legacy hook script and "Hook outdated" never clears #4757

Open

Description

@KuSh

With CLAUDE_CONFIG_DIR set, rtk init -g does not remove a leftover legacy rtk-rewrite.sh from that directory, so rtk gain and the daily reminder keep printing Hook outdated — run rtk init -g to update after the user runs exactly that.

hook_check::status() reads the hook from resolve_claude_dir(), which honours CLAUDE_CONFIG_DIR. migrate_old_hook_script() (src/hooks/init/claude.rs) looks for the legacy script only under user_dirs::home().join(".claude"). With the binary hook registered and $CLAUDE_CONFIG_DIR/hooks/rtk-rewrite.sh still present, status is Outdated, and the migration never sees the file that causes it.

Repro, LC_ALL=C, fresh HOME, CLAUDE_CONFIG_DIR=/x:

/x/settings.json            = {"hooks":{"PreToolUse":[{"matcher":"Bash","hooks":[{"type":"command","command":"rtk hook claude"}]}]}}
/x/hooks/rtk-rewrite.sh     = #!/bin/bash\n# rtk-hook-version: 4
$ rtk gain                  -> [warn] Hook outdated — run `rtk init -g` to update
$ rtk init -g --auto-patch
$ rtk gain                  -> [warn] Hook outdated — run `rtk init -g` to update
/x/hooks/rtk-rewrite.sh still present

Same on v1.0.1 and on develop 2dabd83. A fix passes when, after rtk init -g with CLAUDE_CONFIG_DIR set, the script under that directory and its settings entry are gone and rtk gain no longer warns, and the ~/.claude case keeps working as today.

Activity

  1. added
    bug
    good first issue
    on Oct 23, 2026
  2. rtk-wshm-sync-bot commented on Oct 23, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 93%

    Summary

    migrate_old_hook_script() hardcodes ~/.claude instead of resolve_claude_dir(), so legacy rtk-rewrite.sh under CLAUDE_CONFIG_DIR is never removed and 'Hook outdated' persists after rtk init -g.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/hooks/init/claude.rs

    Suggested Actions

    1. In src/hooks/init/claude.rs, make migrate_old_hook_script() use resolve_claude_dir() instead of home().join(".claude")
    2. Add regression test with CLAUDE_CONFIG_DIR set and a stale hooks/rtk-rewrite.sh present
    3. Verify hook_check::status() reflects removal after fix so rtk gain stops warning
    4. Cross-check False "No hook installed" for Copilot and for project-scope Codex and Droid installs #4756 (false hook-detection issues) for shared root cause in path resolution

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. KuSh commented on Oct 31, 2026

    @KuSh
    CollaboratorAuthor

    There are 2 open pull requests for this issue: #4774, #4798 (oldest first).

    If you were about to start on it, reviewing or testing one of these helps more than another pull request: a note on which approach fits, or a test result on your setup, is welcome on the pull request itself.

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

    area:clibuggood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions