lima-vm/lima · error
cannot execute template %#q: %w
Error message
cannot execute template %#q: %w
What it means
The message template parsed and data was built, but tmpl.Execute failed while rendering into the message builder. This typically means the template references a field or method that does not exist on the data at execution time; the instance is marked StatusBroken.
Source
Thrown at pkg/store/instance.go:139
}
inspectStatus(ctx, instDir, inst, y)
tmpl, err := template.New("format").Parse(y.Message)
if err != nil {
inst.Errors = append(inst.Errors, fmt.Errorf("message %#q is not a valid template: %w", y.Message, err))
inst.Status = limatype.StatusBroken
} else {
data, err := AddGlobalFields(inst)
if err != nil {
inst.Errors = append(inst.Errors, fmt.Errorf("cannot add global fields to instance data: %w", err))
inst.Status = limatype.StatusBroken
} else {
data.Param = y.Param
var message strings.Builder
err = tmpl.Execute(&message, data)
if err != nil {
inst.Errors = append(inst.Errors, fmt.Errorf("cannot execute template %#q: %w", y.Message, err))
inst.Status = limatype.StatusBroken
} else {
inst.Message = message.String()
}
}
}
limaVersionFile := filepath.Join(instDir, filenames.LimaVersion)
if version, err := os.ReadFile(limaVersionFile); err == nil {
inst.LimaVersion = strings.TrimSpace(string(version))
if _, err = versionutil.Parse(inst.LimaVersion); err != nil {
logrus.Warnf("treating lima version %#q from %#q as very latest release", inst.LimaVersion, limaVersionFile)
}
} else if !errors.Is(err, os.ErrNotExist) {
inst.Errors = append(inst.Errors, err)
}
inst.Param = y.Param
return inst, nilView on GitHub (pinned to dd909d0973)
Solutions
- Remove or correct the unknown field reference in the message template in ~/.lima/<inst>/lima.yaml
- Check `limactl list --list-flags` / docs for valid format fields
- Update deprecated host attributes to the new top-level fields (removed in Lima 3.0)
- Recreate the instance with a known-good template
Example fix
// before
message: "{{ .SSHConfigFile }} on {{ .BogusField }}"
// after
message: "{{ .SSHConfigFile }}" Defensive patterns
Strategy: validation
Validate before calling
// Only reference known FormatData fields
tmpl, err := template.New("f").Parse(y.Message)
if err == nil {
data, _ := store.AddGlobalFields(&limatype.Instance{})
if err := tmpl.Execute(io.Discard, data); err != nil {
// unknown field referenced; fix before Inspect
}
} Try / catch
inst, err := store.Inspect(ctx, instDir)
if inst.Status == limatype.StatusBroken {
for _, e := range inst.Errors {
if strings.Contains(e.Error(), "cannot execute template") {
// fix the field names in the message template
}
}
} Prevention
- Stick to documented format fields (`limactl list --help` lists them)
- Avoid deprecated host attributes slated for removal in Lima 3.0
- Dry-run templates with tmpl.Execute against AddGlobalFields output before persisting
When it happens
Trigger: y.Message template references a missing/nonexistent field or calls a method that returns an error during Execute, e.g. {{ .NoSuchField }} or a nil-pointer method call in FormatData.
Common situations: Template written for a newer/older Lima FormatData schema (field removed in Lima 3.0 deprecations); typo in field name; using a deprecated host attribute removed from the data model.
Related errors
- message %#q is not a valid template: %w
- cannot add global fields to instance data: %w
- invalid value for static parameter: %#q
- invalid parameter %#q, expected `static=` followed by a bool
- invalid parameter %#q, expected NAME=VALUE
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/176eb296e3b52563.
Report an issue: GitHub.