AutoDarkMode/Windows-Auto-Night-Mode · error · anyhow::Error

Failed to download: HTTP {}

Error message

Failed to download: HTTP {}

What it means

Returned (via anyhow::bail) by download_file in the Rust installer downloader when the HTTP GET to the installer URL returns a non-success status. The URL is built from a hardcoded GitHub release base plus an architecture-detected filename (ARM64 or x86). The error is mapped to exit code ERR_DOWNLOAD (13370) by run_install_flow.

Source

Thrown at adm-downloader-rs/src/main.rs:125

    // prefer the installer's code if present.
    if let Some(code) = installer_code {
        exit(code);
    }

    // otherwise if we mapped a specific error code, return that.
    if let Some(code) = program_error_code {
        exit(code);
    }

    println!("done.");
    Ok(())
}

fn download_file(url: &str, dest: &PathBuf) -> anyhow::Result<()> {
    let client = Client::new();
    let resp = client.get(url).send()?;
    if !resp.status().is_success() {
        anyhow::bail!("Failed to download: HTTP {}", resp.status());
    }

    let mut file = File::create(dest)?;
    let bytes = resp.bytes()?;
    let mut content = bytes.as_ref();
    copy(&mut content, &mut file)?;
    Ok(())
}

/// print package name and version pairs from the embedded Cargo.lock.
fn print_updater_licenses() {
    // embed the prepared HTML at compile time and open it in the default browser.
    const HTML: &str = include_str!("../license.html");

    // write to a deterministic temp filename so it can be opened.
    let mut out = std::env::temp_dir();
    out.push("adm-updater-licenses.html");
    if let Err(e) = std::fs::write(&out, HTML) {

View on GitHub (pinned to c15b28e921)

Solutions

  1. Verify the release URL is valid and the asset exists at the hardcoded version (open it in a browser).
  2. Retry — GitHub 403/5xx and transient network errors are often intermittent.
  3. Check network connectivity, proxy, and firewall rules blocking github.com.
  4. Update the hardcoded base URL / version in main.rs if the release moved.
  5. Run with network tracing (e.g. set RUST_LOG/HTTPS_PROXY) to capture the exact status code.
Defensive patterns

Strategy: retry

Validate before calling

// Verify the asset URL is reachable before downloading
fn check_url_reachable(url: &str) -> anyhow::Result<()> {
    let resp = Client::new().head(url).send()?;
    if !resp.status().is_success() {
        anyhow::bail!("asset URL not reachable: HTTP {}", resp.status());
    }
    Ok(())
}

Try / catch

// run_install_flow already maps this to ERR_DOWNLOAD. Add limited retries
// for transient 5xx/403 before giving up:
let mut last = None;
for _ in 0..3 {
    match download_file(url, dest) { Ok(()) => return Ok(()), Err(e) => { last = Some(e); std::thread::sleep(Duration::from_secs(2)); } }
}
eprintln!("download failed: {}", last.unwrap());
return Err(ERR_DOWNLOAD);

Prevention

When it happens

Trigger: download_file(url, dest) issues client.get(url).send(); resp.status().is_success() is false. The URL points at a GitHub release asset (e.g. https://github.com/AutoDarkMode/.../AutoDarkMode_11.0.0.54_x86.exe).

Common situations: The release/asset was removed or renamed (404); GitHub rate-limited the unauthenticated request (403); the hardcoded version 11.0.0.54 no longer exists; network proxy/firewall blocked the request; transient server error (5xx).

Related errors


AI-assisted analysis of AutoDarkMode/Windows-Auto-Night-Mode@c15b28e921 (2026-08-13). Data as JSON: /api/errors/4b16494d6fc9e6ef. Report an issue: GitHub.