Skip to content

fix(hooks): recognize absolute-path rtk hook claude in settings.json#2901

Open
syf2211 wants to merge 1 commit into
rtk-ai:developfrom
syf2211:fix/hook-detection-absolute-path
Open

fix(hooks): recognize absolute-path rtk hook claude in settings.json#2901
syf2211 wants to merge 1 commit into
rtk-ai:developfrom
syf2211:fix/hook-detection-absolute-path

Conversation

@syf2211

@syf2211 syf2211 commented Jul 9, 2026

Copy link
Copy Markdown

Summary

  • Add claude_hook_command_matches() so hook detection recognizes absolute-path commands like /opt/homebrew/bin/rtk hook claude
  • Use the helper in hook_check::binary_hook_registered and init::hook_already_present

Fixes #2884

Motivation

Users on macOS often configure Claude Code hooks with an absolute path to rtk because hook commands run under /bin/sh without Homebrew on PATH. rtk gain and rtk init -g incorrectly warned "No hook installed" even when the hook was active and tracking commands.

Changes

  • src/hooks/hook_check.rs: new matcher + unit test; binary_hook_registered delegates to it
  • src/hooks/init.rs: hook_already_present uses the shared matcher

Tests

  • cargo fmt --all && cargo clippy --all-targets — passed
  • cargo test hooks::hook_check — passed (14 tests)
  • composer-2.5 review: APPROVE

Notes

Uninstall path (remove_hook_from_json) still uses exact matching for removal; detection is fixed here. A follow-up could reuse the helper for uninstall symmetry.

Hook detection previously required an exact match on "rtk hook claude",
so settings.json entries like "/opt/homebrew/bin/rtk hook claude" were
reported as missing even when the hook was active.

Fixes rtk-ai#2884
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@syf2211

syf2211 commented Jul 9, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@syf2211

syf2211 commented Jul 9, 2026

Copy link
Copy Markdown
Author

recheck

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Hook detection reports 'No hook installed' when settings.json uses an absolute path to rtk

2 participants