{"record":{"id":"e43bfc29ab9230b8","repo":"diem/diem","slug":"command-failed-with-exit-status","errorCode":null,"errorMessage":"Command {:?} failed with exit status: {}","messagePattern":"Command (.+?) failed with exit status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"storage/backup/backup-cli/src/storage/command_adapter/command.rs","lineNumber":117,"sourceCode":"    pub fn stdin(&mut self) -> &mut ChildStdin {\n        self.child.stdin.as_mut().unwrap()\n    }\n\n    pub fn into_data_source<'a>(self) -> ChildStdoutAsDataSource<'a> {\n        ChildStdoutAsDataSource::new(self)\n    }\n\n    pub fn into_data_sink<'a>(self) -> ChildStdinAsDataSink<'a> {\n        ChildStdinAsDataSink::new(self)\n    }\n\n    pub async fn join(self) -> Result<()> {\n        match self.child.wait_with_output().await {\n            Ok(output) => {\n                if output.status.success() {\n                    Ok(())\n                } else {\n                    bail!(\n                        \"Command {:?} failed with exit status: {}\",\n                        self.command,\n                        output.status\n                    )\n                }\n            }\n            Err(e) => bail!(\"Failed joining command {:?}: {}\", self.command, e),\n        }\n    }\n}\n\npub(super) struct ChildStdoutAsDataSource<'a> {\n    child: Option<SpawnedCommand>,\n    join_fut: Option<BoxFuture<'a, Result<()>>>,\n}\n\nimpl<'a> ChildStdoutAsDataSource<'a> {\n    fn new(child: SpawnedCommand) -> Self {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/diem/diem/blob/fc4714a8ea273b6efe8b13dbce72ea60aad9a16c/storage/backup/backup-cli/src/storage/command_adapter/command.rs#L99-L135","documentation":"join() waits for the spawned command to finish; if the exit status is not success, the library bails with the command and its exit status. It reports the underlying external process (e.g. a backup/storage CLI) failed, not a bug in this library.","triggerScenarios":"Any spawned command exits with non-zero status, detected via wait_with_output().","commonSituations":"Wrong arguments or paths passed to the external tool; tool missing permissions; disk full; tool version mismatch.","solutions":["Read the exit status from the message and run the command manually to see stderr","Fix the arguments/config passed into the command adapter","Check the external tool's logs, permissions, and required environment"],"exampleFix":"// before\nCommand::new(\"backup-tool\").arg(wrong_path)\n// after\nCommand::new(\"backup-tool\").arg(validated_path).arg(\"--verbose\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match cmd.join().await { Ok(()) => Ok(()), Err(e) if e.to_string().contains(\"failed with exit status\") => { log_stderr_hint(&e); Err(e) } Err(e) => Err(e) }","preventionTips":["Validate arguments and paths before spawning","Run the external tool once manually to confirm it works in your environment","Prefer passing --verbose-like flags to capture tool-side errors"],"tags":["process","exit-status","cli"],"backgroundTag":"command-exited-nonzero","analyzedSha":"fc4714a8ea273b6efe8b13dbce72ea60aad9a16c","analyzedAt":"2026-09-04T21:07:05.890Z","contentChangedAt":"2026-09-04T21:07:05.890Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}