abiosoft/colima · error

error during teardown of vm: %w

Error message

error during teardown of vm: %w

What it means

The Lima instance teardown (limactl delete) failed and the error is returned: this is the fatal step of `colima delete`. The VM image and instance directory under ~/.lima/<profile> were not removed.

Source

Thrown at app/app.go:277

	if c.guest.Running(ctx) {
		containers, err := c.currentContainerEnvironments(ctx)
		if err != nil {
			log.Warnln(fmt.Errorf("error retrieving runtimes: %w", err))
		}
		for _, cont := range containers {
			log := log.WithField("context", cont.Name())
			log.Println("deleting ...")

			if err := cont.Teardown(ctx); err != nil {
				// failure here is not fatal
				log.Warnln(fmt.Errorf("error during teardown of %s: %w", cont.Name(), err))
			}
		}
	}

	// teardown vm
	if err := c.guest.Teardown(ctx); err != nil {
		return fmt.Errorf("error during teardown of vm: %w", err)
	}

	// delete configs
	if err := configmanager.Teardown(); err != nil {
		return fmt.Errorf("error deleting configs: %w", err)
	}

	// delete runtime disk if disk in use and data deletion is requested
	if diskInUse && data {
		log.Println("deleting container data")
		if err := limautil.DeleteDisk(); err != nil {
			return fmt.Errorf("error deleting container data: %w", err)
		}

		if err := store.Reset(); err != nil {
			log.Trace("error resetting store: %w", err)
		}
	}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Retry with force: `colima delete --force`
  2. Drive lima directly: `limactl delete -f colima` for the default profile
  3. Ensure no qemu/vz process for the profile survives (`pgrep -af qemu`), kill it, then delete again
  4. Last resort: `rm -rf ~/.lima/colima` (and the profile's colima config dir) once no process uses it

Example fix

# before
colima delete
# error: error during teardown of vm: ...

# after
colima delete --force || limactl delete -f colima
Defensive patterns

Strategy: retry

Validate before calling

// ensure the VM is stopped cleanly before delete
if err := a.Stop(true); err != nil {
    // proceed, but plan for force teardown: a.Delete(false, true)
}

Try / catch

if err := a.Delete(false, false); err != nil {
    if strings.Contains(err.Error(), "error during teardown of vm") {
        return a.Delete(false, true) // force teardown
    }
}

Prevention

When it happens

Trigger: `colima delete` when limactl cannot remove the instance: VM still marked running, lima state files inconsistent after a crash, or files under ~/.lima held open by another process.

Common situations: Deleting right after a failed stop; a wedged qemu process keeping the instance directory busy; permissions changed under ~/.lima after running colima with sudo.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/31a440ce2a5ad0b1. Report an issue: GitHub.