{"record":{"id":"100c2d9e8ec42dcf","repo":"lima-vm/lima","slug":"failed-to-check-if-the-autostart-entry-for-instanc-100c2d","errorCode":null,"errorMessage":"failed to check if the autostart entry for instance %#q is registered: %w","messagePattern":"failed to check if the autostart entry for instance %#q is registered: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/instance/restart.go","lineNumber":29,"sourceCode":"\t\"github.com/sirupsen/logrus\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/autostart\"\n\t\"github.com/lima-vm/lima/v2/pkg/limatype\"\n\t\"github.com/lima-vm/lima/v2/pkg/networks/reconcile\"\n)\n\nconst (\n\tlaunchHostAgentForeground = false\n)\n\nfunc Restart(ctx context.Context, inst *limatype.Instance, showProgress bool) error {\n\tif err := StopGracefully(ctx, inst, true); err != nil {\n\t\treturn err\n\t}\n\n\t// Network reconciliation will be performed by the process launched by the autostart manager\n\tif registered, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {\n\t\treturn fmt.Errorf(\"failed to check if the autostart entry for instance %#q is registered: %w\", inst.Name, err)\n\t} else if !registered {\n\t\tif err := reconcile.Reconcile(ctx, inst.Name); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := Start(ctx, inst, launchHostAgentForeground, showProgress); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\nfunc RestartForcibly(ctx context.Context, inst *limatype.Instance, showProgress bool) error {\n\tlogrus.Info(\"Restarting the instance forcibly\")\n\tStopForcibly(inst)\n\n\tif registered, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/instance/restart.go#L11-L47","documentation":"During a graceful restart, Lima checks whether the instance is registered with an autostart manager (launchd/systemd) so it knows whether the manager will bring the VM back up. If autostart.IsRegistered fails with an error other than ErrNotSupported (e.g. the launchd/systemd backend itself errored), the restart is aborted with this wrapped message naming the instance.","triggerScenarios":"Calling `limactl restart <inst>` (Restart -> StopGracefully, then autostart.IsRegistered) on macOS when launchd queries fail, or on Linux when systemctl --user queries fail (e.g. no user session bus, systemd not running).","commonSituations":"Running limactl over SSH or in a container without a systemd user session; DBUS_SESSION_BUS_ADDRESS unset; launchd plist directory unreadable; corrupted launchd/systemd state for the user.","solutions":["Ensure a working user session (loginctl enable-linger <user> on Linux; a GUI session on macOS).","Run limactl inside a normal user session with DBUS_SESSION_BUS_ADDRESS/systemd user instance available.","If the platform genuinely lacks autostart support, verify errors.Is(err, autostart.ErrNotSupported) - that path is tolerated and would not produce this error.","As a fallback, stop then start the instance manually instead of restart."],"exampleFix":"// before\nlimactl restart myvm  # over ssh without systemd user session\n// after\nssh -t user@host \"systemctl --user status\"  # verify session, then run restart in that session\n# or: limactl stop myvm && limactl start myvm","handlingStrategy":"try-catch","validationCode":"// before restart, check the environment\nif runtime.GOOS == \"linux\" {\n  if out, err := exec.Command(\"systemctl\", \"--user\", \"is-system-running\").Output(); err != nil {\n    log.Println(\"no systemd user session; autostart checks will fail\")\n  }\n}","typeGuard":null,"tryCatchPattern":"err := instance.Restart(ctx, inst, true)\nif err != nil && strings.Contains(err.Error(), \"autostart entry\") {\n  // fall back: stop then start manually\n  _ = instance.StopGracefully(ctx, inst, true)\n  err = instance.Start(ctx, inst, \"\")\n}","preventionTips":["Enable lingering for the user on Linux hosts","Run limactl from an interactive user session, not bare SSH without systemd","Check autostart support per-OS before using restart","Treat errors.Is(err, autostart.ErrNotSupported) as OK in your own wrappers"],"tags":["autostart","restart","systemd","launchd"],"backgroundTag":"autostart-manager-unavailable","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}