{"record":{"id":"e6086c7609ae02e1","repo":"jdx/mise","slug":"cannot-write-task-stub-because-is-not-a-generat","errorCode":null,"errorMessage":"cannot write task stub because {} is not a generated task stub","messagePattern":"cannot write task stub because (.+?) is not a generated task stub","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/task_stubs.rs","lineNumber":230,"sourceCode":"            Err(err) => return Err(err.into()),\n        }\n    }\n\n    for stub in stubs {\n        match fs::symlink_metadata(&stub.path) {\n            Ok(metadata) if metadata.file_type().is_dir() => {\n                validate_generated_stub_directory(&stub.path, &stub.output, stub.task)?;\n                migrations.insert(StubMigration::Directory(stub.path.clone()));\n            }\n            Ok(metadata) if metadata.file_type().is_symlink() => bail!(\n                \"cannot write task stub because {} is a symbolic link\",\n                display_path(&stub.path)\n            ),\n            Ok(metadata) if metadata.file_type().is_file() => {\n                let existing = file::read_to_string(&stub.path)?;\n                let legacy_leaf = stub.legacy_path == stub.path && existing == stub.legacy_output;\n                if existing != stub.output && !legacy_leaf {\n                    bail!(\n                        \"cannot write task stub because {} is not a generated task stub\",\n                        display_path(&stub.path)\n                    );\n                }\n            }\n            Ok(_) => bail!(\n                \"cannot write task stub because {} is not a regular file\",\n                display_path(&stub.path)\n            ),\n            Err(err) if matches!(err.kind(), ErrorKind::NotFound | ErrorKind::NotADirectory) => {}\n            Err(err) => return Err(err.into()),\n        }\n        validate_launcher_path(stub)?;\n        for parent in stub.path.ancestors().skip(1) {\n            match fs::symlink_metadata(parent) {\n                Ok(metadata)\n                    if metadata.file_type().is_dir()\n                        || migrations.contains(&StubMigration::File(parent.to_path_buf())) => {}","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/cli/generate/task_stubs.rs#L212-L248","documentation":"A regular file already exists at the stub path but its content is neither the stub this run would generate nor the legacy stub form (the legacy exception covers only a legacy-path leaf with the old marker-less body). mise only overwrites stubs it can recognize as its own, so a foreign or hand-modified file stops the run before anything is written.","triggerScenarios":"bin/<task> is a project script predating a task of the same name; a previously generated stub was edited by hand; a stub from a run with a different --mise-bin was modified afterwards.","commonSituations":"Adopting task-stubs in a repo whose bin/ already has scripts; a contributor tweaked a generated stub locally and committed it.","solutions":["If the file is the project's own, move it out of the way: `git mv bin/<task> bin/<task>.sh`","If it is a mise stub you edited, revert the edits (`git checkout -- bin/<task>`) or delete it so mise regenerates","Fold the needed behavior into the task definition rather than the generated stub, then rerun `mise generate task-stubs`"],"exampleFix":"# before\n$ mise generate task-stubs\n# error: cannot write task stub because bin/test is not a generated task stub\n\n# after (bin/test was our own script)\n$ git mv bin/test scripts/run-tests.sh\n$ mise generate task-stubs","handlingStrategy":"type-guard","validationCode":"#!/bin/bash\n# any existing stub-shaped path must carry the mise marker\nfor f in $(mise tasks ls --json 2>/dev/null | jq -r '.[]!.name' | tr ':' '/'); do\n  [ -f \"bin/$f\" ] && ! grep -q 'generated by mise task-stubs' \"bin/$f\" \\\n    && { echo \"bin/$f is not a generated stub\" >&2; exit 1; }\ndone\nmise generate task-stubs","typeGuard":"is_mise_stub() {\n  [ \"$(head -1 \"$1\")\" = '#!/bin/sh' ] && [ \"$(sed -n 2p \"$1\")\" = '# generated by mise task-stubs' ]\n}","tryCatchPattern":"if ! mise generate task-stubs; then\n  grep -q 'is not a generated task stub' /dev/stdin <<<\"$err\" 2>/dev/null\n  echo 'rename or remove the foreign file under bin/, then rerun' >&2\n  exit 1\nfi","preventionTips":["Reserve the stub directory for mise output; keep hand-written scripts elsewhere (scripts/)","Never edit generated stubs — customize the task instead so regeneration stays idempotent","Regenerate stubs whenever --mise-bin or task definitions change, from the same canonical setup"],"tags":["mise","task-stubs","ownership","generate"],"backgroundTag":"generated-file-ownership-conflict","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}