{"record":{"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/ee20f426ddf338ac7ead5c5f00ea49258005caaf/src/walk.rs#L326-L362","documentation":"After all --exclude patterns are added, build_overrides calls ignore::OverrideBuilder::build (walk.rs:343); if the compiled override set is internally inconsistent (e.g. mutually contradictory or otherwise unbuildable), fd reports 'Mismatch in exclude patterns'. Unlike the per-pattern error above, this is a failure of the combined set.","triggerScenarios":"A combination of --exclude patterns that individually parse but together cannot be compiled by the ignore crate's OverrideBuilder. This is rarer than per-pattern errors and reflects an inconsistency surfaced only at build time.","commonSituations":"Layering many exclude patterns where one negation/scope rule conflicts with another; upgrading the ignore crate to a version with stricter build validation; complex gitignore-style patterns that interact unexpectedly.","solutions":["Reduce the set of --exclude patterns to the minimum and re-add until the conflict reproduces, then rewrite the offending pattern.","Move persistent excludes into a .fdignore / .gitignore file and let fd read them via its ignore machinery instead of many --exclude flags.","Check `fd --help` and the ignore crate docs for glob precedence/negation rules."],"exampleFix":"# before (conflicting excludes)\nfd --exclude '*.log' --exclude '!debug.log' .\n\n# after (use a .fdignore file with precedence-aware rules)\necho '*.log' > .fdignore\necho '!debug.log' >> .fdignore\nfd .","handlingStrategy":"validation","validationCode":"# No cheap pre-check for set-level inconsistency; minimize and test the set.\n# Move complex excludes to .fdignore and validate:\nfd --exclude p1 --exclude p2 --max-depth 0 . >/dev/null 2>&1 || \\\n  echo \"exclude set rejected\" >&2","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --exclude lists small; move complex rules into .fdignore files.","Add excludes incrementally to localize the conflicting pattern.","Review gitignore precedence/negation rules when mixing inclusive and exclusive globs."],"tags":["exclude","glob","walk","cli","ignore"],"backgroundTag":null,"analyzedSha":"ee20f426ddf338ac7ead5c5f00ea49258005caaf","analyzedAt":"2026-08-09T08:21:40.573Z","contentChangedAt":"2026-08-09T08:21:40.573Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}