{"record":{"id":"40b086e57ff3f393","repo":"jdx/mise","slug":"cannot-write-windows-launcher-because-is-not-a-40b086","errorCode":null,"errorMessage":"cannot write Windows launcher because {} is not a generated launcher","messagePattern":"cannot write Windows launcher because (.+?) is not a generated launcher","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/tool_stub.rs","lineNumber":237,"sourceCode":"        Ok(None)\n    }\n\n    /// Refuse to replace a `.cmd` beside the stub that mise did not write.\n    ///\n    /// `--output` is the user's choice, so `<stub>.cmd` is a name a project may already be using\n    /// 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()","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/generate/tool_stub.rs#L219-L255","documentation":"In `mise generate tool-stub` on Windows, mise writes a companion Windows launcher file. If the launcher path already exists as a regular file but its content fails the `is_generated_launcher` check, mise bails with this error rather than overwriting a file it did not generate. This prevents overwriting user files that happen to occupy the launcher path.","triggerScenarios":"Running `mise generate tool-stub` where the computed Windows launcher path exists as a regular file whose content is not a mise-generated launcher — e.g. a user-created script, a downloaded binary, or a launcher from another tool.","commonSituations":"Users placed their own script at the launcher path; stubs were generated into a directory shared with other tools; an older mise's launcher format no longer matches the current generated marker.","solutions":["Remove or rename the existing file at the launcher path and re-run generation","Inspect the file's content; if it's a stale mise launcher, delete it so a fresh one is written","Generate into a clean dedicated output path"],"exampleFix":"// before: custom script occupies launcher path\nstubs\\tool.cmd  # user-written, not generated -> bail\n// after\nmv stubs\\tool.cmd .\\scripts\\\nmise generate tool-stub --url https://example.com/tool","handlingStrategy":"validation","validationCode":"if (fs.existsSync(launcherPath) && fs.lstatSync(launcherPath).isFile()) {\n  const content = fs.readFileSync(launcherPath, 'utf8');\n  if (!content.includes('generated by mise')) throw new Error('non-generated file at launcher path');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await exec('mise generate tool-stub ...');\n} catch (e) {\n  if (String(e).includes('is not a generated launcher')) {\n    fs.renameSync(launcherPath, launcherPath + '.bak');\n    await exec('mise generate tool-stub ...');\n  }\n}","preventionTips":["Keep launcher paths free of user scripts and third-party files","Regenerate launcher-occupied stub dirs from the same mise version","Inspect unknown files at launcher paths before deleting them"],"tags":["windows","tool-stub","launcher","file-conflict"],"backgroundTag":"file-already-exists","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"}