lima-vm/lima · error
the YAML is invalid, saved the buffer as %#q: %w
Error message
the YAML is invalid, saved the buffer as %#q: %w
What it means
The normal "rejected YAML" error from `saveRejectedYAML`: the edited instance YAML failed lima's validation, but lima successfully saved the invalid buffer to `lima.REJECTED.yaml` in the current working directory so nothing is lost. The wrapped `%w` cause is the actual `limayaml.Validate` error describing which field is wrong.
Source
Thrown at cmd/limactl/edit.go:232
if isTTY {
message := "Do you want to start the instance now? "
return uiutil.Confirm(message, true)
}
return false, nil
}
func editBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return bashCompleteInstanceNames(cmd)
}
// saveRejectedYAML writes the rejected config and returns an error.
func saveRejectedYAML(y []byte, origErr error) error {
rejectedYAML := "lima.REJECTED.yaml"
if writeErr := os.WriteFile(rejectedYAML, y, 0o644); writeErr != nil {
return fmt.Errorf("the YAML is invalid, attempted to save the buffer as %#q but failed: %w", rejectedYAML, errors.Join(writeErr, origErr))
}
// TODO: may need to support editing the rejected YAML
return fmt.Errorf("the YAML is invalid, saved the buffer as %#q: %w", rejectedYAML, origErr)
}
View on GitHub (pinned to dd909d0973)
Solutions
- Read the wrapped cause at the end of the message; fix that specific field in the editor and retry `limactl edit`.
- Inspect the saved `lima.REJECTED.yaml` in the current directory to see exactly what was rejected, then correct it.
- Validate offline before applying: pipe the YAML through a minimal check or compare against `templates/` examples in the lima repo.
- If a lima upgrade removed fields, migrate per release notes (e.g. move deprecated keys to their replacements).
Example fix
// before yaml: cpus: "4" # ok arh: x86_64 # typo field -> validation fails // after yaml: cpus: 4 arch: x86_64
Defensive patterns
Strategy: validation
Validate before calling
// Validate the YAML shape yourself before submitting (Go, using lima's loader):
_, err := limayaml.Load([]byte(newYAML), "edited.yaml")
if err != nil {
return fmt.Errorf("edited YAML will be rejected: %w", err)
} Try / catch
if err := runEdit(inst); err != nil {
var verr *ValidationError // or match on the wrapped cause
if strings.Contains(err.Error(), "saved the buffer as") {
rejected, _ := os.ReadFile("lima.REJECTED.yaml")
log.Printf("rejected YAML kept at lima.REJECTED.yaml (%d bytes); fix reported field and retry", len(rejected))
}
return err
} Prevention
- After a lima upgrade, check release notes for removed/renamed lima.yaml fields before editing existing instances.
- Keep a backup: `cp ~/.lima/<inst>/lima.yaml ~/.lima/<inst>/lima.yaml.bak` before edits.
- Test `--set` yq expressions against a copy of the YAML first; inspect the saved lima.REJECTED.yaml when a change is rejected.
When it happens
Trigger: Any of `limactl edit`, `limactl clone`/`rename`, `limactl restart` (with re-edit), or `limactl edit --set <yq-expr>` producing a YAML that fails validation: unknown/removed fields, invalid values (bad arch, empty required field, conflicting mounts, invalid port forwards in the config).
Common situations: Hand-editing lima.yaml and introducing a typo or unsupported field; upgrading lima so a previously valid field was removed/renamed; a `--set` yq expression producing an invalid structure; copy-pasting a template with fields unsupported on the host.
Related errors
- the YAML is invalid, attempted to save the buffer as %#q but
- failed to validate YAML file %#q: %w
- failed to validate the instance YAML after filling defaults:
- failed to validate the instance YAML after filling defaults:
- disk format %#q not supported, use `qcow2` or `raw` instead
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/11ddabfb77b75767.
Report an issue: GitHub.