{"record":{"id":"222d95f25702a26a","repo":"jdx/mise","slug":"cannot-write-windows-launcher-because-is-not-a-222d95","errorCode":null,"errorMessage":"cannot write Windows launcher because {} is not a regular file","messagePattern":"cannot write Windows launcher because (.+?) is not a regular file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/tool_stub.rs","lineNumber":228,"sourceCode":"    /// for a script of its own, and nothing about that name says mise owns it. The stub itself is\n    /// different: the user named it, so overwriting it is what they asked for.\n    fn validate_windows_launcher(&self, stub_content: &str) -> Result<()> {\n        if !wants_windows_launcher(stub_content) {\n            return Ok(());\n        }\n        let Some(launcher) = super::windows_launcher_path(&self.output) else {\n            return Ok(());\n        };\n        match fs::symlink_metadata(&launcher) {\n            Ok(metadata) if metadata.file_type().is_file() => {\n                if !super::is_generated_launcher(&file::read_to_string(&launcher)?) {\n                    bail!(\n                        \"cannot write Windows launcher because {} is not a generated launcher\",\n                        display_path(&launcher)\n                    );\n                }\n            }\n            Ok(_) => bail!(\n                \"cannot write Windows launcher because {} is not a regular file\",\n                display_path(&launcher)\n            ),\n            Err(err) if matches!(err.kind(), ErrorKind::NotFound | ErrorKind::NotADirectory) => {}\n            Err(err) => return Err(err.into()),\n        }\n        Ok(())\n    }\n\n    fn get_tool_name(&self) -> String {\n        self.output\n            .file_name()\n            .and_then(|name| name.to_str())\n            .unwrap_or(\"tool\")\n            .to_string()\n    }\n\n    async fn generate_stub(&self) -> Result<String> {","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/cli/generate/tool_stub.rs#L210-L246","documentation":"The Windows launcher path `<output>.cmd` exists but is not a regular file (directory, symlink, fifo...). mise cannot write the launcher there, and validation happens before the stub is written, so generation aborts cleanly.","triggerScenarios":"`mise generate tool-stub --output bin/tool` when bin/tool.cmd is a directory (accidental `mkdir bin/tool.cmd`) or other non-file object.","commonSituations":"Misnamed folders; mount points or symlinked directories occupying the launcher path.","solutions":["Remove the object at `<output>.cmd` (`rm -rf` for the directory case)","Pick an `--output` whose `.cmd` sibling path is free","Note: naming the output with an executable extension (.cmd/.bat/.exe) suppresses the sibling launcher entirely, since windows_launcher_path returns None for those"],"exampleFix":"# before\n$ ls -ld bin/tool.cmd   # a directory\n$ mise generate tool-stub --output bin/tool --url https://...\n# error: bin/tool.cmd is not a regular file\n\n# after\n$ rm -rf bin/tool.cmd\n$ mise generate tool-stub --output bin/tool --url https://...","handlingStrategy":"type-guard","validationCode":"#!/bin/bash\nOUT=bin/tool\n[ -e \"$OUT.cmd\" ] && [ ! -f \"$OUT.cmd\" -o -L \"$OUT.cmd\" ] \\\n  && { echo \"$OUT.cmd is not a regular file\" >&2; exit 1; }\nmise generate tool-stub --output \"$OUT\" --url \"$URL\"","typeGuard":"launcher_writable() {\n  # 0 when <stub>.cmd is absent or a plain regular file\n  [ ! -e \"$1.cmd\" ] || { [ -f \"$1.cmd\" ] && [ ! -L \"$1.cmd\" ]; }\n}","tryCatchPattern":null,"preventionTips":["Do not create directories or symlinks named <stub>.cmd next to tool stub outputs","If the .cmd name is taken by a directory, pick a different --output base name","Remember outputs named *.cmd/*.bat/*.exe never get a sibling launcher, which sidesteps the whole path"],"tags":["mise","tool-stub","windows","file-type","generate"],"backgroundTag":"unsupported-file-type","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}