Skip to content

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

@Rmohid

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

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