Hmbown/CodeWhale · error

Failed to run `gh pr checkout

Error message

Failed to run `gh pr checkout`: {e}

What it means

Subprocess wrapper guard in run_gh_pr_checkout: `gh` was found and the `pr checkout` command was spawned, but the process itself could not run to completion (spawn/exec failure reported as {e}). No checkout occurred.

Solutions

  1. Check the underlying io error in {e} (permissions, exec format, resource limits) and fix it.
  2. Retry after verifying `gh pr checkout <n>` works from a shell in the same directory.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/tui/src/lib.rs:9288 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

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

fn run_gh_pr_view(number: u32, repo: Option<&str>) -> Result<GhPullRequest> {
    crate::tools::review_pr::fetch_view(number, repo, &std::env::current_dir()?)
}

fn run_gh_pr_diff(number: u32, repo: Option<&str>, view: &GhPullRequest) -> Result<String> {
    crate::tools::review_pr::fetch_diff(number, repo, &std::env::current_dir()?, view)
}

fn run_gh_pr_checkout(number: u32, repo: Option<&str>) -> Result<()> {
    let mut cmd = crate::dependencies::Gh::command()
        .ok_or_else(|| anyhow::anyhow!("gh not found on PATH"))?;
    cmd.arg("pr").arg("checkout").arg(number.to_string());
    if let Some(r) = repo {
        cmd.arg("--repo").arg(r);
    }
    let output = cmd
        .output()
        .map_err(|e| anyhow::anyhow!("Failed to run `gh pr checkout`: {e}"))?;
    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();
        bail!("gh pr checkout #{number} failed: {stderr}");
    }
    Ok(())
}

/// Resolve the `owner/name` repository `gh` believes the current workspace
/// belongs to. `gh api` needs an explicit repository path, unlike `gh pr`
/// which infers it from the working directory.
fn run_gh_repo_name() -> Result<String> {
    let mut cmd = crate::dependencies::Gh::command()
        .ok_or_else(|| anyhow::anyhow!("gh not found on PATH"))?;
    cmd.arg("repo")
        .arg("view")
        .arg("--json")
        .arg("nameWithOwner")
        .arg("--jq")

View on GitHub (pinned to 73e0f67d83)