Skip to content

fix: augment PATH in hook to fix silent failure on Homebrew installs (#685)#1117

Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/issue-685
Open

fix: augment PATH in hook to fix silent failure on Homebrew installs (#685)#1117
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes:fix/issue-685

Conversation

@ousamabenyounes
Copy link
Copy Markdown
Contributor

@ousamabenyounes ousamabenyounes commented Apr 9, 2026

Summary

Fixes #685

  • Claude Code hooks run with a restricted PATH that excludes Homebrew (/opt/homebrew/bin on Apple Silicon, /usr/local/bin on Intel) and cargo (~/.cargo/bin) directories
  • command -v rtk silently returns non-zero, causing the hook to print a warning and exit — no commands are rewritten, token savings are lost silently
  • Fix adds export PATH="$HOME/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" at the top of the hook, before the command -v rtk guard
  • Hook version bumped from 3 → 4; existing installations will be upgraded on the next rtk init -g

Verification

  • Baseline tests: 1351 pass, 6 ignored, 0 pre-existing failures
  • Post-fix tests: no regressions
  • New test: test_hook_augments_path_before_rtk_check — asserts PATH export exists and precedes the rtk guard, and that /opt/homebrew/bin and .cargo/bin are covered
  • Review agent: issue alignment verified

Files changed

File Change
hooks/claude/rtk-rewrite.sh Bump version 3→4, add PATH augmentation (6 lines)
src/hooks/hook_check.rs Update CURRENT_HOOK_VERSION constant to 4
src/hooks/init.rs Add test_hook_augments_path_before_rtk_check test

Generated by Claude Code
Vibe coded by ousamabenyounes


Vibe Coded by Ousama Ben Younes
Developed With Ora Studio (Claude Code)

@ousamabenyounes ousamabenyounes changed the base branch from master to develop April 10, 2026 08:51
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 10, 2026

CLA assistant check
All committers have signed the CLA.

…tk-ai#685)

Claude Code runs hooks with a restricted PATH that excludes Homebrew
(/opt/homebrew/bin) and cargo (~/.cargo/bin) directories. `command -v rtk`
silently failed, causing the hook to exit early without rewriting any commands.

Add `export PATH="$HOME/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"` at
the top of the hook script (before the rtk guard) and bump hook version to 4 so
existing installations are upgraded on the next `rtk init -g`.

Generated by Claude Code
Vibe coded by ousamabenyounes

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Hook silently fails when rtk not in Claude Code's restricted PATH (Homebrew installs)

2 participants