denisidoro/navi · error · anyhow

Failed to call: wget {} Output: {} Error: {}

Error message

Failed to call:
wget {}

Output:
{}

Error:
{}

What it means

When the wget child process spawned by `cheatsh::call` exits with a non-zero status, navi returns an error containing the full wget command line plus its stdout and stderr. This distinguishes transport-level failures (DNS, TLS, HTTP errors) from 'topic not found'.

Source

Thrown at src/clients/cheatsh.rs:71

        let lines = as_lines(query, &markdown);
        Ok(lines)
    } else {
        let msg = format!(
            "Failed to call:
wget {}

Output:
{}

Error:
{}
",
            args.join(" "),
            String::from_utf8(out.stdout).unwrap_or_else(|_e| "Unable to get output message".to_string()),
            String::from_utf8(out.stderr).unwrap_or_else(|_e| "Unable to get error message".to_string())
        );
        Err(anyhow!(msg))
    }
}

View on GitHub (pinned to f7330b9ad5)

Solutions

  1. Read the Output/Error sections in the message to identify the wget failure cause
  2. Verify connectivity: `wget https://cheat.sh` manually
  3. Configure proxy env vars (https_proxy) if behind a corporate proxy
  4. Retry when network/cheat.sh is back, or use a local cheatsheet source instead

Example fix

// before
$ navi cheatsh tar
Failed to call:
wget https://cheat.sh/tar
Error:
wget: unable to resolve host address 'cheat.sh'
// after
$ ping cheat.sh        # fix DNS/network first
$ navi cheatsh tar
Defensive patterns

Strategy: retry

Validate before calling

fn connectivity_ok() -> bool {
    std::process::Command::new("wget").args(["-q", "--spider", "https://cheat.sh"])
        .status().map(|s| s.success()).unwrap_or(false)
}
if !connectivity_ok() {
    eprintln!("no connectivity to cheat.sh; check network/proxy/DNS");
    return;
}

Try / catch

match cheatsh::call(query, opts) {
    Ok(lines) => render(lines),
    Err(e) if e.to_string().contains("Failed to call") => {
        eprintln!("wget failed; inspect embedded stdout/stderr, retrying once...");
        match cheatsh::call(query, opts) { Ok(l) => render(l), Err(e2) => eprintln!("{}", e2) }
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `call` -> wget exits non-zero: no network connection, DNS failure, TLS/proxy errors, HTTP 5xx from cheat.sh, or wget blocked by firewall.

Common situations: Working offline, corporate proxy requiring configuration (http_proxy/https_proxy), DNS misconfiguration, cheat.sh outage, or wget certificates missing (CA bundle) in minimal containers.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03). Data as JSON: /api/errors/d7dbb58776365b9c. Report an issue: GitHub.