Skip to content

Hook: ~/.cargo/bin not in PATH, rewritten commands use bare 'rtk' instead of absolute path #111

Closed

Description

@Rmohid

Problem

The generated hook script (rtk init -g) has two related PATH issues:

1. Guard check fails silently when ~/.cargo/bin is not in Claude Code's shell PATH

Claude Code's shell environment does not inherit ~/.cargo/bin from the user's profile. The guard at the top of the hook:

if ! command -v rtk &>/dev/null || ! command -v jq &>/dev/null; then
  exit 0
fi

...silently exits because rtk can't be found. The hook never fires.

2. Rewritten commands use bare rtk instead of absolute path

Even after fixing the PATH for the guard check, the rewritten commands use bare rtk:

REWRITTEN="${ENV_PREFIX}$(echo "$CMD_BODY" | sed 's/^git status/rtk git status/')"

When Claude Code executes the rewritten command, rtk is not found because ~/.cargo/bin isn't in the execution PATH either.

Fix

Add to the top of the hook:

export PATH="$HOME/.cargo/bin:$PATH"
RTK="$(command -v rtk)"

Then use $RTK in all sed substitutions instead of the bare word rtk.

Environment

  • rtk 0.15.3
  • macOS (Tahoe)
  • Claude Code CLI
  • rtk installed via cargo install

Activity

  1. pszymkowiak commented on Feb 17, 2026

    @pszymkowiak
    Collaborator

    PR #161 changes the install directory to ~/.local/bin but doesn't fix the hook PATH. The hook still does command -v rtk without adding common install paths.

    Fix is one line at the top of .claude/hooks/rtk-rewrite.sh (before the guard check):

    export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"

    PR welcome.

  2. Rmohid commented on Feb 18, 2026

    @Rmohid
    ContributorAuthor

    Verified fix: PR #150 eliminates this by replacing bash/jq hook with native Rust rtk hook-rewrite subcommand. No PATH lookup needed -- if rtk is callable, the hook works. Build passes, 435 tests pass (94 hook-specific).

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

    P2-importantDevrait être fixé bientôtbugSomething isn't workingeffort-smallQuelques heures, 1 fichiergood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions