lima-vm/lima · error
failed to resolve vm for %#q: %w
Error message
failed to resolve vm for %#q: %w
What it means
When restarting, restart.go re-reads the instance's lima.yaml; if the file content changed it reloads it with limayaml.LoadWithWarnings and then calls driverutil.ResolveVMType to determine the VM driver. If the (modified) config cannot be resolved to a VM type, the command aborts with "failed to resolve vm for <file>" wrapping the resolver error.
Source
Thrown at cmd/limactl/restart.go:95
yqExprs, err := editflags.YQExpressions(flags, false, params)
if err != nil {
return err
}
if len(yqExprs) > 0 {
yq := yqutil.Join(yqExprs)
yBytes, err := yqutil.EvaluateExpression(ctx, yq, yContent)
if err != nil {
return err
}
if !bytes.Equal(yBytes, yContent) {
y, err := limayaml.LoadWithWarnings(ctx, yBytes, filePath)
if err != nil {
return err
}
if err := driverutil.ResolveVMType(y); err != nil {
return fmt.Errorf("failed to resolve vm for %#q: %w", filePath, err)
}
inst.Config = y
limaDriver, err := driverutil.CreateConfiguredDriver(ctx, inst, 0)
if err != nil {
return err
}
if err := limaDriver.Validate(ctx); err != nil {
return saveRejectedYAML(yBytes, err)
}
if err := limayaml.Validate(inst.Config, true); err != nil {
return saveRejectedYAML(yBytes, err)
}
if err := limayaml.ValidateAgainstLatestConfig(ctx, yBytes, yContent); err != nil {
return saveRejectedYAML(yBytes, err)
}
if err := os.WriteFile(filePath, yBytes, 0o644); err != nil {
return err
}View on GitHub (pinned to dd909d0973)
Solutions
- Restore a valid vmType in the instance's lima.yaml (e.g. `vmType: qemu` or the native driver for your OS)
- Revert recent manual edits to ~/.lima/<instance>/lima.yaml or re-apply them with a supported vmType
- Validate the edited file by loading it via a fresh `limactl start`/edit flow, then restart
Example fix
// before # ~/.lima/myvm/lima.yaml (vmType removed by hand-edit) // after vmType: qemu arch: x86_64
Defensive patterns
Strategy: validation
Validate before calling
vmType=$(yq '.vmType' ~/.lima/myvm/lima.yaml) case "$vmType" in qemu|vz|wsl2|qemu-system-*) : ;; *) echo "unsupported vmType: $vmType" >&2; exit 1;; esac
Try / catch
if err := restartCmd.Run(); err != nil {
if strings.Contains(err.Error(), "failed to resolve vm for") {
// restore a valid vmType in the instance lima.yaml, then retry
}
} Prevention
- Edit instance configs via `limactl edit` rather than raw file edits
- Preserve the vmType/arch fields when hand-editing lima.yaml
- Validate copied configs against the target host's supported drivers
When it happens
Trigger: Hand-editing an instance's lima.yaml (or applying a yq/template change) so that the vm-type/arch fields are missing, ambiguous, or unsupported, then running `limactl restart <instance>`.
Common situations: Manual edits removing the `vmType` setting; copying a config from a different host/architecture; template upgrades changing schema; typos in driver names.
Related errors
- the YAML is invalid, saved the buffer as %#q: %w
- network %#q already exists
- failed to build network arguments: %w
- unexpected architecture: %#q
- field `vmOpts.qemu.minimumVersion` must be a semvar value, g
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/80de3a98d6092e1e.
Report an issue: GitHub.