{"record":{"id":"9e07adb320216f13","repo":"lima-vm/lima","slug":"failed-to-check-autostart-registration-w","errorCode":null,"errorMessage":"failed to check autostart registration: %w","messagePattern":"failed to check autostart registration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/instance/start.go","lineNumber":254,"sourceCode":"\n\tprepared, err := Prepare(ctx, inst, guestAgent)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif limactl == \"\" {\n\t\tlimactl, err = os.Executable()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\thaStdoutPath := filepath.Join(inst.Dir, filenames.HostAgentStdoutLog)\n\thaStderrPath := filepath.Join(inst.Dir, filenames.HostAgentStderrLog)\n\n\tbegin := time.Now() // used for logrus propagation\n\tvar haCmd *exec.Cmd\n\tif isRegisteredToAutoStart, err := autostart.IsRegistered(ctx, inst); err != nil && !errors.Is(err, autostart.ErrNotSupported) {\n\t\treturn fmt.Errorf(\"failed to check autostart registration: %w\", err)\n\t} else if !isRegisteredToAutoStart || launchHostAgentForeground {\n\t\tif err := os.RemoveAll(haStdoutPath); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := os.RemoveAll(haStderrPath); err != nil {\n\t\t\treturn err\n\t\t}\n\t\thaStdoutW, err := os.Create(haStdoutPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// no defer haStdoutW.Close()\n\t\thaStderrW, err := os.Create(haStderrPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// no defer haStderrW.Close()\n","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/instance/start.go#L236-L272","documentation":"While launching the host agent, Lima checks autostart.IsRegistered to decide whether to spawn the host agent in the foreground or let the autostart manager do it. A backend error other than autostart.ErrNotSupported aborts the start with this message.","triggerScenarios":"`limactl start <inst>` on a host where the launchd (macOS) or systemd user (Linux) query fails: no systemd user session, dbus unavailable, or launchd plist lookup error.","commonSituations":"Starting instances from CI/containers/SSH sessions without a user service manager; running limactl as a different user than the one with the session; minimal Linux installs without systemd.","solutions":["Ensure a systemd user session exists (systemctl --user status works) and enable lingering: loginctl enable-linger $USER.","Run limactl from the same user session that owns the instance directory.","On truly autostart-less platforms, the ErrNotSupported path is tolerated - if you get this error instead, the backend exists but is failing; fix the session/dbus environment.","Alternative: limactl start --foreground (or the equivalent) to avoid the autostart decision path if available."],"exampleFix":"// before\nssh host \"limactl start myvm\"  # no user session\n// after\nssh host \"loginctl enable-linger $USER && systemctl --user status && limactl start myvm\"","handlingStrategy":"try-catch","validationCode":"// confirm a user service manager is reachable before start\nif err := exec.Command(\"systemctl\", \"--user\", \"is-system-running\").Run(); err != nil && runtime.GOOS == \"linux\" {\n  log.Println(\"no systemd user session: start via autostart check may fail\")\n}","typeGuard":null,"tryCatchPattern":"err := instance.Start(ctx, inst, \"\")\nif err != nil && strings.Contains(err.Error(), \"check autostart registration\") {\n  // retry in foreground path or after fixing the user session\n  err = startForeground(ctx, inst)\n}","preventionTips":["Enable lingering so services survive without an interactive session","Run limactl as the instance-owning user","Keep dbus/systemd user instance healthy in CI images","Prefer foreground start on hosts without autostart support"],"tags":["autostart","hostagent","systemd"],"backgroundTag":"autostart-manager-unavailable","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}