abiosoft/colima · error

error retrieving instance: %w

Error message

error retrieving instance: %w

What it means

Error returned by getInstance when 'limactl list <profileID> --json' itself exits non-zero while fetching a single instance's info. Note cmd.Stderr is set to nil, so limactl's explanation is discarded and only the exit error is wrapped.

Source

Thrown at environment/vm/lima/limautil/instance.go:57

// Config returns the current Colima config
func (i InstanceInfo) Config() (config.Config, error) {
	return configmanager.LoadFrom(config.ProfileFromName(i.Name).StateFile())
}

// Lima statuses
const (
	limaStatusRunning = "Running"
)

func getInstance(profileID string) (InstanceInfo, error) {
	var i InstanceInfo
	var buf bytes.Buffer
	cmd := Limactl("list", profileID, "--json")
	cmd.Stderr = nil
	cmd.Stdout = &buf

	if err := cmd.Run(); err != nil {
		return i, fmt.Errorf("error retrieving instance: %w", err)
	}

	if buf.Len() == 0 {
		return i, fmt.Errorf("instance '%s' does not exist", config.ProfileFromName(profileID).DisplayName)
	}

	if err := json.Unmarshal(buf.Bytes(), &i); err != nil {
		return i, fmt.Errorf("error retrieving instance: %w", err)
	}

	if conf, err := i.Config(); err == nil {
		if conf.Disk > 0 {
			i.Disk = config.Disk(conf.Disk).Int()
		}
	}
	return i, nil
}

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Run 'limactl list' directly to see the real failure message that this error hides
  2. Reinstall/upgrade colima so limactl and the Lima state layout match
  3. Fix ownership: sudo chown -R $(whoami) ~/.lima ~/.colima
  4. If one instance's files are corrupted, 'colima delete <profile>' removes just that instance

Example fix

# before: only 'error retrieving instance' is shown
# after: reproduce with stderr visible to get the cause
limactl list colima --json; echo "exit=$?"
Defensive patterns

Strategy: try-catch

Try / catch

On error from Instance(), shell out once to 'limactl list <id> --json' with stderr inherited to recover the hidden failure text, then decide: broken limactl -> reinstall; corrupt instance -> colima delete.

Prevention

When it happens

Trigger: Running limactl list for a profile when the limactl binary is broken/missing, the Lima configuration directory is corrupted, or limactl encounters an internal error (all produce non-zero exit before any JSON output).

Common situations: Half-updated colima whose embedded limactl mismatches the on-disk ~/.lima state; ~/.colima or ~/.lima files made root-owned; limactl crashing on a malformed instance database.

Related errors


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