{"record":{"id":"29fd16f5c61623a8","repo":"sharkdp/fd","slug":"the-pattern-s-seems-to-only-match-files-with-a-le","errorCode":null,"errorMessage":"The pattern(s) seems to only match files with a leading dot, but hidden files are filtered by default. Consider adding -H/--hidden to search hidden files as well or adjust your search pattern(s).","messagePattern":"The pattern\\(s\\) seems to only match files with a leading dot, but hidden files are filtered by default\\. Consider adding -H/--hidden to search hidden files as well or adjust your search pattern\\(s\\)\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"src/main.rs","lineNumber":531,"sourceCode":"                \"'{}' is not a valid date or duration. See 'fd --help'.\",\n                t\n            ));\n        }\n    }\n    Ok(time_constraints)\n}\n\nfn ensure_use_hidden_option_for_leading_dot_pattern(\n    config: &Config,\n    pattern_regexps: &[String],\n) -> Result<()> {\n    if cfg!(unix)\n        && config.ignore_hidden\n        && pattern_regexps\n            .iter()\n            .any(|pat| pattern_matches_strings_with_leading_dot(pat))\n    {\n        Err(anyhow!(\n            \"The pattern(s) seems to only match files with a leading dot, but hidden files are \\\n            filtered by default. Consider adding -H/--hidden to search hidden files as well \\\n            or adjust your search pattern(s).\"\n        ))\n    } else {\n        Ok(())\n    }\n}\n\nfn build_regex(pattern_regex: String, config: &Config) -> Result<regex::bytes::Regex> {\n    RegexBuilder::new(&pattern_regex)\n        .case_insensitive(!config.case_sensitive)\n        .dot_matches_new_line(true)\n        .build()\n        .map_err(|e| {\n            anyhow!(\n                \"{}\\n\\nNote: You can search for literal substrings with '--fixed-strings' \\\n                 or literal strings with '--exact' options (instead of a regular expression). \\","sourceCodeStart":513,"sourceCodeEnd":549,"githubUrl":"https://github.com/sharkdp/fd/blob/ee20f426ddf338ac7ead5c5f00ea49258005caaf/src/main.rs#L513-L549","documentation":"ensure_use_hidden_option_for_leading_dot_pattern (main.rs:521) uses pattern_matches_strings_with_leading_dot to detect a regex that starts with '^\\.' (start anchor followed by a literal dot) and therefore can only ever match hidden/dotfiles. Since fd filters hidden files by default, such a pattern would silently return nothing; fd errors instead with a hint to add -H. Unix-only.","triggerScenarios":"Running `fd '^.gitignore'`, `fd '^\\.config'`, or any pattern the HIR analysis detects as start-anchored-on-dot, while hidden files are filtered (the default, no -H). The detector (regex_helper.rs:40) only catches the simple ^\\.literal form.","commonSituations":"Searching for dotfiles without realizing -H is required; scripts ported from `find . -name '.git*'` that assume hidden files are searched by default.","solutions":["Add -H/--hidden to include hidden files: `fd -H '^.gitignore'`.","If you did not intend to search dotfiles, adjust the pattern (e.g. drop the leading '^\\.').","Use --no-hidden explicitly if you want to confirm the filter is intentional, or --hidden to disable filtering."],"exampleFix":"# before\nfd '^.gitignore'\n\n# after\nfd -H '^.gitignore'","handlingStrategy":"validation","validationCode":"if printf '%s' \"$PATTERN\" | grep -Eq '^\\\\^\\\\\\.'; then\n  fd -H \"$PATTERN\"  # leading-dot pattern: include hidden\nelse\n  fd \"$PATTERN\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add -H/--hidden whenever searching for dotfiles.","If a dot is not intended as a hidden-file prefix, rewrite the pattern.","Document that hidden files are excluded by default for new users."],"tags":["pattern","hidden-files","regex","cli","unix"],"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"}