Hmbown/CodeWhale · error · anyhow::Error

`gh` CLI not found on PATH. Install GitHub 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

`codewhale pr <N>` shells out to the GitHub CLI (`gh`) to fetch PR metadata and the diff. Before doing so it checks is_command_available("gh"); if `gh` is not on PATH it bails with install/auth instructions, because the whole command depends on it.

Solutions

  1. Install the GitHub CLI (https://cli.github.com) and ensure it is on PATH (`gh --version`)
  2. Authenticate with `gh auth login`
  3. In CI/scripts, install gh in the setup step and/or extend PATH (e.g. `export PATH="$HOME/.local/bin:$PATH"`)

Example fix

// before (CI step)
- run: codewhale pr 123
// after
- run: |
    type -p gh || (sudo apt-get install -y gh)
    gh auth login --with-token < token.txt
    codewhale pr 123
Defensive patterns

Strategy: validation

Validate before calling

command -v gh >/dev/null 2>&1 || { echo 'gh CLI missing'; exit 1; }
gh auth status >/dev/null 2>&1 || { echo 'gh not authenticated'; exit 1; }

Prevention

When it happens

Trigger: Running any `codewhale pr <N>` command on a machine where the `gh` binary is not installed or is not on the current PATH.

Common situations: Fresh CI container or devcontainer without GitHub CLI; `gh` installed via a version manager whose PATH is not active in the script environment; running inside Docker or systemd where PATH is minimal.

Understand the failure class

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/386d430cd0aaa52d. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/lib.rs:9197

    } 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, &view)?;

    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 73e0f67d83)