{"id":"068eb17706ab78b2","repo":"BurntSushi/ripgrep","slug":"error-reading-f-file-from-stdin-stdin-has-alre","errorCode":null,"errorMessage":"error reading -f/--file from stdin: stdin has already been consumed","messagePattern":"error reading -f/--file from stdin: stdin has already been consumed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/flags/hiargs.rs","lineNumber":1066,"sourceCode":"        // not until after it has gone through parsing and some other layers.\n        // If there are a lot of duplicates, then that can lead to a sizeable\n        // extra cost. It is lamentable that we pay the extra cost here to\n        // de-duplicate for a likely uncommon case, but I've seen this have a\n        // big impact on real world data.\n        let mut seen = HashSet::new();\n        let mut patterns = Vec::with_capacity(low.patterns.len());\n        let mut add = |pat: String| {\n            if !seen.contains(&pat) {\n                seen.insert(pat.clone());\n                patterns.push(pat);\n            }\n        };\n        for source in low.patterns.drain(..) {\n            match source {\n                PatternSource::Regexp(pat) => add(pat),\n                PatternSource::File(path) => {\n                    if path == Path::new(\"-\") {\n                        anyhow::ensure!(\n                            !state.stdin_consumed,\n                            \"error reading -f/--file from stdin: stdin \\\n                             has already been consumed\"\n                        );\n                        for pat in grep::cli::patterns_from_stdin()? {\n                            add(pat);\n                        }\n                        state.stdin_consumed = true;\n                    } else {\n                        for pat in grep::cli::patterns_from_path(&path)? {\n                            add(pat);\n                        }\n                    }\n                }\n            }\n        }\n        Ok(Patterns { patterns })\n    }","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/flags/hiargs.rs#L1048-L1084","documentation":"Error \"error reading -f/--file from stdin: stdin has already been consumed\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/core/flags/hiargs.rs:1066 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not use -f/--file with stdin ('-') when stdin is already being consumed by another option","Read patterns from a real file instead of stdin"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}