sharkdp/fd · warning · anyhow::Error
The pattern(s) seems to only match files with a leading…
Error message
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).
What it means
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.
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.
Example fix
# before fd '^.gitignore' # after fd -H '^.gitignore'
Defensive patterns
Strategy: validation
Validate before calling
if printf '%s' "$PATTERN" | grep -Eq '^\\^\\\.'; then fd -H "$PATTERN" # leading-dot pattern: include hidden else fd "$PATTERN" fi
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Searching for dotfiles without realizing -H is required; scripts ported from `find . -name '.git*'` that assume hidden files are searched by default.
Related errors
- Note: You can search for literal substrings with…
- more than one ':' present in owner string
- The search pattern ' ' contains a path-separation character…
- A path separator must be exactly one byte, but the given…
- Could not retrieve current directory (has it been deleted?).
AI-assisted analysis of sharkdp/fd@ee20f426dd (2026-08-09).
Data as JSON: /api/errors/29fd16f5c61623a8.
Report an issue: GitHub.
Appendix: source
Thrown at src/main.rs:531
"'{}' is not a valid date or duration. See 'fd --help'.",
t
));
}
}
Ok(time_constraints)
}
fn ensure_use_hidden_option_for_leading_dot_pattern(
config: &Config,
pattern_regexps: &[String],
) -> Result<()> {
if cfg!(unix)
&& config.ignore_hidden
&& pattern_regexps
.iter()
.any(|pat| pattern_matches_strings_with_leading_dot(pat))
{
Err(anyhow!(
"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)."
))
} else {
Ok(())
}
}
fn build_regex(pattern_regex: String, config: &Config) -> Result<regex::bytes::Regex> {
RegexBuilder::new(&pattern_regex)
.case_insensitive(!config.case_sensitive)
.dot_matches_new_line(true)
.build()
.map_err(|e| {
anyhow!(
"{}\n\nNote: You can search for literal substrings with '--fixed-strings' \
or literal strings with '--exact' options (instead of a regular expression). \View on GitHub (pinned to ee20f426dd)