zeroclaw-labs/zeroclaw · warning · DiagItem

{cmd} found but returned non-zero

Error message

{cmd} found but returned non-zero

What it means

A `zeroclaw doctor` warning from `check_command_available`: the probed command (`git --version` or `curl --version`) exists and executed but exited non-zero. Doctor only needs the first stdout line as a version banner, so a non-zero exit means the binary is present yet broken — a wrapper/shim that errors, a corrupt install, or a patched build that rejects the version flag.

Source

Thrown at crates/zeroclaw-runtime/src/doctor/mod.rs:1815

        ));
    }
}

fn check_command_available(cmd: &str, args: &[&str], cat: &'static str, items: &mut Vec<DiagItem>) {
    match std::process::Command::new(cmd)
        .args(args)
        .stdout(std::process::Stdio::piped())
        .stderr(std::process::Stdio::piped())
        .output()
    {
        Ok(output) if output.status.success() => {
            let ver = String::from_utf8_lossy(&output.stdout);
            let first_line = ver.lines().next().unwrap_or("").trim();
            let display = truncate_for_display(first_line, COMMAND_VERSION_PREVIEW_CHARS);
            items.push(DiagItem::ok(cat, format!("{cmd}: {display}")));
        }
        Ok(_) => {
            items.push(DiagItem::warn(
                cat,
                format!("{cmd} found but returned non-zero"),
            ));
        }
        Err(_) => {
            items.push(DiagItem::warn(cat, format!("{cmd} not found in PATH")));
        }
    }
}

fn format_error_chain(error: &anyhow::Error) -> String {
    let mut parts = Vec::new();
    for cause in error.chain() {
        let message = cause.to_string();
        if !message.is_empty() {
            parts.push(message);
        }
    }

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Reproduce manually: run `git --version` (or `curl --version`) and read the error it prints.
  2. Fix or reinstall the broken binary (`apt-get install --reinstall git`, `brew reinstall git`).
  3. Remove or repair shims earlier in PATH (`which -a git` to find them).
  4. Re-run `zeroclaw doctor` to confirm the ok line with the version banner.

Example fix

# before: doctor -> "git found but returned non-zero"
git --version   # exits 1, prints error to stderr

# after
apt-get install --reinstall git
git --version   # git version 2.47.x
Defensive patterns

Strategy: fallback

Try / catch

match std::process::Command::new(cmd).args(["--version"]).output() {
    Ok(output) if output.status.success() => { /* use first stdout line as version */ }
    Ok(_) => { /* present but broken: proceed without version, flag for reinstall */ }
    Err(_) => { /* not on PATH */ }
}

Prevention

When it happens

Trigger: Running `zeroclaw doctor` when `git --version` or `curl --version` returns a non-zero exit status — e.g. a broken shim earlier on PATH, a git wrapper requiring config that fails, or a corrupted installation.

Common situations: Corporate machines with wrapped git; homebrew/apt installs interrupted mid-upgrade; custom `git` shims in `/usr/local/bin` that print to stderr and exit 1; snapshot tools (asdf/mise) with a broken shim.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/e04977e7da05b428. Report an issue: GitHub.