{"record":{"id":"6058f4dbf7687f81","repo":"jdx/mise","slug":"windows-script-file-name-filename-contains-uns","errorCode":null,"errorMessage":"Windows script file name {filename:?} contains unsupported characters","messagePattern":"Windows script file name (.+?) contains unsupported characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/backend/http.rs","lineNumber":1055,"sourceCode":"    ensure_plain_bin_name(\"windows_script_interpreter\", interpreter)?;\n    if interpreter.is_empty()\n        || !interpreter\n            .chars()\n            .all(|ch| ch.is_ascii_alphanumeric() || matches!(ch, '.' | '_' | '-'))\n    {\n        eyre::bail!(\"windows_script_interpreter: {interpreter:?} must be a plain executable name\");\n    }\n    let filename = script\n        .file_name()\n        .and_then(|filename| filename.to_str())\n        .ok_or_else(|| eyre::eyre!(\"Windows script launcher requires a UTF-8 file name\"))?;\n    ensure_plain_bin_name(\"windows script\", filename)?;\n    if filename.is_empty()\n        || !filename\n            .chars()\n            .all(|ch| ch.is_ascii_alphanumeric() || matches!(ch, '.' | '_' | '-'))\n    {\n        eyre::bail!(\"Windows script file name {filename:?} contains unsupported characters\");\n    }\n    let launcher = script.with_file_name(format!(\"{filename}.cmd\"));\n    let body = format!(\"@echo off\\r\\n{interpreter} \\\"%~dp0{filename}\\\" %*\\r\\n\");\n    Ok((launcher, body))\n}\n\n#[cfg(windows)]\nfn write_windows_script_launcher(script: &Path, interpreter: &str) -> Result<()> {\n    let (launcher, body) = windows_script_launcher(script, interpreter)?;\n    file::write(launcher, body)\n}\n\n/// Returns install-time-only option keys for HTTP backend.\npub(crate) fn install_time_option_keys() -> Vec<String> {\n    vec![\n        \"url\".into(),\n        \"checksum\".into(),\n        \"version_list_url\".into(),","sourceCodeStart":1037,"sourceCodeEnd":1073,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/backend/http.rs#L1037-L1073","documentation":"The script file being wrapped into a Windows .cmd launcher must have a simple ASCII filename (alphanumerics, `.`, `_`, `-`), because the filename is embedded verbatim in the generated command line (`%~dp0<filename>`). Names with spaces, quotes, or non-ASCII characters would break or corrupt the launcher, so mise bails first.","triggerScenarios":"Writing a Windows script launcher for a script whose filename contains spaces, shell metacharacters, or non-ASCII characters (e.g. `my script.sh`, `run(tool).py`).","commonSituations":"Upstream packages shipping script assets with spaces or special characters in their names; non-English locales producing Unicode file names in installed packages.","solutions":["Rename the script to a plain name (e.g. `my_script.py`) before/instead of launching","Wrap the oddly-named script with a simple-named shim script","If the file comes from a package, patch or report the upstream asset naming"],"exampleFix":"// before\nmy script.py    # fails\n// after\nmy_script.py","handlingStrategy":"validation","validationCode":"// bash: reject script filenames unsafe for a .cmd launcher\nf=\"$(basename \"$script\")\"\n[[ \"$f\" =~ ^[A-Za-z0-9._-]+$ ]] || { echo \"rename $f to a plain name\"; exit 1; }","typeGuard":"// rust\nfn is_safe_script_name(s: &str) -> bool {\n    !s.is_empty() && s.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '_' | '-'))\n}","tryCatchPattern":null,"preventionTips":["Rename scripts with spaces or special characters before packaging","Prefer ASCII-only, underscore-separated asset names in packages consumed on Windows","Test Windows installs with the real upstream asset names, not sanitized copies"],"tags":["windows","filename","validation","http-backend"],"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"}