nikivdev/code · error

download failed ({})

Error message

download failed ({})

What it means

install downloads the binary from the resolved download URL. If the HTTP response status is not successful, it bails with 'download failed (<status>)'. The `.context("failed to download binary")` only covers transport errors; this error covers server-side rejections.

Source

Thrown at src/registry.rs:241

    let version = opts.version.clone();
    let manifest = fetch_manifest(&client, &registry_url, &name, version.as_deref())?;
    let target = detect_target_triple()?;
    let target_entry = manifest
        .targets
        .get(&target)
        .with_context(|| format!("No binaries for target {}", target))?;
    let bin = resolve_install_bin(&name, &opts.bin, &manifest, target_entry)?;
    let path = target_entry
        .binaries
        .get(&bin)
        .with_context(|| format!("No binary '{}' in manifest", bin))?;
    let download_url = resolve_download_url(&registry_url, path);
    let response = client
        .get(download_url)
        .send()
        .context("failed to download binary")?;
    if !response.status().is_success() {
        bail!("download failed ({})", response.status());
    }
    let bytes = response.bytes().context("failed to read download")?;

    if !opts.no_verify {
        if let Some(expected) = target_entry.sha256.get(&bin) {
            let actual = sha256_bytes(&bytes);
            if expected != &actual {
                bail!("checksum mismatch for {}", bin);
            }
        }
    }

    let bin_dir = opts.bin_dir.clone().unwrap_or_else(default_bin_dir);
    fs::create_dir_all(&bin_dir)
        .with_context(|| format!("failed to create {}", bin_dir.display()))?;
    let dest = bin_dir.join(&bin);
    if dest.exists() && !opts.force {
        bail!(

View on GitHub (pinned to a747e741ae)

Solutions

  1. Check the status code: 404 means the binary isn't published for that package/version/target — verify the version and target.
  2. Verify the registry URL configuration resolves to the correct registry.
  3. Re-publish the package if the binary was never uploaded.
  4. Retry if the status is 5xx (transient registry issue).

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: verify the binary entry exists in the manifest before downloading
let target_entry = manifest.targets.get(&target_triple)
    .ok_or_else(|| format!("no binaries published for target {}", target_triple))?;
if !target_entry.sha256.contains_key(&bin) {
    return Err(format!("binary {} not listed for target {}", bin, target_triple));
}

Try / catch

match install(opts) {
    Err(e) if e.to_string().contains("download failed") => {
        if e.to_string().contains("404") {
            eprintln!("Binary not published for this package/version/target — verify version and target triple.");
        } else if e.to_string().contains("50") {
            retry_with_backoff(3, || install(opts.clone()));
        }
        std::process::exit(1);
    }
    other => other,
}

Prevention

When it happens

Trigger: GET on the resolved binary URL returning 404 (package/version/target not published), 401/403 (private package), or 5xx, after a successful manifest fetch.

Common situations: Requesting a version whose manifest exists but binaries were never uploaded; wrong target triple published; registry URL misconfigured pointing at the wrong host; package removed from the registry.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/2308d244f4acddba. Report an issue: GitHub.