abiosoft/colima · error

cannot restart, VM not previously started

Error message

cannot restart, VM not previously started

What it means

limaVM.Restart refuses to run when the in-memory config for the profile is empty, because restart replays the previous start configuration (Stop then Start with l.conf). An empty config means Colima has no record of how the VM was started in this invocation, so it cannot safely restart. The config is normally loaded from the persisted Lima/Colima profile state before Restart is called.

Source

Thrown at environment/vm/lima/lima.go:255

	a := l.Init(ctx)

	if util.MacOS() {
		conf, _ := configmanager.LoadInstance()
		a.Retry("", time.Second*1, 10, func(retryCount int) error {
			return l.daemon.Stop(ctx, conf)
		})
	}

	a.Add(func() error {
		return l.host.Run(limactl, "delete", "--force", config.CurrentProfile().ID)
	})

	return a.Exec()
}

func (l limaVM) Restart(ctx context.Context) error {
	if l.conf.Empty() {
		return fmt.Errorf("cannot restart, VM not previously started")
	}

	if err := l.Stop(ctx, false); err != nil {
		return err
	}

	// minor delay to prevent possible race condition.
	time.Sleep(time.Second * 2)

	if err := l.Start(ctx, l.conf); err != nil {
		return err
	}

	return nil
}

func (l limaVM) Host() environment.HostActions {
	return l.host

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. For CLI users: run `colima stop && colima start` instead, or simply retry `colima restart` which loads state through the normal command path.
  2. Ensure the profile's state/Lima config file exists (not manually deleted); if gone, recreate with `colima start`.
  3. For API users: call the profile/config load step (the same one the restart command uses) before Restart, or Start the VM first.
  4. Verify you are targeting an existing profile name; a typo'd profile has no state and hits this path.
Defensive patterns

Strategy: validation

Validate before calling

// CLI users: ensure profile has state before restart
// `colima status -p <profile>` should report created/running
// API users: load persisted config before Restart (the restart command path does this)

Prevention

When it happens

Trigger: Invoking restart through an API path that never loaded the profile config (fresh limaVM instance without prior Start/Load); profile state file missing/corrupt so config parses as empty; calling Restart on a profile that was deleted.

Common situations: Programmatic use of the environment package constructing a new limaVM without loading state; users running `colima restart` after manually deleting state under ~/.colima; bugs in wrappers that skip initialization.

Related errors


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