{"record":{"id":"b9682cf728bd0e35","repo":"vectordotdev/vector","slug":"command-self-failed-with-exit-code-exit","errorCode":null,"errorMessage":"command: {self:?}\n  failed with exit code: {exit}","messagePattern":"command: (.+?)\n  failed with exit code: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/app.rs","lineNumber":137,"sourceCode":"                \"{}\",\n                format_command_error(&output, Some(&format!(\"Command: {self:?}\")))\n            )\n        }\n    }\n\n    /// Run the command and catch its exit code.\n    fn run(&mut self) -> Result<ExitStatus> {\n        self.pre_exec();\n        self.status().map_err(Into::into)\n    }\n\n    fn check_run(&mut self) -> Result<()> {\n        let status = self.run()?;\n        if status.success() {\n            Ok(())\n        } else {\n            let exit = status.code().unwrap();\n            bail!(\"command: {self:?}\\n  failed with exit code: {exit}\")\n        }\n    }\n\n    /// Run the command, capture its output, and display a progress bar while it's\n    /// executing. Intended to be used for long-running processes with little interaction.\n    fn wait(&mut self, message: impl Into<Cow<'static, str>>) -> Result<()> {\n        self.pre_exec();\n\n        let progress_bar = get_progress_bar()?;\n        progress_bar.set_message(message);\n\n        let result = self.output();\n        progress_bar.finish_and_clear();\n\n        let Ok(output) = result else {\n            bail!(\"could not run command\")\n        };\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/app.rs#L119-L155","documentation":"vdev's check_run runs a command and only checks its exit status. On failure it bails with \"command: {self:?}\\n  failed with exit code: {exit}\". Note the unwrap on status.code(): on Unix this is the signal-terminated case's None only in rare scenarios (normally a code exists after failure). The error tells you exactly which vdev command wrapper failed and with which exit code.","triggerScenarios":"Calling any vdev operation that internally uses check_run (e.g. exec, test flows) when the spawned process (cargo build/test, git, script) returns a non-zero exit code; also triggered when a test subcommand fails during vdev test runs.","commonSituations":"cargo build/test failures surfaced through vdev; scripts exiting non-zero due to environment issues (missing features, rustup toolchain absent); flaky tests returning non-zero in vdev test.","solutions":["Copy the echoed `command:` line and run it directly to obtain the full compiler/test output that check_run discards.","Fix the underlying failure (compile errors, missing toolchain via `rustup update`, failing tests) indicated by the direct run.","Set required feature flags/environment (e.g. FEATURES=... for make test) so the invoked command succeeds.","If the process was killed by a signal (no exit code), check OOM/timeout conditions in CI logs."],"exampleFix":"// before: vdev check_run(\"cargo test --features x\") exits 101\n// run manually to see the real error:\ncargo test --features x 2>&1 | head -50\n// after: fix compile error / missing feature, rerun the vdev command","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Handle non-zero exits from vdev-wrapped commands\nlet status = std::process::Command::new(\"cargo\").args([\"test\"]).status()?;\nif !status.success() {\n  eprintln!(\"underlying command failed with {:?}; inspect full output\", status.code());\n}\n// Then rerun the exact command line echoed by the vdev error for full logs.","preventionTips":["Treat the echoed `command:` line as reproducible: run it directly to capture output check_run swallows.","Ensure the rustup toolchain and required feature flags are set before vdev test/build runs.","Watch CI for OOM/timeouts when exit codes are absent (signal kills).","Fix root-cause build/test failures rather than retrying vdev blindly."],"tags":["cli","process","exit-code","vdev"],"backgroundTag":"command-execution-failed","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}