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

startAtLoginAction calls autostart.IsRegistered to check whether the instance's autostart entry (systemd user service / launchd agent) exists; if that check itself fails, the error is wrapped with the instance name and returned. This means the registration lookup could not be performed at all — distinct from the entry simply not being registered.

Source

Thrown at cmd/limactl/start-at-login_unix.go:42

		instName = args[0]
	}

	inst, err := store.Inspect(ctx, instName)
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			logrus.Infof("Instance %#q not found", instName)
			return nil
		}
		return err
	}

	flags := cmd.Flags()
	startAtLogin, err := flags.GetBool("enabled")
	if err != nil {
		return err
	}
	if registered, err := autostart.IsRegistered(ctx, inst); err != nil {
		return fmt.Errorf("failed to check if the autostart entry for instance %#q is registered: %w", inst.Name, err)
	} else if startAtLogin {
		verb := "create"
		if registered {
			verb = "update"
		}
		if err := autostart.RegisterToStartAtLogin(ctx, inst); err != nil {
			return fmt.Errorf("failed to %s the autostart entry for instance %#q: %w", verb, inst.Name, err)
		}
		logrus.Infof("The autostart entry for instance %#q has been %sd", inst.Name, verb)
	} else {
		if !registered {
			logrus.Infof("The autostart entry for instance %#q is not registered", inst.Name)
		} else if err := autostart.UnregisterFromStartAtLogin(ctx, inst); err != nil {
			return fmt.Errorf("failed to unregister the autostart entry for instance %#q: %w", inst.Name, err)
		} else {
			logrus.Infof("The autostart entry for instance %#q has been unregistered", inst.Name)
		}
	}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Ensure a user systemd session exists: `systemctl --user status` should work in the same environment
  2. Run the command from a normal login session (not a bare SSH exec without session setup)
  3. Enable lingering so user services can run: `loginctl enable-linger $USER`
  4. Check that the platform backend is supported (systemd on Linux, launchd on macOS)

Example fix

// before: failing over plain ssh without session
ssh host limactl start-at-login default --enabled
// after
ssh host 'XDG_RUNTIME_DIR=/run/user/$(id -u) systemctl --user status >/dev/null && limactl start-at-login default --enabled'
Defensive patterns

Strategy: validation

Validate before calling

systemctl --user status >/dev/null 2>&1 || { echo 'no user systemd session; run from a login session or enable lingering' >&2; exit 1; }

Try / catch

if ! limactl start-at-login "$inst" 2>err.log; then
  cat err.log >&2
  grep -q 'autostart entry' err.log && loginctl enable-linger "$USER"
fi

Prevention

When it happens

Trigger: Running `limactl start-at-login <instance>` (with or without --enabled) on a Unix host where the autostart backend fails: systemctl user session unavailable (no XDG_RUNTIME_DIR / lingering not set up), launchd lookup failure, or underlying command errors.

Common situations: Running limactl over SSH without a user systemd session; dbus/session bus not running; systemd user instance not started; non-systemd minimal distros lacking systemctl.

Related errors


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