abiosoft/colima · error

error retrieving instances: %w

Error message

error retrieving instances: %w

What it means

Error returned by Instances when the multi-instance 'limactl list --json [ids...]' command exits non-zero. stderr is nil'd out, so the wrapped error carries only the exit status, not limactl's message.

Source

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

	}
	return i, nil
}

// Instances returns Lima instances created by colima.
func Instances(ids ...string) ([]InstanceInfo, error) {
	limaIDs := make([]string, len(ids))
	for i := range ids {
		limaIDs[i] = config.ProfileFromName(ids[i]).ID
	}
	args := append([]string{"list", "--json"}, limaIDs...)

	var buf bytes.Buffer
	cmd := Limactl(args...)
	cmd.Stderr = nil
	cmd.Stdout = &buf

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

	var instances []InstanceInfo
	scanner := bufio.NewScanner(&buf)
	for scanner.Scan() {
		var i InstanceInfo
		line := scanner.Bytes()
		if err := json.Unmarshal(line, &i); err != nil {
			return nil, fmt.Errorf("error retrieving instances: %w", err)
		}

		// limit to colima instances
		if !strings.HasPrefix(i.Name, "colima") {
			continue
		}

		conf, _ := i.Config()
		if i.Running() {

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Reproduce directly: 'limactl list --json' to surface the hidden stderr
  2. Fix permissions on ~/.lima and ~/.colima
  3. Reinstall/upgrade colima to repair the embedded limactl
  4. Remove stale Lima locks or the offending instance directory
Defensive patterns

Strategy: try-catch

Try / catch

If Instances() fails, fall back to a direct 'limactl list --json' subprocess with stderr captured, so the real limactl message replaces the swallowed one; branch on that message (permissions vs corruption vs binary).

Prevention

When it happens

Trigger: Enumerating instances (e.g. 'colima list') when limactl fails outright: broken binary, unreadable/corrupted Lima config directory, or invalid instance state on disk.

Common situations: First 'colima list' after a partial upgrade; ~/.lima owned by another user; leftover lock files from a crashed limactl.

Related errors


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