go-task/task · error
task: Taskfiles versions should match. First is "%s" but sec
Error message
task: Taskfiles versions should match. First is "%s" but second is "%s"
What it means
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.
Source
Thrown at taskfile/ast/taskfile.go:43
Output Output
Method string
Includes *Includes
Set []string
Shopt []string
Vars *Vars
Env *Vars
Tasks *Tasks
Silent bool
Dotenv []string
Run string
Interval time.Duration
UseGitignore *bool
}
// Merge merges the second Taskfile into the first
func (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error {
if !t1.Version.Equal(t2.Version) {
return fmt.Errorf(`task: Taskfiles versions should match. First is "%s" but second is "%s"`, t1.Version, t2.Version)
}
if len(t2.Dotenv) > 0 {
return ErrIncludedTaskfilesCantHaveDotenvs
}
if t2.Output.IsSet() {
t1.Output = t2.Output
}
if t1.Includes == nil {
t1.Includes = NewIncludes()
}
if t1.Vars == nil {
t1.Vars = NewVars()
}
if t1.Env == nil {
t1.Env = NewVars()
}
if t1.Tasks == nil {
t1.Tasks = NewTasks()View on GitHub (pinned to 385e5ad92a)
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
Example fix
# included Taskfile before version: '2' # after version: '3'
Defensive patterns
Strategy: validation
Validate before calling
main, err := os.ReadFile("Taskfile.yml")
inc, err2 := os.ReadFile("included.yml")
// compare the version: fields (e.g. with gopkg.in/yaml.v3) before running task
var mv, iv struct{ Version string `yaml:"version"` }
_ = yaml.Unmarshal(main, &mv)
_ = yaml.Unmarshal(inc, &iv)
if mv.Version != iv.Version { /* fix versions first */ } Type guard
func versionsMatch(a, b Taskfile) bool {
return a.Version.Equal(b.Version)
} Try / catch
if err := t1.Merge(t2, include); err != nil {
var mismatch bool = strings.Contains(err.Error(), "versions should match")
if mismatch {
// prompt user to align versions, or load included file standalone
}
return err
} Prevention
- 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
When it happens
Trigger: An `includes:` referenced Taskfile declares a different `version:` than the including Taskfile (e.g. main file uses `version: '3'`, included file uses `version: '2'`).
Common situations: 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.
Related errors
- task: Included Taskfiles can't have dotenv declarations. Ple
- task: Blank Arch value provided
- task: Multiple Arch values provided
- task: precondition not met
- loop var must be a delimiter-separated string, list or a map
AI-assisted analysis of go-task/task@385e5ad92a (2026-09-05).
Data as JSON: /api/errors/2adb5bfb48aca2f7.
Report an issue: GitHub.