{"record":{"id":"7cd2c24cbbbf3936","repo":"nikivdev/code","slug":"external-cli-exited-unsuccessfully-with-status","errorCode":null,"errorMessage":"external CLI {} exited unsuccessfully with status {}","messagePattern":"external CLI (.+?) exited unsuccessfully with status (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/external_cli.rs","lineNumber":296,"sourceCode":"    if let Some(env_map) = &tool.manifest.exec.env {\n        if env_map.is_empty() {\n            println!(\"env: none\");\n        } else {\n            let mut keys = env_map.keys().cloned().collect::<Vec<_>>();\n            keys.sort();\n            println!(\"env: {}\", keys.join(\", \"));\n        }\n    } else {\n        println!(\"env: none\");\n    }\n    Ok(())\n}\n\nfn ensure_success(id: &str, status: ExitStatus) -> Result<()> {\n    if status.success() {\n        Ok(())\n    } else {\n        bail!(\n            \"external CLI {} exited unsuccessfully with status {}\",\n            id,\n            status\n        )\n    }\n}\n\nfn render_argv(argv: &[String]) -> String {\n    argv.iter()\n        .map(|arg| {\n            if arg.chars().any(char::is_whitespace) {\n                format!(\"{arg:?}\")\n            } else {\n                arg.clone()\n            }\n        })\n        .collect::<Vec<_>>()\n        .join(\" \")","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/external_cli.rs#L278-L314","documentation":"`ensure_success` converts a non-zero (or signal-killed) exit status of a spawned external CLI into a library error. The CLI itself ran and reported failure; this error just propagates its exit status with the tool id for context.","triggerScenarios":"`run_external_cli` spawns the resolved CLI via `Command`; the child process exits with a non-success status (non-zero code, or terminated by a signal), and `ensure_success` is called on the resulting `ExitStatus`.","commonSituations":"The external tool itself fails: bad CLI arguments built from config, the tool rejecting the working directory or environment, the tool crashing, or being killed by OOM/signals.","solutions":["Run the same CLI command manually with the same arguments to see the tool's own stderr/stdout diagnostics.","Fix the arguments or configuration that the library passes to the CLI (they derive from the manifest and your call to `command`).","Check the CLI's required environment, permissions, and working directory.","If killed by a signal (e.g. OOM), investigate resource limits or the tool's stability."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match runner.run_external_cli(...) {\n    Err(e) if e.to_string().contains(\"exited unsuccessfully\") => {\n        eprintln!(\"external CLI failed; rerun the command manually to see its diagnostics\");\n        // fall back or surface stderr to the user\n        Err(e)\n    }\n    other => other,\n}","preventionTips":["Run the external CLI manually with the generated arguments before automating it.","Pin and test CLI versions your manifest depends on.","Capture and log the child's stdout/stderr alongside this error.","Check the CLI's environment/working-directory requirements in CI."],"tags":["external-cli","exit-status","process"],"backgroundTag":"nonzero-exit-code","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}