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

  1. Restore a valid vmType in the instance's lima.yaml (e.g. `vmType: qemu` or the native driver for your OS)
  2. Revert recent manual edits to ~/.lima/<instance>/lima.yaml or re-apply them with a supported vmType
  3. 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

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


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/80de3a98d6092e1e. Report an issue: GitHub.