{"record":{"id":"e04977e7da05b428","repo":"zeroclaw-labs/zeroclaw","slug":"cmd-found-but-returned-non-zero","errorCode":null,"errorMessage":"{cmd} found but returned non-zero","messagePattern":"(.+?) found but returned non-zero","errorType":"console","errorClass":"DiagItem","httpStatus":null,"severity":"warning","filePath":"crates/zeroclaw-runtime/src/doctor/mod.rs","lineNumber":1815,"sourceCode":"        ));\n    }\n}\n\nfn check_command_available(cmd: &str, args: &[&str], cat: &'static str, items: &mut Vec<DiagItem>) {\n    match std::process::Command::new(cmd)\n        .args(args)\n        .stdout(std::process::Stdio::piped())\n        .stderr(std::process::Stdio::piped())\n        .output()\n    {\n        Ok(output) if output.status.success() => {\n            let ver = String::from_utf8_lossy(&output.stdout);\n            let first_line = ver.lines().next().unwrap_or(\"\").trim();\n            let display = truncate_for_display(first_line, COMMAND_VERSION_PREVIEW_CHARS);\n            items.push(DiagItem::ok(cat, format!(\"{cmd}: {display}\")));\n        }\n        Ok(_) => {\n            items.push(DiagItem::warn(\n                cat,\n                format!(\"{cmd} found but returned non-zero\"),\n            ));\n        }\n        Err(_) => {\n            items.push(DiagItem::warn(cat, format!(\"{cmd} not found in PATH\")));\n        }\n    }\n}\n\nfn format_error_chain(error: &anyhow::Error) -> String {\n    let mut parts = Vec::new();\n    for cause in error.chain() {\n        let message = cause.to_string();\n        if !message.is_empty() {\n            parts.push(message);\n        }\n    }","sourceCodeStart":1797,"sourceCodeEnd":1833,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/doctor/mod.rs#L1797-L1833","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reproduce manually: run `git --version` (or `curl --version`) and read the error it prints.","Fix or reinstall the broken binary (`apt-get install --reinstall git`, `brew reinstall git`).","Remove or repair shims earlier in PATH (`which -a git` to find them).","Re-run `zeroclaw doctor` to confirm the ok line with the version banner."],"exampleFix":"# before: doctor -> \"git found but returned non-zero\"\ngit --version   # exits 1, prints error to stderr\n\n# after\napt-get install --reinstall git\ngit --version   # git version 2.47.x","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match std::process::Command::new(cmd).args([\"--version\"]).output() {\n    Ok(output) if output.status.success() => { /* use first stdout line as version */ }\n    Ok(_) => { /* present but broken: proceed without version, flag for reinstall */ }\n    Err(_) => { /* not on PATH */ }\n}","preventionTips":["Smoke-test `git --version` and `curl --version` in image build pipelines.","Avoid custom shims for git/curl in PATH; if needed, make them exit 0 on --version."],"tags":["environment","cli-tools","git","curl","doctor","zeroclaw"],"backgroundTag":"cli-tool-version-check-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}