jdx/mise · error

history cannot represent a non-UTF-8 filename; refusing to…

Error message

history cannot represent a non-UTF-8 filename; refusing to change its bytes

What it means

History storage represents file paths as UTF-8 strings; tracked::walk bails when a discovered tracked file path cannot be converted with Path::to_str(). Rather than silently mangling the file's bytes, it refuses to include it.

Solutions

  1. Rename the offending file to a UTF-8-safe name (`convmv` or manual mv).
  2. Move the non-UTF-8 file out of the tracked/captured directories.
  3. Exclude or delete the file if it is no longer needed.

Example fix

// before: file named with raw bytes, e.g. created by `touch $'caf\xe9'`
// after: rename to valid UTF-8
mv $'caf\xe9' cafe.txt
Defensive patterns

Strategy: validation

Validate before calling

if path.to_str().is_none() {
  eprintln!("non-UTF-8 filename not supported: {:?}", path);
  return false;
}

Type guard

fn is_utf8_path(p: &std::path::Path) -> bool { p.to_str().is_some() }

Try / catch

match tracked::walk(...) {
  Err(e) if e.to_string().contains("non-UTF-8 filename") => rename_offenders(),
  other => other?,
}

Prevention

When it happens

Trigger: Calling walk (directly or via list_commands, attempt_locked, live_tree, unsaved_paths) when any walked file path under the config dir or home fails `path.to_str().is_none()`, i.e. contains invalid UTF-8 bytes.

Common situations: Files created with legacy encodings or random-byte names on Linux (filenames are raw bytes); files restored from archives or other OSes with non-UTF-8 names inside a tracked directory.

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


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/e9dd19a6f57649fb. Report an issue: GitHub.

Appendix: source

Thrown at src/system/history/tracked.rs:381

        // a hidden local-only history. Explicit encryption permits key files
        // to be tracked without storing their plaintext.
        walk.files.retain(|path, (_, policy)| {
            if let Some(reason) = capture_exclusion(path, policy) {
                walk.omitted.push(PathReason {
                    path: display_path(path),
                    reason: reason.into(),
                });
                false
            } else {
                true
            }
        });
        walk.entries = set.entries.clone();
        let config = normalize(&global_config_dir());
        let mut roots: BTreeMap<String, CaptureRoot> = BTreeMap::new();
        for (path, (owner, _)) in &walk.files {
            if path.to_str().is_none() {
                eyre::bail!(
                    "history cannot represent a non-UTF-8 filename; refusing to change its bytes"
                );
            }
            let (label, base, relative) = if let Ok(relative) = path.strip_prefix(&config) {
                ("config", config.clone(), relative.to_path_buf())
            } else if let Ok(relative) = path.strip_prefix(&home) {
                ("home", home.clone(), relative.to_path_buf())
            } else {
                (
                    "fs",
                    PathBuf::from(std::path::MAIN_SEPARATOR.to_string()),
                    path.components()
                        .filter(|c| matches!(c, Component::Normal(_)))
                        .collect(),
                )
            };
            let label = walk.entries[*owner]
                .variant

View on GitHub (pinned to 533346cc37)