jdx/mise · error
glob pattern is not valid UTF-8: {}
Error message
glob pattern is not valid UTF-8: {} What it means
glob_walk builds a glob::Pattern from the task pattern path; if the pattern (after prefixing) is not valid UTF-8, pattern_from_path returns None and glob_walk bails, reporting the original Path display. The underlying glob matcher requires UTF-8 patterns, so non-UTF-8 paths cannot be walked.
Source
Thrown at src/task/task_source_checker.rs:527
if !globbing && let Some(file_name) = base.file_name().map(|name| name.to_os_string()) {
base.pop();
glob_pattern.push(file_name);
pattern_depth = 1;
}
while !base.as_os_str().is_empty() && !base.exists() {
let Some(file_name) = base.file_name().map(|name| name.to_os_string()) else {
break;
};
base.pop();
let mut prefixed_pattern = PathBuf::from(file_name);
prefixed_pattern.push(glob_pattern);
glob_pattern = prefixed_pattern;
pattern_depth += 1;
}
let Some(mut glob_pattern) = pattern_from_path(&glob_pattern) else {
bail!("glob pattern is not valid UTF-8: {}", pattern.display());
};
if glob_pattern.starts_with('!') {
glob_pattern.insert(0, '\\');
}
let mut builder = GlobWalkerBuilder::new(&base, glob_pattern)
.follow_links(true)
.sort_by(|a, b| a.file_name().cmp(b.file_name()))
.case_insensitive(case_insensitive);
if !recursive {
builder = builder.max_depth(pattern_depth);
}
Ok(builder.build()?)
}
/// Return a successful walk entry, pruning expected errors from following
/// symlinks that loop or point to a missing target.
pub(crate) fn prune_symlink_walk_error(View on GitHub (pinned to afd2eddd3a)
Solutions
- Rename the offending file/directory to a valid UTF-8 name
- Regenerate or re-extract the files with a UTF-8-safe tool (e.g. `unzip -O UTF-8` or convmv)
- Rewrite the task pattern to point only at UTF-8 paths
Example fix
# before $ ls src '\xff\xfe'notes.md # after convmv -f latin1 -t utf8 -r --notest src # then mise task sources = ['src/*.md'] works
Defensive patterns
Strategy: validation
Validate before calling
// node: reject non-UTF-8 pattern paths before running tasks
const isUtf8 = (s) => Buffer.from(s, 'utf8').toString('utf8') === s;
if (!isUtf8(patternPath)) throw new Error('pattern must be valid UTF-8: ' + patternPath); Type guard
// node
const isValidUtf8Path = (p) => { try { Buffer.from(p, 'utf8'); return Buffer.compare(Buffer.from(p, 'utf8'), Buffer.from(Buffer.from(p, 'utf8').toString('utf8'))) === 0; } catch { return false; } }; Prevention
- Keep file names ASCII/UTF-8 in projects mise manages
- Re-extract archives with UTF-8-aware tools (unzip -O UTF-8, convmv)
- Avoid deriving task patterns from raw byte env vars or legacy-encoded filenames
When it happens
Trigger: Resolving task sources/outputs where the pattern path (base dir or glob component) contains invalid UTF-8 bytes — typically from filenames created outside UTF-8 locales or corrupted archive extraction.
Common situations: Files unpacked with mangled encoding; patterns derived from non-UTF-8 environment variables or filesystem names; project checkouts on filesystems with legacy byte encodings.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- history cannot represent a non-UTF-8 filename; refusing to c
- tracking does not support non-UTF-8 filenames
- rustc output is not a regular file: {}
- brew-cask: structured move with multiple sources requires a
- brew-cask: structured copy source must resolve to exactly on
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/b5d05a1092033bbe.
Report an issue: GitHub.