lima-vm/lima · error

failed to check if the autostart entry for instance %#q is r

Error message

failed to check if the autostart entry for instance %#q is registered: %w

What it means

This error wraps a failure that occurred while checking whether the instance has an autostart entry registered with the OS autostart manager (systemd user units on Linux, launchd on macOS). `limactl edit` calls `autostart.IsRegistered` after editing a running instance so it can reconcile state, but only tolerates `autostart.ErrNotSupported` (e.g. WSL2 or an OS without a supported manager). Any other lookup failure (dbus/systemctl/launchctl failure, unexpected exit status) is surfaced through this wrapper with `%#q` quoting of the instance name.

Source

Thrown at cmd/limactl/edit.go:195

	}

	start, err = flags.GetBool("start")
	if err != nil {
		return err
	}

	if tty && !flags.Changed("start") {
		start, err = askWhetherToStart(cmd)
		if err != nil {
			return err
		}
	}
	if !start {
		return nil
	}
	// Network reconciliation will be performed by the process launched by the autostart manager
	if registered, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {
		return fmt.Errorf("failed to check if the autostart entry for instance %#q is registered: %w", inst.Name, err)
	} else if !registered {
		err = reconcile.Reconcile(ctx, inst.Name)
		if err != nil {
			return err
		}
	}

	// store.Inspect() syncs values between inst.YAML and the store.
	// This call applies the validated template to the store.
	inst, err = store.Inspect(ctx, inst.Name)
	if err != nil {
		return err
	}
	return instance.Start(ctx, inst, false, false)
}

func askWhetherToStart(cmd *cobra.Command) (bool, error) {
	isTTY := uiutil.InputIsTTY(cmd.InOrStdin())

View on GitHub (pinned to dd909d0973)

Solutions

  1. Verify the host's autostart manager works manually: `systemctl --user status` (Linux) or `launchctl managername` (macOS); fix the session/dbus issue first.
  2. Ensure XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS are set when running limactl over SSH; enable `loginctl enable-linger <user>`.
  3. Re-run `limactl start <inst>` (or edit with autostart disabled) so the autostart entry is recreated cleanly.
  4. If the platform genuinely has no autostart manager, confirm lima's driver/platform detection marks it ErrNotSupported (e.g. upgrade lima) instead of failing.

Example fix

// before
$ limactl edit myvm
FATA ... failed to check if the autostart entry for instance "myvm" is registered: exit status 1

// after
$ loginctl enable-linger $USER   # make systemd --user session available
$ limactl edit myvm              # succeeds
Defensive patterns

Strategy: try-catch

Validate before calling

// Before editing, check the autostart manager is reachable:
if err := exec.Command("systemctl", "--user", "is-system-running").Run(); err != nil {
    log.Println("systemd user session unavailable; edit may fail on autostart check")
}

Try / catch

if err := limactlEdit(inst); err != nil {
    if strings.Contains(err.Error(), "failed to check if the autostart entry") {
        // fall back: disable autostart or fix systemd user session
        fixSystemdUserSession() // e.g. loginctl enable-linger $USER
    }
    return err
}

Prevention

When it happens

Trigger: Running `limactl edit <inst>` on an instance that was started with autostart enabled, where the autostart manager query fails: systemd user session unavailable over SSH (no lingering/dbus), `systemctl --user` exits non-zero, or the launchd plist query fails on macOS.

Common situations: Editing an autostarted instance on a headless Linux host where the user session is not a real systemd user session; running limactl under an environment where XDG_RUNTIME_DIR is unset so `systemctl --user` cannot connect; partial upgrades where the autostart unit exists but the manager is unreachable; WSL2 edge cases not detected as ErrNotSupported.

Related errors


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