{"record":{"id":"1bf35b3fab21de84","repo":"xai-org/grok-build","slug":"failed-to-spawn-ripgrep","errorCode":null,"errorMessage":"Failed to spawn ripgrep: {}","messagePattern":"Failed to spawn ripgrep: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/file_system/content.rs","lineNumber":146,"sourceCode":"\n/// Streaming content search with batched status notifications. Cancellation\n/// is dropping the future: the spawn config kills rg on drop.\npub async fn content_search_streaming<F>(\n    root: &Path,\n    params: &ContentSearchParams,\n    on_status: F,\n) -> anyhow::Result<ContentSearchData>\nwhere\n    F: Fn(ContentSearchBatch) + Send + 'static,\n{\n    let max_files = params.max_files.unwrap_or(DEFAULT_MAX_FILES);\n    let max_matches = params.max_matches.unwrap_or(DEFAULT_MAX_MATCHES);\n\n    let mut cmd = build_ripgrep_command(root, params);\n    #[allow(clippy::disallowed_methods)] // waited on below; killed on drop (cancellation)\n    let mut child = cmd\n        .spawn()\n        .map_err(|e| anyhow::anyhow!(\"Failed to spawn ripgrep: {}\", e))?;\n\n    let stdout = child\n        .stdout\n        .take()\n        .ok_or_else(|| anyhow::anyhow!(\"Failed to capture ripgrep stdout\"))?;\n\n    let mut reader = BufReader::new(stdout).lines();\n    let mut files: Vec<ContentMatchFile> = Vec::new();\n    let mut current_file: Option<ContentMatchFile> = None;\n    let mut total_matches = 0usize;\n    let mut pending_files: Vec<ContentMatchFile> = Vec::new();\n    let mut last_notify = Instant::now();\n    let mut hit_limit = false;\n\n    while let Ok(Some(line)) = reader.next_line().await {\n        if line.is_empty() {\n            continue;\n        }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/file_system/content.rs#L128-L164","documentation":"content_search_streaming builds a ripgrep command via build_ripgrep_command and spawns it as a child process. This error is thrown when std Command::spawn fails — i.e. the ripgrep binary could not be located or executed at all. The underlying io::Error is included in the message.","triggerScenarios":"Calling content_search_streaming when the `rg` binary is not on PATH, the path configured for ripgrep does not exist, the binary lacks execute permission, or an exec-format/architecture mismatch occurs.","commonSituations":"ripgrep not installed in a container/CI image; a bundled rg path pointing at a stripped binary; permissions stripped by packaging; running on an OS/arch the rg build does not support.","solutions":["Install ripgrep (`cargo install ripgrep`, `apt install ripgrep`, `brew install ripgrep`) or verify `rg` resolves with `which rg`.","If the tooling lets you configure the rg path, point it at a valid executable and chmod +x it.","Ensure the PATH seen by the process includes the directory containing rg (container/CI images often have minimal PATHs).","Match the rg binary architecture/OS to the host."],"exampleFix":"// before: fails when rg is missing\ncontent_search_streaming(root, params).await?;\n// after: fail fast with a clear prerequisite\nif which::which(\"rg\").is_err() {\n    anyhow::bail!(\"ripgrep is required; install it or set the rg path\");\n}\ncontent_search_streaming(root, params).await?;","handlingStrategy":"validation","validationCode":"use std::process::Command;\nfn ripgrep_available() -> bool {\n    Command::new(\"rg\").arg(\"--version\").output().map(|o| o.status.success()).unwrap_or(false)\n}\nassert!(ripgrep_available(), \"ripgrep ('rg') must be installed and on PATH\");","typeGuard":null,"tryCatchPattern":"match content_search_streaming(root, params).await {\n    Ok(matches) => matches,\n    Err(e) if e.to_string().starts_with(\"Failed to spawn ripgrep\") => {\n        eprintln!(\"ripgrep is not installed; run: cargo install ripgrep\");\n        std::process::exit(1);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Install ripgrep in all deployment images (Dockerfile: apt-get install -y ripgrep)","Run `rg --version` in CI setup as a smoke check","Keep PATH consistent between dev and production environments"],"tags":["ripgrep","process-spawn","filesystem","missing-binary"],"backgroundTag":"command-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}