{"record":{"id":"4ffdaeea038ef927","repo":"xai-org/grok-build","slug":"command-failed-to-start-e","errorCode":null,"errorMessage":"command failed to start: {e}","messagePattern":"command failed to start: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/auth/auth_provider.rs","lineNumber":288,"sourceCode":"\n/// Spawn `cmd`, capture stdout/stderr with a byte cap (reading both\n/// concurrently so a full pipe on one can't deadlock the other; a runaway helper\n/// is drained to a sink past the cap so it can't wedge the wait), and bound the\n/// whole run by `timeout`. Exceeding the stdout cap is an error.\n///\n/// On timeout the child's entire process group is killed. The helper is a group\n/// leader (`detach_command`'s `setsid`), so a compound `sh -c` helper's\n/// grandchildren -- and the `GROK_AUTH_PROVIDER_*` credentials in their env --\n/// do not outlive the reported timeout; `kill_on_drop` alone would reap only the\n/// direct child.\nasync fn run_capped(\n    cmd: &mut tokio::process::Command,\n    timeout: std::time::Duration,\n) -> anyhow::Result<std::process::Output> {\n    #[allow(clippy::disallowed_methods)] // killed at the timeout this call reports\n    let mut child = cmd\n        .spawn()\n        .map_err(|e| anyhow::anyhow!(\"command failed to start: {e}\"))?;\n    // Enroll the child's process group so the timeout path can tear down the\n    // whole tree. Best-effort: if enrollment fails, `kill_on_drop` still reaps\n    // the direct child.\n    let mut group = xai_grok_tools::util::ProcessGroup::new()\n        .map_err(|e| anyhow::anyhow!(\"process group setup failed: {e}\"))?;\n    if let Err(e) = group.attach(&child) {\n        tracing::debug!(error = %e, \"auth provider: could not enroll helper process group\");\n    }\n    let stdout = child.stdout.take().expect(\"stdout is piped\");\n    let stderr = child.stderr.take().expect(\"stderr is piped\");\n    let mut out_buf = Vec::new();\n    let mut err_buf = Vec::new();\n\n    // One extra stdout byte so an over-cap write is detectable, not truncated.\n    // The stderr read is advisory (it only feeds the failure log), so only\n    // stdout governs the mint.\n    let capture = async {\n        let (out_res, err_res) = tokio::join!(","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/auth/auth_provider.rs#L270-L306","documentation":"run_capped spawns a helper auth provider command via tokio::process; if spawn() itself fails the error is wrapped as 'command failed to start'. This happens before any timeout/capture logic.","triggerScenarios":"mint_provider_token invoking a helper binary that does not exist, lacks execute permission, or whose interpreter is missing (ENOENT/EACCES).","commonSituations":"Provider CLI not installed or not on PATH after an environment change, wrong config path to the helper, missing shebang interpreter, or container images without the helper binary.","solutions":["Verify the helper command exists and is executable: run it manually and check `which <cmd>`","Fix the configured path/PATH so the binary is found","If packaged, ensure the helper ships with the build/container image"],"exampleFix":"// before\nprovider_cmd = \"~/tools/grok-auth-helper\"; // not expanded, ENOENT\n// after\nprovider_cmd = \"/usr/local/bin/grok-auth-helper\";","handlingStrategy":"validation","validationCode":"use std::process::Command;\nlet ok = Command::new(cmd_path)\n    .arg(\"--version\")\n    .output()\n    .map(|o| o.status.success())\n    .unwrap_or(false);\nassert!(ok, \"auth helper {cmd_path} missing or not executable\");","typeGuard":null,"tryCatchPattern":"match mint_provider_token().await {\n    Err(e) if e.to_string().starts_with(\"command failed to start\") => {\n        eprintln!(\"auth helper missing: {e}; install it or fix PATH\");\n    }\n    other => other?,\n}","preventionTips":["Check the helper binary exists at startup (which <cmd> or Path::exists)","Pin absolute paths in configuration","Include the helper in container images and install docs"],"tags":["process","spawn","command"],"backgroundTag":"command-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}