Hmbown/CodeWhale · error · anyhow::Error
`gh` CLI not found on PATH. Install GitHub CLI (https://cli.
Error message
`gh` CLI not found on PATH. Install GitHub CLI (https://cli.github.com) and authenticate (`gh auth login`) so `codewhale pr <N>` can fetch PR metadata and the diff.
What it means
run_pr() shells out to GitHub's `gh` for PR metadata and diff; its first act is an is_command_available("gh") check that bails with install/auth instructions when gh is not on PATH. Note the doc comment above the function claims it "falls back gracefully if gh is missing", but the implementation hard-fails — the comment is stale.
Source
Thrown at crates/tui/src/lib.rs:8155
} else {
"invalid"
}
}
/// `codewhale pr <N>` (#451) — fetch a GitHub PR via `gh`, format
/// title + body + diff as the composer's first message, and launch
/// the interactive TUI. Falls back gracefully if `gh` is missing.
async fn run_pr(
cli: &Cli,
config: &Config,
number: u32,
repo: Option<&str>,
checkout: bool,
pending_telemetry_notice: Option<crate::telemetry_notice::PendingTelemetryNotice>,
plugin_registry: Arc<crate::plugins::PluginRegistry>,
) -> Result<()> {
if !is_command_available("gh") {
bail!(
"`gh` CLI not found on PATH. Install GitHub CLI \
(https://cli.github.com) and authenticate (`gh auth login`) \
so `codewhale pr <N>` can fetch PR metadata and the diff."
);
}
let view = run_gh_pr_view(number, repo)?;
let diff = run_gh_pr_diff(number, repo)?;
if checkout {
match run_gh_pr_checkout(number, repo) {
Ok(()) => eprintln!("Checked out PR #{number} into the current workspace."),
Err(err) => eprintln!(
"warning: gh pr checkout #{number} failed ({err}). Continuing without checkout."
),
}
}
View on GitHub (pinned to 0c42157ee5)
Solutions
- Install GitHub CLI (https://cli.github.com — e.g. `brew install gh` or your distro package)
- Authenticate with `gh auth login`
- Verify with `command -v gh` inside the same shell/environment codewhale runs in
Example fix
// before $ codewhale pr 42 Error: `gh` CLI not found on PATH. Install GitHub CLI ... // after $ brew install gh # or: apt install gh / dnf install gh $ gh auth login $ codewhale pr 42
Defensive patterns
Strategy: validation
Validate before calling
command -v gh >/dev/null 2>&1 || { echo 'gh missing: install from https://cli.github.com' >&2; exit 2; }
gh auth status >/dev/null 2>&1 || { echo 'run: gh auth login' >&2; exit 2; }
codewhale pr "$N" Prevention
- Bake gh into CI images and verify with `command -v gh` in preflight
- Keep gh authenticated in automation via GH_TOKEN rather than interactive logins
When it happens
Trigger: `codewhale pr <N>` on a machine where the gh binary is not installed or not on PATH (the check is name-based, so a shadowed or non-executable gh also fails).
Common situations: Fresh container or CI image without gh; gh installed for a different user or via a PATH not propagated into the session; minimal dev images.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- gh pr view #{number} failed: {stderr}
- NotFound
- gh pr diff #{number} failed: {stderr}
- tmux attach unavailable
- release redirect did not resolve to a tag URL: {final_url}
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/386d430cd0aaa52d.
Report an issue: GitHub.