{"id":"03f6b4faece9c4f6","repo":"sharkdp/fd","slug":"mismatch-in-exclude-patterns","errorCode":null,"errorMessage":"Mismatch in exclude patterns","messagePattern":"Mismatch in exclude patterns","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/walk.rs","lineNumber":344,"sourceCode":"            interrupt_flag,\n        }\n    }\n\n    fn build_overrides(&self, paths: &[PathBuf]) -> Result<Override> {\n        let first_path = &paths[0];\n        let config = &self.config;\n\n        let mut builder = OverrideBuilder::new(first_path);\n\n        for pattern in &config.exclude_patterns {\n            builder\n                .add(pattern)\n                .map_err(|e| anyhow!(\"Malformed exclude pattern: {}\", e))?;\n        }\n\n        builder\n            .build()\n            .map_err(|_| anyhow!(\"Mismatch in exclude patterns\"))\n    }\n\n    fn build_walker(&self, paths: &[PathBuf]) -> Result<WalkParallel> {\n        let first_path = &paths[0];\n        let config = &self.config;\n        let overrides = self.build_overrides(paths)?;\n\n        let mut builder = WalkBuilder::new(first_path);\n        builder\n            .hidden(config.ignore_hidden)\n            .ignore(config.read_fdignore)\n            .parents(config.read_parent_ignore && (config.read_fdignore || config.read_vcsignore))\n            .git_ignore(config.read_vcsignore)\n            .git_global(config.read_vcsignore)\n            .git_exclude(config.read_vcsignore)\n            .require_git(config.require_git_to_read_vcsignore)\n            .overrides(overrides)\n            .follow_links(config.follow_links)","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/sharkdp/fd/blob/41532d114e2ba565fb5367d606c111b29b96450c/src/walk.rs#L326-L362","documentation":"Thrown by WorkerState::build_overrides in src/walk.rs:344 when OverrideBuilder::build() fails after every individual add() succeeded. The ignore crate's OverrideBuilder can fail at build time when the accumulated set of patterns cannot be compiled together (e.g. mutually contradictory matchers or an internal consistency error).","triggerScenarios":"Combining several --exclude patterns whose union the ignore crate cannot compile into a single matcher; extremely large or pathological pattern sets; rare internal inconsistency after all adds passed.","commonSituations":"A long list of --exclude flags generated from a script producing a contradictory set; version differences in the ignore crate's glob compiler rejecting an edge case only at build time.","solutions":["Reduce the --exclude set to a minimal reproduction and identify the offending pair/pattern.","Re-express conflicting patterns (e.g. consolidate '**/foo' and 'foo' variants into one).","Move complex exclusions into a .fdignore/.gitignore file (which uses a different compilation path) and drop the corresponding --exclude flags.","Check the ignore crate version/changelog if a previously working pattern set started failing after a dependency bump."],"exampleFix":"// before\nfd --exclude 'foo/**' --exclude 'foo' bar\n\n// after\nfd --exclude 'foo' bar","handlingStrategy":"validation","validationCode":"# in automation, keep --exclude sets small and internally consistent\nif [ \"${#EXCLUDES[@]}\" -gt 16 ]; then\n  echo \"too many --exclude patterns; move them to .fdignore\" >&2; exit 1\nfi\nfd \"${EXCLUDES[@]/#/--exclude }\" \"$PAT\"","typeGuard":"use ignore::overrides::OverrideBuilder;\nfn exclude_set_builds(base: &str, pats: &[&str]) -> bool {\n    let mut b = OverrideBuilder::new(base);\n    pats.iter().all(|p| b.add(p).is_ok()) && b.build().is_ok()\n}","tryCatchPattern":null,"preventionTips":["Consolidate overlapping exclude patterns to avoid build-time conflicts.","Move large/complex exclude sets into .fdignore/.gitignore files.","Pin the ignore crate version in builds that rely on a specific glob compiler behavior."],"tags":["exclude","glob","ignore","build-error"],"analyzedSha":"41532d114e2ba565fb5367d606c111b29b96450c","analyzedAt":"2026-08-06T01:39:28.509Z","schemaVersion":2}