{"id":"d8e3674311532590","repo":"BurntSushi/ripgrep","slug":"error-attempted-to-read-patterns-from-stdin-while","errorCode":null,"errorMessage":"error: attempted to read patterns from stdin while also searching stdin","messagePattern":"error: attempted to read patterns from stdin while also searching stdin","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/flags/hiargs.rs","lineNumber":1121,"sourceCode":"}\n\nimpl Paths {\n    /// Drain the search paths out of the given low arguments.\n    fn from_low_args(\n        state: &mut State,\n        _: &Patterns,\n        low: &mut LowArgs,\n    ) -> anyhow::Result<Paths> {\n        // We require a `&Patterns` even though we don't use it to ensure that\n        // patterns have already been read from LowArgs. This let's us safely\n        // assume that all remaining positional arguments are intended to be\n        // file paths.\n\n        let mut paths = Vec::with_capacity(low.positional.len());\n        for osarg in low.positional.drain(..) {\n            let path = PathBuf::from(osarg);\n            if state.stdin_consumed && path == Path::new(\"-\") {\n                anyhow::bail!(\n                    \"error: attempted to read patterns from stdin \\\n                     while also searching stdin\",\n                );\n            }\n            paths.push(path);\n        }\n        log::debug!(\"number of paths given to search: {}\", paths.len());\n        if !paths.is_empty() {\n            let is_one_file = paths.len() == 1\n                // Note that we specifically use `!paths[0].is_dir()` here\n                // instead of `paths[0].is_file()`. Namely, the latter can\n                // return `false` even when the path is something resembling\n                // a file. So instead, we just consider the path a file as\n                // long as we know it isn't a directory.\n                //\n                // See: https://github.com/BurntSushi/ripgrep/issues/2736\n                && (paths[0] == Path::new(\"-\") || !paths[0].is_dir());\n            log::debug!(\"is_one_file? {is_one_file:?}\");","sourceCodeStart":1103,"sourceCodeEnd":1139,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/flags/hiargs.rs#L1103-L1139","documentation":"Error \"error: attempted to read patterns from stdin while also searching stdin\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/core/flags/hiargs.rs:1121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Either read patterns from stdin (-f -) or search stdin, not both","Redirect patterns from a file and let stdin be searched, or vice versa"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}