BurntSushi/ripgrep · error

preprocessor command failed: '{cmd:?}': {err}

Error message

preprocessor command failed: '{cmd:?}': {err}

What it means

In search_preprocessor, after the command spawns successfully, search_reader runs over the preprocessor's stdout. If reading or searching that stream fails (preprocessor exited non-zero, closed stdout early, wrote invalid data), the error is wrapped as format!("preprocessor command failed: '{cmd:?}': {err}"). It signals the preprocessor ran but did not produce usable output.

Source

Thrown at crates/core/search.rs:315

        &mut self,
        path: &Path,
    ) -> io::Result<SearchResult> {
        use std::{fs::File, process::Stdio};

        let bin = self.config.preprocessor.as_ref().unwrap();
        let mut cmd = std::process::Command::new(bin);
        cmd.arg(path).stdin(Stdio::from(File::open(path)?));

        let mut rdr = self.command_builder.build(&mut cmd).map_err(|err| {
            io::Error::new(
                io::ErrorKind::Other,
                format!(
                    "preprocessor command could not start: '{cmd:?}': {err}",
                ),
            )
        })?;
        let result = self.search_reader(path, &mut rdr).map_err(|err| {
            io::Error::new(
                io::ErrorKind::Other,
                format!("preprocessor command failed: '{cmd:?}': {err}"),
            )
        });
        let close_result = rdr.close();
        let search_result = result?;
        close_result?;
        Ok(search_result)
    }

    /// Attempt to decompress the data at the given file path and search the
    /// result. If the given file path isn't recognized as a compressed file,
    /// then search it without doing any decompression.
    fn search_decompress(&mut self, path: &Path) -> io::Result<SearchResult> {
        let Some(ref decomp_builder) = self.decomp_builder else {
            return self.search_path(path);
        };
        let mut rdr = decomp_builder.build(path)?;

View on GitHub (pinned to 3fce3b5bb0)

Solutions

  1. Run the preprocessor manually on the same file (preprocessor <file>) and inspect its exit code and stderr.
  2. Fix the script so it exits 0 and writes complete output to stdout.
  3. Ensure the preprocessor does not close stdout prematurely and handles the file argument correctly.
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = search_preprocessor(path) {
    eprintln!("{e}"); // command failed mid-run
}

Prevention

When it happens

Trigger: The preprocessor binary starts but crashes, exits non-zero, is killed (OOM), or closes its stdout pipe before emitting all data, causing search_reader (or the subsequent rdr.close()) to observe an IO error.

Common situations: A preprocessor script with a bug that panics; a decompressor failing on a truncated archive; a wrapper that requires args the caller did not pass; memory pressure killing the child.

Related errors


AI-assisted analysis of BurntSushi/ripgrep@3fce3b5bb0 (2026-08-06). Data as JSON: /data/errors/479f12aa1bdcb259.json. Report an issue: GitHub.