{"record":{"id":"5cac063825432e6f","repo":"jdx/mise","slug":"cannot-replace-task-stub-directory-because-is-n","errorCode":null,"errorMessage":"cannot replace task stub directory because {} is not a generated task stub","messagePattern":"cannot replace task stub directory because (.+?) is not a generated task stub","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/task_stubs.rs","lineNumber":647,"sourceCode":"    for entry in fs::read_dir(path)? {\n        let entry = entry?;\n        let entry_path = entry.path();\n        let metadata = fs::symlink_metadata(&entry_path)?;\n        if metadata.file_type().is_dir() {\n            let child_files = validate_generated_stub_tree(&entry_path, launchers)?;\n            if child_files == 0 {\n                bail!(\n                    \"cannot replace task stub directory because {} is empty\",\n                    display_path(&entry_path)\n                );\n            }\n            files += child_files;\n        } else if metadata.file_type().is_file() && is_exe_path(&entry_path) {\n            // A native launcher of ours. Checked before anything reads the file as text, which a\n            // binary is not. Not counted towards `files`, same as the `.cmd`: a directory holding\n            // nothing but launchers has no stubs left and should still be reported as empty.\n            if !launchers.owns(&entry_path) {\n                bail!(\n                    \"cannot replace task stub directory because {} is not a generated task stub\",\n                    display_path(&entry_path)\n                );\n            }\n        } else if metadata.file_type().is_file()\n            && is_generated_task_stub(&file::read_to_string(&entry_path)?)\n        {\n            files += 1;\n        } else if metadata.file_type().is_file()\n            && super::is_generated_launcher(&file::read_to_string(&entry_path)?)\n        {\n            // Our own Windows launcher. Not counted towards `files`: a directory holding nothing\n            // but launchers has no stubs left and should still be reported as empty.\n        } else {\n            bail!(\n                \"cannot replace task stub directory because {} is not a generated task stub\",\n                display_path(&entry_path)\n            );","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/generate/task_stubs.rs#L629-L665","documentation":"During stub-tree validation, mise treats executable-extension files as native launchers it generated, and confirms ownership via `Launchers::owns`. If an `.exe`/executable-named file in the stub directory was not created by mise (not in its launcher registry), mise refuses to replace the directory with this error.","triggerScenarios":"Running `mise generate task-stub` against a directory containing a file with an executable extension (e.g. `.exe`) that is not tracked as a mise-generated launcher — a user-placed binary or a stale launcher from a removed output path.","commonSituations":"Users copied real tools/binaries into the stub directory; launcher registry reset (path moved) so previously generated launchers are no longer owned; shared bin directory pointed at as output.","solutions":["Move the foreign executable out of the stub directory","Delete the stale/unowned launcher file","Point `mise generate task-stub` at a dedicated output directory that only contains generated stubs"],"exampleFix":"// before: user's own tool.exe sits in stubs\\\nstubs\\tool.exe  # not owned by mise -> bail\n// after\nmv stubs\\tool.exe .\\tools\\\nmise generate task-stub --output stubs","handlingStrategy":"validation","validationCode":"const foreignExe = fs.readdirSync(stubDir)\n  .filter(f => /\\.(exe|cmd|bat)$/i.test(f))\n  .filter(f => !generatedLauncherRegistry.includes(f));","typeGuard":null,"tryCatchPattern":"try {\n  await exec('mise generate task-stub ...');\n} catch (e) {\n  if (String(e).includes('is not a generated task stub')) {\n    // move foreign executables out of stubDir, then retry\n  }\n}","preventionTips":["Keep user binaries outside mise stub output directories","Regenerate stubs from the same mise version that owns the launchers","Use one output directory exclusively for generated stubs"],"tags":["windows","task-stub","launcher","validation"],"backgroundTag":"unexpected-response-shape","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"}