lima-vm/lima · error

failed to create driver instance: %w

Error message

failed to create driver instance: %w

What it means

The unregister helper in pkg/instance/delete.go could not construct the VM driver via driverutil.CreateConfiguredDriver. Without a driver instance, Lima cannot tell the driver to delete its resources, so instance teardown aborts. This mirrors error 641 but on the delete path.

Source

Thrown at pkg/instance/delete.go:42

	StopForcibly(inst)

	if len(inst.Errors) == 0 {
		if err := unregister(ctx, inst); err != nil {
			return fmt.Errorf("failed to unregister %#q: %w", inst.Dir, err)
		}
	}
	if err := os.RemoveAll(inst.Dir); err != nil {
		return fmt.Errorf("failed to remove %#q: %w", inst.Dir, err)
	}

	return nil
}

func unregister(ctx context.Context, inst *limatype.Instance) error {
	limaDriver, err := driverutil.CreateConfiguredDriver(ctx, inst, 0)
	if err != nil {
		return fmt.Errorf("failed to create driver instance: %w", err)
	}

	if err := limaDriver.Delete(ctx); err != nil {
		return fmt.Errorf("failed to delete driver instance: %w", err)
	}
	server.Stop(inst.Dir, true)

	return nil
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Check the wrapped driver error for the missing/unsupported driver name.
  2. Ensure lima.yaml in the instance dir is intact and its vmType is supported on this host.
  3. Install/rebuild limactl with the needed driver (`make native`).
  4. If the driver can never work again, force-remove the directory manually after `limactl stop -f`.

Example fix

// before: instance made on macOS with vmType: vz, deleting on Linux
vmType: "vz"
// after: edit instance dir lima.yaml or delete on the original host
vmType: "qemu"
Defensive patterns

Strategy: fallback

Validate before calling

// verify the driver for the instance's vmType is registered on this host
if !driverutil.IsDriverRegistered(inst.Config.VMType) {
    return fmt.Errorf("driver %s unavailable; delete on original host or clean manually", inst.Config.VMType)
}

Try / catch

if err := instance.Delete(ctx, inst, false); err != nil {
    if strings.Contains(err.Error(), "failed to create driver instance") {
        // driver can never load here: fall back to manual dir removal
        return os.RemoveAll(inst.Dir)
    }
    return err
}

Prevention

When it happens

Trigger: unregister(ctx, inst) (called from Delete when inst.Errors is empty) hits CreateConfiguredDriver(ctx, inst, 0) returning an error — missing/unsupported driver for inst.Config's vmType, or driver configure failure reading the instance dir.

Common situations: Deleting an instance created with a vmType unavailable on the current machine (moved between macOS/Linux), a limactl build lacking the driver, or corrupted lima.yaml in the instance directory.

Related errors


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