{"record":{"id":"4ef12a1ddf677b8d","repo":"jdx/mise","slug":"command-exited-with-non-zero-status-status","errorCode":null,"errorMessage":"command exited with non-zero status: {status}","messagePattern":"command exited with non-zero status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/bounded.rs","lineNumber":53,"sourceCode":"                child.wait(),\n                capture(stdout, &budget, limit),\n                capture(stderr, &budget, limit)\n            )\n        })\n        .await;\n        let (status, stdout, _stderr) = match result {\n            Ok(Ok(output)) => output,\n            Ok(Err(err)) => {\n                end(&mut child, tree).await;\n                return Err(err.into());\n            }\n            Err(_) => {\n                end(&mut child, tree).await;\n                bail!(\"timed out after {timeout:?}\");\n            }\n        };\n        if !status.success() {\n            bail!(\"command exited with non-zero status: {status}\");\n        }\n        Ok(String::from_utf8(stdout)?.trim_end().to_string())\n    }\n}\n\n/// How long reaping a killed command may take before it is left to the\n/// operating system. A process that has been killed is normally gone at\n/// once; one that is not is no reason to outlive the deadline.\nconst REAP: Duration = Duration::from_secs(1);\n\n/// End the command and account for it, without waiting on a process that\n/// may not be listening. Closing the tree kills the group, but the direct\n/// child can be outside it — on Windows it may never have joined the job,\n/// and on unix it can have left the group — and `kill_on_drop` cannot run\n/// while this is the task awaiting the child. So kill it here, and bound\n/// the wait: a deadline anything can extend is not a deadline.\nasync fn end(child: &mut tokio::process::Child, tree: ChildTree) {\n    drop(tree);","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cmd/bounded.rs#L35-L71","documentation":"Raised by read_isolated in src/cmd/bounded.rs after a bounded command completes but reports a non-success exit status. Unlike error 420 this is the bounded-reader variant: it returns the raw `ExitStatus` display rather than stderr content. It signals the isolated child command failed.","triggerScenarios":"Calling read_isolated when the spawned command exits non-zero (after completing within the timeout).","commonSituations":"A version-listing or metadata command fails on an unexpected file layout; a script returns non-zero because of a missing file, bad permissions, or an incompatible environment.","solutions":["Run the same command manually to capture its real stderr/stdout","Fix the failing child command's environment (PATH, files, permissions)","Check mise debug logs for the exact command line executed","Guard the call site if non-zero is an expected outcome for some inputs"],"exampleFix":"// before: failing script `mytool --list-versions` exits 1 due to missing config\n// after: create the expected config or use `mytool --list-versions --fallback`","handlingStrategy":"try-catch","validationCode":"// pre-flight the command outside the bounded reader\nlet status = Command::new(program).args(args).status()?;\nif !status.success() {\n    eprintln!(\"{program} exits non-zero in this environment\");\n}","typeGuard":null,"tryCatchPattern":"match read_isolated(&mut cmd, timeout, &tree).await {\n    Ok(out) => out,\n    Err(e) if e.to_string().contains(\"non-zero status\") => {\n        // re-run the command directly to capture stderr, then decide\n        diagnose_with_direct_run(program, args)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Test the exact command with the same args/env mise uses","Check file permissions and cwd assumptions of the child script","Pin the child tool version so behavior is stable","Handle expected non-zero exits at the call site instead of letting them bubble"],"tags":["subprocess","exit-code","nonzero-status"],"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-14T05:17:10.506Z"}