{"record":{"id":"9f4910f2fb39bc9a","repo":"jdx/mise","slug":"cannot-create-nested-task-stubs-because-is-not","errorCode":null,"errorMessage":"cannot create nested task stubs because {} is not the generated stub for task {}","messagePattern":"cannot create nested task stubs because (.+?) is not the generated stub for task (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/task_stubs.rs","lineNumber":509,"sourceCode":"                display_path(path)\n            );\n        }\n    }\n    Ok(paths)\n}\n\nfn validate_stub_paths(\n    dir: &Path,\n    stubs: &[TaskStub<'_>],\n    launchers: &Launchers,\n) -> Result<Vec<StubMigration>> {\n    let mut migrations = HashSet::new();\n    for stub in stubs.iter().filter(|stub| stub.legacy_path != stub.path) {\n        match fs::symlink_metadata(&stub.legacy_path) {\n            Ok(metadata) if metadata.file_type().is_file() => {\n                let existing = file::read_to_string(&stub.legacy_path)?;\n                if existing != stub.output && existing != stub.legacy_output {\n                    bail!(\n                        \"cannot create nested task stubs because {} is not the generated stub for task {}\",\n                        display_path(&stub.legacy_path),\n                        stub.task.display_name\n                    );\n                }\n                migrations.insert(StubMigration::File(stub.legacy_path.clone()));\n            }\n            Ok(metadata) if metadata.file_type().is_dir() => {}\n            Ok(_) => bail!(\n                \"cannot create nested task stubs because {} is not a directory\",\n                display_path(&stub.legacy_path)\n            ),\n            Err(err) if matches!(err.kind(), ErrorKind::NotFound | ErrorKind::NotADirectory) => {}\n            Err(err) => return Err(err.into()),\n        }\n    }\n\n    for stub in stubs {","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/generate/task_stubs.rs#L491-L527","documentation":"When migrating flat task stubs to nested ones, mise may need to replace a legacy stub path with a directory. If the legacy path exists as a regular file whose content is neither the current nor legacy generated stub output, mise refuses to overwrite a file it did not generate, protecting hand-written files from destruction.","triggerScenarios":"Running `mise generate task-stubs` where a task's legacy stub path (flat layout) exists as a file with user-modified or unrelated content, while the new layout places stubs in a directory of that name.","commonSituations":"Developers edited a previously generated stub by hand and later enabled nested task stubs; a checked-in script occupies the path that the nested stub directory needs; generated from an older mise version with different stub content.","solutions":["Restore the legacy path's file content to the exact generated stub output (regenerate it with the old layout) so migration can proceed","Delete or move the unrecognized file at the legacy path if it is not needed","Check the file into a different location if it is hand-written, since mise will never overwrite non-generated files"],"exampleFix":"// before: hand-edited legacy stub\n#!/bin/sh\nmise x -- my-task \"$@\" # custom tweaks\n// after: regenerate or remove so it matches stub output\nrm .mise/tasks/build && mise generate task-stubs","handlingStrategy":"validation","validationCode":"const legacy = fs.readFileSync(legacyStubPath, 'utf8');\nif (legacyStubExists && legacy !== generatedOutput && legacy !== legacyOutput) {\n  throw new Error(`${legacyStubPath} was modified by hand; save it and remove before nested migration`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync('mise generate task-stubs');\n} catch (e) {\n  if (String(e).includes('is not the generated stub for task')) {\n    console.error('Back up the hand-edited legacy stub, delete it, rerun generation');\n  }\n}","preventionTips":["Never hand-edit generated task stubs; edit the underlying task instead","Regenerate stubs after changing layout (flat -> nested) before committing","Treat stub files as generated artifacts in code review","If a stub was customized, move the customization out before migrating"],"tags":["cli","task-stubs","file-overwrite-protection"],"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"}