{"id":"4af73dba88a9338b","repo":"BurntSushi/ripgrep","slug":"preprocessor-command-could-not-start-cmd","errorCode":null,"errorMessage":"preprocessor command could not start: '{cmd:?}': {err}","messagePattern":"preprocessor command could not start: '(.+?)': (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/search.rs","lineNumber":307,"sourceCode":"            return true;\n        }\n        !self.config.preprocessor_globs.matched(path, false).is_ignore()\n    }\n\n    /// Search the given file path by first asking the preprocessor for the\n    /// data to search instead of opening the path directly.\n    fn search_preprocessor(\n        &mut self,\n        path: &Path,\n    ) -> io::Result<SearchResult> {\n        use std::{fs::File, process::Stdio};\n\n        let bin = self.config.preprocessor.as_ref().unwrap();\n        let mut cmd = std::process::Command::new(bin);\n        cmd.arg(path).stdin(Stdio::from(File::open(path)?));\n\n        let mut rdr = self.command_builder.build(&mut cmd).map_err(|err| {\n            io::Error::new(\n                io::ErrorKind::Other,\n                format!(\n                    \"preprocessor command could not start: '{cmd:?}': {err}\",\n                ),\n            )\n        })?;\n        let result = self.search_reader(path, &mut rdr).map_err(|err| {\n            io::Error::new(\n                io::ErrorKind::Other,\n                format!(\"preprocessor command failed: '{cmd:?}': {err}\"),\n            )\n        });\n        let close_result = rdr.close();\n        let search_result = result?;\n        close_result?;\n        Ok(search_result)\n    }\n","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/search.rs#L289-L325","documentation":"In SearchWorker::search_preprocessor, the configured preprocessor command is spawned via command_builder.build(&mut cmd). If spawning fails (binary not found, not executable, out of resources), the error is wrapped as format!(\"preprocessor command could not start: '{cmd:?}': {err}\"). It distinguishes a spawn failure from a search failure of an already-running preprocessor.","triggerScenarios":"Configuring SearchWorkerBuilder.preprocessor(path) to a program that does not exist, lacks execute permission, or cannot be forked; PATH does not contain the preprocessor binary.","commonSituations":"rg --pre some-script where some-script is missing or not on PATH; a wrapper script without +x; a CI container missing the preprocessor dependency; a typo in the --pre argument.","solutions":["Confirm the preprocessor binary exists, is executable, and is on PATH (use an absolute path to be safe).","chmod +x the script, or invoke an interpreter explicitly (e.g. /usr/bin/python3 script.py).","Use --pre-glob to restrict preprocessing and verify the binary works standalone on a sample file first."],"exampleFix":"// before\nlet mut b = SearchWorkerBuilder::new();\nb.preprocessor(Path::new(\"mypp\")); // not on PATH -> could not start\n\n// after\nb.preprocessor(Path::new(\"/usr/local/bin/mypp\"));","handlingStrategy":"validation","validationCode":"fn preprocessor_runnable(p: &std::path::Path) -> bool {\n    use std::path::Path;\n    fn on_path(name: &str) -> bool {\n        std::env::var_os(\"PATH\").map(|paths| {\n            std::env::split_paths(&paths).any(|dir| dir.join(name).exists())\n        }).unwrap_or(false)\n    }\n    p.is_absolute() && p.exists() || on_path(p.to_string_lossy().as_ref())\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = run_search_with_preprocessor(path) {\n    eprintln!(\"{e}\"); // could not start\n    return;\n}","preventionTips":["Use absolute paths for the preprocessor binary.","Ensure the binary is executable (chmod +x) and on PATH.","Test the preprocessor standalone on a sample file before wiring it into search."],"tags":["preprocessor","process","spawn","cli"],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}