Problem
When RTK is installed via Homebrew, the rtk-rewrite.sh hook silently stops working because Claude Code runs hooks with a restricted PATH that does not include /opt/homebrew/bin.
The hook does:
if ! command -v rtk &>/dev/null; then
exit 0 # silent failure — no rewrite happens, no warning
fi
This means all Bash commands pass through unmodified with zero indication anything is wrong. rtk gain still works fine from the terminal (because the user's shell has Homebrew in PATH), so the breakage is invisible.
How it breaks
- User installs RTK via
cargo install rtk → binary at ~/.cargo/bin/rtk
- Hook works (cargo bin may be in PATH, or user never notices)
- User switches to
brew install rtk → binary moves to /opt/homebrew/bin/rtk
- Hook silently fails —
command -v rtk returns nothing in Claude Code's hook environment
rtk gain --history stops updating, but user assumes hook is fine
Verification
You can reproduce by running the hook with a clean environment:
env -i HOME="$HOME" echo '{"tool_input":{"command":"git status"}}' | env -i HOME="$HOME" bash ~/.claude/hooks/rtk-rewrite.sh
# Output: (nothing) — exits 0 silently, no rewrite
Root cause
rtk init -g installs a hook that uses rtk by name and relies on it being in PATH. But Claude Code's hook subprocess does not inherit the user's full shell PATH (no Homebrew, no cargo, etc. on macOS).
Suggested fixes
Option A (best): rtk init -g should inject the absolute path to the current binary into the hook at install time:
# Generated by rtk init -g
RTK_BIN="/opt/homebrew/bin/rtk" # resolved at install time
Option B: The hook should probe known install locations as fallback:
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.cargo/bin:$PATH"
Option C: Emit a visible warning (not just exit 0) when rtk is not found — at minimum >&2 echo "[rtk] WARNING: rtk not found in PATH, hook disabled" so users know something is wrong.
Note: Option C has already been partially addressed (warnings added to the hook), but the silent failure on Homebrew installs is the main UX problem.
Environment
- macOS (Apple Silicon) — Homebrew installs to
/opt/homebrew/bin
- RTK installed via
brew install rtk
- Claude Code hook PATH does not include
/opt/homebrew/bin
Workaround
In ~/.claude/settings.json, change the hook command from:
/Users/<you>/.claude/hooks/rtk-rewrite.sh
to:
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" bash /Users/<you>/.claude/hooks/rtk-rewrite.sh
Problem
When RTK is installed via Homebrew, the
rtk-rewrite.shhook silently stops working because Claude Code runs hooks with a restricted PATH that does not include/opt/homebrew/bin.The hook does:
This means all Bash commands pass through unmodified with zero indication anything is wrong.
rtk gainstill works fine from the terminal (because the user's shell has Homebrew in PATH), so the breakage is invisible.How it breaks
cargo install rtk→ binary at~/.cargo/bin/rtkbrew install rtk→ binary moves to/opt/homebrew/bin/rtkcommand -v rtkreturns nothing in Claude Code's hook environmentrtk gain --historystops updating, but user assumes hook is fineVerification
You can reproduce by running the hook with a clean environment:
Root cause
rtk init -ginstalls a hook that usesrtkby name and relies on it being in PATH. But Claude Code's hook subprocess does not inherit the user's full shell PATH (no Homebrew, no cargo, etc. on macOS).Suggested fixes
Option A (best):
rtk init -gshould inject the absolute path to the current binary into the hook at install time:Option B: The hook should probe known install locations as fallback:
Option C: Emit a visible warning (not just
exit 0) whenrtkis not found — at minimum>&2 echo "[rtk] WARNING: rtk not found in PATH, hook disabled"so users know something is wrong.Note: Option C has already been partially addressed (warnings added to the hook), but the silent failure on Homebrew installs is the main UX problem.
Environment
/opt/homebrew/binbrew install rtk/opt/homebrew/binWorkaround
In
~/.claude/settings.json, change the hook command from:to: