lima-vm/lima · error

failed to stop VM after installation: %w

Error message

failed to stop VM after installation: %w

What it means

After the macOS installer VM finishes (vm.RequestStop path), installMacOS stops the VM. If vm.RequestStop() returns an error, this wrapped error is thrown, meaning the Virtualization framework refused or failed the graceful stop request.

Source

Thrown at pkg/driver/vz/vm_darwin_arm64.go:168

				logrus.WithError(ctx.Err()).Info("macOS installer exited")
				bar.SetCurrent(barResolution)
				return
			case <-ticker.C:
				progress := installer.FractionCompleted() * barResolution
				bar.SetCurrent(int64(progress))
			}
		}
	}()

	err = installer.Install(ctx)
	bar.Finish()
	if err != nil {
		return err
	}

	stopped, err := vm.RequestStop()
	if err != nil {
		return fmt.Errorf("failed to stop VM after installation: %w", err)
	}
	if !stopped {
		logrus.WithError(err).Warn("VM did not stop after installation")
		if err = vm.Stop(); err != nil {
			return fmt.Errorf("failed to force stop VM after installation: %w", err)
		}
	}
	return nil
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Retry `limactl start <instance>` — the install step is usually skippable/resumable
  2. If the VM is actually gone, delete and recreate the instance: `limactl delete <name> --force`
  3. Update macOS to get Virtualization.framework fixes
  4. Inspect the wrapped error for the underlying framework cause

Example fix

// before
$ limactl start macos-test  # fails stopping installer VM
// after
$ limactl delete macos-test --force
$ limactl start macos-test
Defensive patterns

Strategy: retry

Try / catch

if err := start(); err != nil && strings.Contains(err.Error(), "failed to stop VM after installation") {
    // VM state may be inconsistent: force delete and retry
    exec.Command("limactl", "delete", instName, "--force").Run()
    err = start()
}

Prevention

When it happens

Trigger: vm.RequestStop() on the freshly installed macOS VM returns a non-nil error during `limactl start` of a VZ macOS guest (install phase).

Common situations: Virtualization.framework state inconsistency after installation; VM already halted or crashed so the stop request fails; macOS version-specific framework bugs.

Related errors


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