Repository navigation
fix(hooks): migrate the legacy script in the dir hook_check reads - #4774
Open
danieldutu wants to merge 1 commit into
Open
danieldutu wants to merge 1 commit into
danieldutu wants to merge 1 commit into
Conversation
With CLAUDE_CONFIG_DIR set, `rtk gain` kept printing
`Hook outdated — run `rtk init -g` to update` after the user ran exactly
that command. I reproduced it on develop: with the binary hook registered
and `$CLAUDE_CONFIG_DIR/hooks/rtk-rewrite.sh` present, `rtk init -g
--auto-patch` left the script on disk and the warning up.
The cause is a directory mismatch. `hook_status()` in
src/hooks/init/claude.rs reports Outdated for a leftover script in
`resolve_claude_dir()`, which honours `$CLAUDE_CONFIG_DIR`, while
`migrate_old_hook_script()` in the same file looked only under
`user_dirs::home().join(".claude")` and never saw the file.
I pointed `migrate_old_hook_script()` at `resolve_claude_dir()` so both
paths agree, and moved the Cursor cleanup to its own `home` lookup so it
still runs when no Claude directory resolves. The settings-entry cleanup
already resolved through `resolve_claude_dir()`, so it needed no change.
Before (develop 32b2ec4, fresh HOME, CLAUDE_CONFIG_DIR=/x, LC_ALL=C):
$ rtk init -g --auto-patch
$ rtk gain 2>&1 | grep -i hook
[warn] Hook outdated — run `rtk init -g` to update
$ test -f /x/hooks/rtk-rewrite.sh && echo present
present
After (this patch, same setup):
$ rtk init -g --auto-patch
$ rtk gain 2>&1 | grep -i hook
(no output)
$ test -f /x/hooks/rtk-rewrite.sh && echo present
(no output)
The new tests cover both directories: a leftover script under
$CLAUDE_CONFIG_DIR is removed with its settings entry while the
`rtk hook claude` entry survives, and the `~/.claude` default path still
migrates. Boundaries: the hash-file cleanup follows the resolved
directory too, which is a behaviour change only for a hash file left in
~/.claude while CLAUDE_CONFIG_DIR points elsewhere — that file was
already invisible to hook_status(), so the warning it produced is gone.
Cursor's directory resolution is untouched; macOS is the only platform I
ran the repro on.
Fixes rtk-ai#4757
Signed-off-by: danieldutu <[email protected]>
📊 Automated PR Analysis
SummaryFixes a bug where migrate_old_hook_script() looked for the legacy rtk-rewrite.sh hook script under the fixed ~/.claude path, while hook_status() checked resolve_claude_dir() (which honors CLAUDE_CONFIG_DIR), causing the 'Hook outdated' warning to persist after rtk init -g. The fix points the migration at resolve_claude_dir() and moves Cursor cleanup to its own home-based lookup, plus adds tests covering both the CLAUDE_CONFIG_DIR and default ~/.claude paths. Review Checklist
Linked issues: #4757 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
1 of 2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
CLAUDE_CONFIG_DIRset,rtk gainkept printingHook outdated — runrtk init -gto updateafter the user ran exactly that command. I reproduced it on develop 32b2ec4: with the binary hook registered and$CLAUDE_CONFIG_DIR/hooks/rtk-rewrite.shpresent,rtk init -g --auto-patchleft the script on disk and the warning up.The cause is a directory mismatch.
hook_status()in src/hooks/init/claude.rs reports Outdated for a leftover script inresolve_claude_dir(), which honours$CLAUDE_CONFIG_DIR, whilemigrate_old_hook_script()in the same file looked only underuser_dirs::home().join(".claude")and never saw the file.I pointed
migrate_old_hook_script()atresolve_claude_dir()so both paths agree, and moved the Cursor cleanup to its ownhomelookup so it still runs when no Claude directory resolves. The settings-entry cleanup already resolved throughresolve_claude_dir(), so it needed no change.Test plan
Before (develop 32b2ec4, fresh HOME, CLAUDE_CONFIG_DIR=/x, LC_ALL=C):
After (this patch, same setup):
$ rtk init -g --auto-patch
$ rtk gain 2>&1 | grep -i hook
(no output)
$ test -f /x/hooks/rtk-rewrite.sh && echo present
(no output)
The new tests cover both directories: a leftover script under $CLAUDE_CONFIG_DIR is removed with its settings entry while the
rtk hook claudeentry survives, and the~/.claudedefault path still migrates. Boundaries: the hash-file cleanup follows the resolved directory too, which is a behaviour change only for a hash file left in ~/.claude while CLAUDE_CONFIG_DIR points elsewhere — that file was already invisible to hook_status(), so the warning it produced is gone. Cursor's directory resolution is untouched; macOS is the only platform I ran the repro on.Fixes #4757