jdx/mise · error

--localized-dir cannot be carried to Windows: is not…

Error message

--localized-dir {raw:?} cannot be carried to Windows: {bad:?} is not allowed in a path component there, so the generated launcher could not create the directory. Drop --windows, or pick a name Windows accepts.

What it means

When generating a Windows install script with --windows, the --localized-dir value must be a valid Windows path component; mise validates each character against WINDOWS_FORBIDDEN_IN_COMPONENT and bails naming the offending character, since the generated launcher would otherwise fail to create the directory.

Solutions

  1. Rename --localized-dir to a Windows-safe name (drop : " / \ | ? * < >)
  2. Drop --windows so the Windows check is skipped when only generating for Unix
  3. Split the path so illegal characters are not part of any single component

Example fix

// before
mise generate install-script --windows --localized-dir 'mise:tools'
// after
mise generate install-script --windows --localized-dir 'mise-tools'
Defensive patterns

Strategy: validation

Validate before calling

case "$dir" in *[<>:"/\\|?]*|[!control]*) echo "invalid for Windows: $dir";; esac

Prevention

When it happens

Trigger: Calling generate install-script with both --windows and a --localized-dir containing characters illegal on Windows (< > : " / \ | ? * or control chars) in a path component.

Common situations: Unix-style dir names with colons or question marks (e.g. 'mise:tools') reused for a Windows target; copy-pasted paths with quotes.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/cli/generate/install_script.rs:285

    rest.trim_start_matches(['\\', '/'])
}

/// The `localized_dir` value for the batch script — the same two rules the bash branch applies:
/// escape the value, and join it to the project directory only when it is relative.
///
/// Refuses a value Windows could not hold rather than emitting one. A directory named `C:foo` is
/// ordinary on Linux and the bash half installs into it happily, but on Windows `C:foo` is
/// drive-*relative*, so `%project_dir%\C:foo` is not a path at all and `mkdir` fails — on the
/// contributor's machine, not on the machine that generated the file. Calling it rooted instead
/// would be worse: that drops `%project_dir%\` and installs wherever cmd's per-drive working
/// directory happens to point, silently diverging from the bash half.
fn windows_localized_dir(dir: &Path) -> Result<String> {
    let raw = dir.to_string_lossy();
    if let Some(bad) = windows_path_components(&raw)
        .chars()
        .find(|c| WINDOWS_FORBIDDEN_IN_COMPONENT.contains(c))
    {
        bail!(
            "--localized-dir {raw:?} cannot be carried to Windows: {bad:?} is not allowed in a \
             path component there, so the generated launcher could not create the directory. \
             Drop --windows, or pick a name Windows accepts."
        );
    }
    let escaped = cmd_escape(&raw);
    match is_windows_absolute(&escaped) {
        true => Ok(escaped),
        false => Ok(format!(r"%project_dir%\{escaped}")),
    }
}

/// Escape a value for interpolation into a `set "var=…"` line in the launcher.
///
/// Only `%` needs it. The script keeps delayed expansion off, so `!` is already an ordinary
/// character there — measured: with it off, `set "d=…\p6-od!d"` followed by `mkdir "%d%"` creates
/// `p6-od!d`, and with it on the same two lines create `p6-odd`. A raw `%` would still be read at
/// parse time, so with `x` set a directory named `my%x%dir` becomes `myCLOBBEREDdir`.

View on GitHub (pinned to 533346cc37)