{"record":{"id":"bbd19aca630b8b2b","repo":"jdx/mise","slug":"program-display-args-failed-exit-code","errorCode":null,"errorMessage":"{program} {display_args} failed: exit code {}\n{}","messagePattern":"(.+?) (.+?) failed: exit code (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd.rs","lineNumber":2076,"sourceCode":"    V: AsRef<OsStr>,\n{\n    let display_args = args.join(\" \");\n    debug!(\"$ {program} {display_args}\");\n\n    let output = tokio::process::Command::new(program)\n        .args(args)\n        .envs(extra_env)\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .kill_on_drop(true)\n        .output()\n        .await\n        .wrap_err_with(|| format!(\"failed to execute command: {program} {display_args}\"))?;\n\n    if !output.status.success() {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\n            \"{program} {display_args} failed: exit code {}\\n{}\",\n            output.status.code().unwrap_or(-1),\n            stderr.trim()\n        );\n    }\n\n    let stdout = String::from_utf8(output.stdout)\n        .wrap_err_with(|| format!(\"{program} produced invalid UTF-8 output\"))?;\n    Ok(stdout.trim_end().to_string())\n}\n\n#[cfg(test)]\n#[cfg(unix)]\nmod tests {\n    use std::sync::atomic::{AtomicUsize, Ordering};\n    use std::sync::{Arc, Mutex};\n\n    use pretty_assertions::assert_eq;","sourceCodeStart":2058,"sourceCodeEnd":2094,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cmd.rs#L2058-L2094","documentation":"This error is raised when an external command spawned by mise (via the async command runner in src/cmd.rs) exits with a non-zero status. It wraps the program name, its display arguments, the raw exit code, and the trimmed stderr output so the developer can see exactly what subprocess failed and why. It mirrors the child's failure rather than a mise-internal bug.","triggerScenarios":"Calling any mise code path that shells out to an external program (e.g. a backend install step, git command, or plugin hook) when that program exits non-zero. The message includes exit code and stderr.","commonSituations":"A tool backend fails during install (network partial download, checksum script failing); a git command fails because the repo is dirty or the ref doesn't exist; a plugin's hook script errors; PATH/toolchain missing so the child fails at startup.","solutions":["Read the stderr appended to the message to identify the child failure and fix the underlying cause","Run the same command manually with the same args/env to reproduce the child's error","Ensure the required tool/dependency is installed and on PATH in the environment mise uses","Set MISE_DEBUG=1 to see the full command invocation that failed"],"exampleFix":"// before: vague failure, exit code 1 with empty context\n// after: install the missing dependency indicated by stderr, e.g.\n// mise install  ->  error: git clone ... failed: exit code 128\n// fix: git config --global url.\"https://\".insteadOf git:// or install git","handlingStrategy":"try-catch","validationCode":"// before invoking, check the child tool exists\nif !Path::new(program).exists() && which(program).is_none() {\n    return Err(format!(\"{program} not found on PATH\"));\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"failed: exit code\") => {\n        // parse stderr from the message; surface a targeted fix or retry with corrected env\n        eprintln!(\"external tool failed: {e}\");\n        fallback_path()\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate that the external binary exists on PATH before spawning","Run commands non-interactively and with explicit env/cwd","Keep tool dependencies pinned in [tools] so child tools are present","Log full command lines with MISE_DEBUG=1 when debugging"],"tags":["subprocess","command-execution","exit-code","cli"],"backgroundTag":"command-failed-nonzero","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}