XAMPPRocky/tokei · error
Excludes provided were invalid
Error message
Excludes provided were invalid
What it means
This panic comes from `overrides.build().expect("Excludes provided were invalid")` in `get_all_files` (src/utils/fs.rs:37). It wraps the `OverrideBuilder::build()` call from the `ignore` crate, which returns `Err` if any glob added via `overrides.add("!<dir>")` is not a syntactically valid glob. The tool cannot construct the directory walker's override set, so it aborts instead of walking with incorrect exclusion rules.
Source
Thrown at src/utils/fs.rs:37
) {
let languages = parking_lot::Mutex::new(languages);
let (tx, rx) = crossbeam_channel::unbounded();
let mut paths = paths.iter();
let mut walker = WalkBuilder::new(paths.next().unwrap());
for path in paths {
walker.add(path);
}
if !ignored_directories.is_empty() {
let mut overrides = OverrideBuilder::new(".");
for ignored in ignored_directories {
rs_error!(overrides.add(&format!("!{}", ignored)));
}
walker.overrides(overrides.build().expect("Excludes provided were invalid"));
}
let ignore = config.no_ignore.map(|b| !b).unwrap_or(true);
let ignore_dot = ignore && config.no_ignore_dot.map(|b| !b).unwrap_or(true);
let ignore_vcs = ignore && config.no_ignore_vcs.map(|b| !b).unwrap_or(true);
// Custom ignore files always work even if the `ignore` option is false,
// so we only add if that option is not present.
if ignore_dot {
walker.add_custom_ignore_filename(IGNORE_FILE);
}
walker
.git_exclude(ignore_vcs)
.git_global(ignore_vcs)
.git_ignore(ignore_vcs)
.hidden(config.hidden.map(|b| !b).unwrap_or(true))
.ignore(ignore_dot)View on GitHub (pinned to fa44e51940)
Solutions
- Fix the ignore entry in the config/CLI argument so it is a valid glob — remove or escape stray metacharacters (`[`, `]`, `{`, `}`), e.g. use `node_modules` or `**/node_modules/**`
- Test the pattern with a glob matcher (e.g. the `globset` crate or a gitignore checker) before passing it to the tool
- Simplify the pattern: plain directory names like `target` or `dist` are usually enough; avoid absolute paths and trailing slashes
- If you maintain the library, replace `.expect` with error propagation so the user's config reports which pattern was invalid instead of panicking
Example fix
// before ignored_directories = ["node_modules[", "target/"] // after ignored_directories = ["node_modules", "target"]
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_exclude_pattern(pattern: &str) -> bool {
// reject unbalanced brackets/braces and absolute paths before adding "!"
let open = pattern.matches('[').count();
let close = pattern.matches(']').count();
let brace_open = pattern.matches('{').count();
let brace_close = pattern.matches('}').count();
open == close && brace_open == brace_close
&& !pattern.starts_with('/')
&& !globset::Glob::new(pattern).is_err()
} Try / catch
let overrides = match overrides_builder.build() {
Ok(o) => o,
Err(e) => {
eprintln!("Invalid exclude pattern in config: {}", e);
return Err(e);
}
};
walker.overrides(overrides); Prevention
- Keep ignore entries as simple relative directory names (`target`, `node_modules`, `dist`) unless globs are truly needed
- Validate glob syntax with the `globset` crate before writing patterns to config
- Do not use absolute paths or leading/trailing slashes in exclude entries
- Check shell quoting when patterns come from the command line — test the exact string the tool receives
- Document the accepted glob syntax for users editing the config file
When it happens
Trigger: Calling `get_all_files` with an `ignored_directories` entry that produces an invalid glob when prefixed with `!` — e.g. a path containing an unclosed `[`, an invalid `**` placement, or other glob metacharacter mistakes. Note that entries with simple malformed glob syntax can panic here even though each individual `overrides.add` was checked by `rs_error!` earlier (build-time validation can still fail).
Common situations: Users writing exclude patterns copied from .gitignore syntax with unsupported glob features; a config value like `ignored_directories = ["node_modules[", "target/**/"]` with bracket/escape errors; shell-quoting stripping or adding characters so the pattern reaching the builder differs from what the user intended; trailing slashes or absolute paths used where a relative glob is expected.
Related errors
AI-assisted analysis of XAMPPRocky/tokei@fa44e51940 (2026-09-06).
Data as JSON: /api/errors/7967a7bdf70f5d3e.
Report an issue: GitHub.