{"record":{"id":"2291bca5cc91d1cd","repo":"jdx/mise","slug":"localized-dir-raw-cannot-be-carried-to-windo","errorCode":null,"errorMessage":"--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.","messagePattern":"--localized-dir (.+?) cannot be carried to Windows: (.+?) 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\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/install_script.rs","lineNumber":285,"sourceCode":"    rest.trim_start_matches(['\\\\', '/'])\n}\n\n/// The `localized_dir` value for the batch script — the same two rules the bash branch applies:\n/// escape the value, and join it to the project directory only when it is relative.\n///\n/// Refuses a value Windows could not hold rather than emitting one. A directory named `C:foo` is\n/// ordinary on Linux and the bash half installs into it happily, but on Windows `C:foo` is\n/// drive-*relative*, so `%project_dir%\\C:foo` is not a path at all and `mkdir` fails — on the\n/// contributor's machine, not on the machine that generated the file. Calling it rooted instead\n/// would be worse: that drops `%project_dir%\\` and installs wherever cmd's per-drive working\n/// directory happens to point, silently diverging from the bash half.\nfn windows_localized_dir(dir: &Path) -> Result<String> {\n    let raw = dir.to_string_lossy();\n    if let Some(bad) = windows_path_components(&raw)\n        .chars()\n        .find(|c| WINDOWS_FORBIDDEN_IN_COMPONENT.contains(c))\n    {\n        bail!(\n            \"--localized-dir {raw:?} cannot be carried to Windows: {bad:?} is not allowed in a \\\n             path component there, so the generated launcher could not create the directory. \\\n             Drop --windows, or pick a name Windows accepts.\"\n        );\n    }\n    let escaped = cmd_escape(&raw);\n    match is_windows_absolute(&escaped) {\n        true => Ok(escaped),\n        false => Ok(format!(r\"%project_dir%\\{escaped}\")),\n    }\n}\n\n/// Escape a value for interpolation into a `set \"var=…\"` line in the launcher.\n///\n/// Only `%` needs it. The script keeps delayed expansion off, so `!` is already an ordinary\n/// character there — measured: with it off, `set \"d=…\\p6-od!d\"` followed by `mkdir \"%d%\"` creates\n/// `p6-od!d`, and with it on the same two lines create `p6-odd`. A raw `%` would still be read at\n/// parse time, so with `x` set a directory named `my%x%dir` becomes `myCLOBBEREDdir`.","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/generate/install_script.rs#L267-L303","documentation":"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.","triggerScenarios":"Calling generate install-script with both --windows and a --localized-dir containing characters illegal on Windows (< > : \" / \\ | ? * or control chars) in a path component.","commonSituations":"Unix-style dir names with colons or question marks (e.g. 'mise:tools') reused for a Windows target; copy-pasted paths with quotes.","solutions":["Rename --localized-dir to a Windows-safe name (drop : \" / \\ | ? * < >)","Drop --windows so the Windows check is skipped when only generating for Unix","Split the path so illegal characters are not part of any single component"],"exampleFix":"// before\nmise generate install-script --windows --localized-dir 'mise:tools'\n// after\nmise generate install-script --windows --localized-dir 'mise-tools'","handlingStrategy":"validation","validationCode":"case \"$dir\" in *[<>:\"/\\\\|?]*|[!control]*) echo \"invalid for Windows: $dir\";; esac","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only [A-Za-z0-9._-] in paths shared with Windows","Test generated scripts for both platforms in CI"],"tags":["cli","windows","path","generate"],"backgroundTag":"invalid-argument-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}