{"record":{"id":"a0e1a28dd2cbfdaf","repo":"vectordotdev/vector","slug":"could-not-run-command","errorCode":null,"errorMessage":"could not run command","messagePattern":"could not run command","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/app.rs","lineNumber":153,"sourceCode":"        } 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\n        if output.status.success() {\n            Ok(())\n        } else {\n            bail!(\"{}\", format_command_error(&output, None))\n        }\n    }\n\n    /// Print out a pre-execution debug message.\n    fn pre_exec(&self) {\n        debug!(\"Executing: {self:?}\");\n        if let Some(cwd) = self.get_current_dir() {\n            debug!(\"  in working directory {cwd:?}\");\n        }\n        for (key, value) in self.get_envs() {\n            let key = key.to_string_lossy();\n            if let Some(value) = value {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/app.rs#L135-L171","documentation":"In vdev's `wait` helper, a Command is spawned with output captured while a progress bar runs. When `self.output()` returns Err (the child process could not be spawned at all — e.g. the executable was not found or spawning failed), the helper bails with the generic message \"could not run command\". This error signals that the command never executed, as opposed to executing and failing (which produces the `format_command_error` message instead).","triggerScenarios":"Calling `App::wait(...)` (vdev/src/app.rs:143) when the wrapped `Command` fails to spawn: the binary is not on PATH, an invalid working directory was set via `current_dir`, or an invalid environment/program configuration makes `output()` return Err.","commonSituations":"Running vdev on a machine without a required external tool installed (e.g. `gh`, `docker`, `cargo` component missing); a typo'd binary name in a vdev command implementation; setting a `current_dir` that no longer exists before spawning.","solutions":["Install or fix the external binary so it exists on PATH (`which <tool>` to verify).","Check the `Executing: {self:?}` debug output (run with debug logging) to see the exact command and cwd that failed to spawn.","Verify the working directory passed to the command exists (e.g. repo root resolved correctly).","If authoring vdev code, use `format_command_error`/context on the spawn failure so the underlying io::Error is surfaced instead of the generic message."],"exampleFix":"// before\nlet Ok(output) = result else {\n    bail!(\"could not run command\")\n};\n// after\nlet Ok(output) = result else {\n    bail!(\"could not run command `{self:?}`: {}\", result.unwrap_err())\n};","handlingStrategy":"try-catch","validationCode":"// before invoking the vdev flow, ensure the binary is available\nif which::which(\"docker\").is_err() {\n    eprintln!(\"required tool not on PATH\");\n}","typeGuard":"fn is_spawn_failure(err: &anyhow::Error) -> bool {\n    err.chain().any(|c| c.downcast_ref::<std::io::Error>().is_some())\n}","tryCatchPattern":"match cmd.wait(\"building\") {\n    Err(e) if is_spawn_failure(&e) => eprintln!(\"tool missing/failed to spawn: {e}\"),\n    Err(e) => eprintln!(\"command failed: {e}\"),\n    Ok(()) => {}\n}","preventionTips":["Verify external tools are installed and on PATH before running vdev commands.","Run vdev with debug logging to see the exact command, cwd, and env used.","Ensure the working directory passed to commands exists (e.g. correct repo checkout)."],"tags":["process-spawn","cli","command-not-found"],"backgroundTag":"command-not-found","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"}