xai-org/grok-build · error

gh release download failed for

Error message

gh release download failed for {} tag {} from {}: {}

What it means

This error wraps a failed `gh release download` subprocess invocation. The command ran (spawn succeeded) but exited non-zero; the message includes the release pattern, tag, the GH_RELEASE_REPO repository, and the trimmed stderr from the gh CLI so the developer can see gh's own diagnostic (auth errors, missing release, network failures).

Solutions

  1. Read the stderr embedded in the message — it contains gh's specific reason (404, 403, 'release not found', etc.).
  2. Run `gh auth status` and authenticate (gh auth login or set GH_TOKEN) if the stderr indicates auth failure.
  3. Verify the tag exists: `gh release view <tag> -R <repo>`; if not, use a valid/current tag.
  4. Check the asset pattern matches an actual release asset name.
  5. Update gh (`gh upgrade` or reinstall) if the stderr shows unsupported flags or API changes; verify proxy settings if network errors appear.

Example fix

// before: calling with a hardcoded stale tag
gh_download("grok-cli-*", "v0.9.9").await?;

// after: resolve the latest tag first and surface gh's stderr
let tag = latest_release_tag().await?; // e.g. via gh api repos/:repo/releases/latest
match gh_download("grok-cli-*", &tag).await {
    Err(e) => {
        eprintln!("gh download failed for tag {tag}; check `gh auth status` and that the asset exists");
        return Err(e);
    }
    Ok(()) => {}
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Preflight: gh installed, authenticated, and the tag exists
let auth = std::process::Command::new("gh").args(["auth", "status"]).output()?;
if !auth.status.success() {
    anyhow::bail!("gh not authenticated; run `gh auth login` or set GH_TOKEN");
}
let view = std::process::Command::new("gh")
    .args(["release", "view", tag, "-R", repo])
    .output()?;
if !view.status.success() {
    anyhow::bail!("release {tag} not found in {repo}");
}

Type guard

fn gh_succeeded(status: &std::process::ExitStatus) -> bool {
    status.success()
}

Try / catch

match gh_release_download(pattern, tag, repo).await {
    Ok(()) => {}
    Err(e) => {
        let msg = e.to_string();
        if msg.contains("403") || msg.contains("authentication") {
            eprintln!("gh auth problem: run `gh auth login` or set GH_TOKEN");
        } else if msg.contains("not found") || msg.contains("404") {
            eprintln!("tag/pattern {tag}/{pattern} does not exist in {repo}");
        } else {
            return Err(e);
        }
    }
}

Prevention

When it happens

Trigger: Calling the gh-release download helper (with a pattern, tag, and repo) when the `gh release download` process exits non-zero: tag does not exist, asset matching the pattern is missing, gh is not authenticated (no GH_TOKEN / `gh auth login`), gh CLI is outdated, or the network/DNS fails inside gh.

Common situations: Running the updater in CI without gh credentials (401/403 in stderr); requesting a tag that was deleted or not yet published; specifying an asset glob pattern that matches nothing; corporate proxy blocking gh; gh CLI not installed on PATH so an older/wrong binary is invoked.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/53fb495ab5e62225. Report an issue: GitHub.

Appendix: source

Thrown at crates/codegen/xai-grok-update/src/auto_update.rs:2439

        crate::version::GH_RELEASE_REPO,
        "--pattern",
        pattern,
        "--output",
        &dest.to_string_lossy(),
        "--clobber",
    ])
    .stdin(Stdio::null())
    .stdout(Stdio::null())
    .stderr(Stdio::piped());
    xai_grok_tools::util::detach_command(&mut cmd);
    cmd.envs(xai_grok_tools::util::pager_env());
    let output = cmd.output().await?;

    pb.finish_and_clear();

    if !output.status.success() {
        let stderr = String::from_utf8_lossy(&output.stderr);
        anyhow::bail!(
            "gh release download failed for {} tag {} from {}: {}",
            pattern,
            tag,
            crate::version::GH_RELEASE_REPO,
            stderr.trim()
        );
    }
    Ok(())
}

/// Download and install grok from GitHub Releases (xai-org-shared/grok-build).
///
/// Uses `gh release download` to fetch the binary matching the current platform.
/// This works anywhere the `gh` CLI is authenticated, without needing npm or
/// internal network access.
async fn install_gh_release(target: Option<&str>) -> Result<()> {
    let (os, arch) = detect_platform()?;
    let platform = format!("{}-{}", os, arch);

View on GitHub (pinned to bc7f02eddd)