{"record":{"id":"2adb5bfb48aca2f7","repo":"go-task/task","slug":"task-taskfiles-versions-should-match-first-is","errorCode":null,"errorMessage":"task: Taskfiles versions should match. First is \"%s\" but second is \"%s\"","messagePattern":"task: Taskfiles versions should match\\. First is \"(.+?)\" but second is \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"taskfile/ast/taskfile.go","lineNumber":43,"sourceCode":"\tOutput       Output\n\tMethod       string\n\tIncludes     *Includes\n\tSet          []string\n\tShopt        []string\n\tVars         *Vars\n\tEnv          *Vars\n\tTasks        *Tasks\n\tSilent       bool\n\tDotenv       []string\n\tRun          string\n\tInterval     time.Duration\n\tUseGitignore *bool\n}\n\n// Merge merges the second Taskfile into the first\nfunc (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error {\n\tif !t1.Version.Equal(t2.Version) {\n\t\treturn fmt.Errorf(`task: Taskfiles versions should match. First is \"%s\" but second is \"%s\"`, t1.Version, t2.Version)\n\t}\n\tif len(t2.Dotenv) > 0 {\n\t\treturn ErrIncludedTaskfilesCantHaveDotenvs\n\t}\n\tif t2.Output.IsSet() {\n\t\tt1.Output = t2.Output\n\t}\n\tif t1.Includes == nil {\n\t\tt1.Includes = NewIncludes()\n\t}\n\tif t1.Vars == nil {\n\t\tt1.Vars = NewVars()\n\t}\n\tif t1.Env == nil {\n\t\tt1.Env = NewVars()\n\t}\n\tif t1.Tasks == nil {\n\t\tt1.Tasks = NewTasks()","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/taskfile/ast/taskfile.go#L25-L61","documentation":"Taskfile.Merge merges an included Taskfile into the parent and requires both to declare the same schema version. If t1.Version and t2.Version differ, merging could mix incompatible semantics, so the merge is rejected with both versions in the message.","triggerScenarios":"An `includes:` referenced Taskfile declares a different `version:` than the including Taskfile (e.g. main file uses `version: '3'`, included file uses `version: '2'`).","commonSituations":"Upgrading a project's main Taskfile to version 3 while included Taskfiles still say 2; vendoring Taskfiles from other repos pinned to older versions; forgetting to bump version in shared includes.","solutions":["Set the same `version:` in the included Taskfile as in the including one","Update the included Taskfile's syntax to match the main file's version","Inline or copy the tasks locally if you cannot modify the included file","Consolidate version numbers across all Taskfiles in the repo"],"exampleFix":"# included Taskfile before\nversion: '2'\n\n# after\nversion: '3'","handlingStrategy":"validation","validationCode":"main, err := os.ReadFile(\"Taskfile.yml\")\ninc, err2 := os.ReadFile(\"included.yml\")\n// compare the version: fields (e.g. with gopkg.in/yaml.v3) before running task\nvar mv, iv struct{ Version string `yaml:\"version\"` }\n_ = yaml.Unmarshal(main, &mv)\n_ = yaml.Unmarshal(inc, &iv)\nif mv.Version != iv.Version { /* fix versions first */ }","typeGuard":"func versionsMatch(a, b Taskfile) bool {\n    return a.Version.Equal(b.Version)\n}","tryCatchPattern":"if err := t1.Merge(t2, include); err != nil {\n    var mismatch bool = strings.Contains(err.Error(), \"versions should match\")\n    if mismatch {\n        // prompt user to align versions, or load included file standalone\n    }\n    return err\n}","preventionTips":["Keep `version:` identical across all Taskfiles and includes in a repo","When upgrading Task versions, update every included Taskfile in the same commit","Pin external includes to a ref whose version you know matches","Grep the repo for `version:` in CI to catch drift"],"tags":["taskfile","versioning","includes","config"],"backgroundTag":"taskfile-version-mismatch","analyzedSha":"385e5ad92af02877b6d7cf9dcc963b5ed916e70a","analyzedAt":"2026-09-05T09:01:05.226Z","contentChangedAt":"2026-09-05T09:01:05.226Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}