{"record":{"id":"cf4c4785a2977353","repo":"lima-vm/lima","slug":"failed-to-bootstrap-launchdaemon-w","errorCode":null,"errorMessage":"failed to bootstrap LaunchDaemon: %w","messagePattern":"failed to bootstrap LaunchDaemon: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/autostart_darwin.go","lineNumber":139,"sourceCode":"\t}\n\tdefer os.Remove(tmp.Name())\n\tif _, err := tmp.Write(content); err != nil {\n\t\treturn fmt.Errorf(\"failed to write temp plist: %w\", err)\n\t}\n\ttmp.Close()\n\n\tdestPath := launchd.GetDaemonPlistPath(instName)\n\tsvcTarget := \"system/\" + launchd.DaemonServiceNameFrom(instName)\n\n\t_ = runSudo(ctx, \"launchctl\", \"bootout\", svcTarget)\n\tif err := runSudo(ctx, \"install\", \"-m\", \"644\", tmp.Name(), destPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to install plist to %s: %w\", destPath, err)\n\t}\n\tif err := runSudo(ctx, \"launchctl\", \"enable\", svcTarget); err != nil {\n\t\treturn fmt.Errorf(\"failed to enable LaunchDaemon: %w\", err)\n\t}\n\tif err := runSudo(ctx, \"launchctl\", \"bootstrap\", \"system\", destPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to bootstrap LaunchDaemon: %w\", err)\n\t}\n\n\tlogrus.Infof(\"LaunchDaemon installed for instance %q (runs as %q at boot)\", instName, userName)\n\tlogrus.Infof(\"Plist: %s\", destPath)\n\treturn nil\n}\n\nfunc daemonUninstall(ctx context.Context, instName string) error {\n\tsvcTarget := \"system/\" + launchd.DaemonServiceNameFrom(instName)\n\tdestPath := launchd.GetDaemonPlistPath(instName)\n\n\t_ = runSudo(ctx, \"launchctl\", \"bootout\", svcTarget)\n\t_ = runSudo(ctx, \"launchctl\", \"disable\", svcTarget)\n\tif err := runSudo(ctx, \"rm\", \"-f\", destPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove %s: %w\", destPath, err)\n\t}\n\tlogrus.Infof(\"LaunchDaemon uninstalled for instance %q\", instName)\n\treturn nil","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/autostart_darwin.go#L121-L157","documentation":"The final step of daemonInstall runs `sudo launchctl bootstrap system <plist>` to load the LaunchDaemon into the system domain; this error wraps that command's failure. The most common cause is launchd error 5 (Bootstrap failed: already loaded) when the daemon is already bootstrapped, or an invalid plist.","triggerScenarios":"`limactl autostart <instance> --condition=boot` when `sudo launchctl bootstrap system /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist` exits nonzero: daemon already bootstrapped (EEXIST), plist failed plutil lint, program path in plist (limactl binary) missing or not executable, or canceled sudo.","commonSituations":"Re-running enable on an already-active daemon whose bootout in the same invocation failed silently; limactl was moved/built elsewhere so the Binary path in the plist points to a nonexistent file; SIP/MDM restrictions on system-domain bootstrapping over SSH.","solutions":["Bootout first, then retry: `sudo launchctl bootout system/io.lima-vm.daemon.<instance>` then rerun limactl autostart","Lint the plist: `sudo plutil -lint /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist`","Verify the Binary path in the plist exists and is executable (points at the limactl that ran the command)","Check the error output above the message for launchd's numeric error code"],"exampleFix":"// before: limactl autostart myinstance --condition=boot  (Bootstrap failed: 5)\n// after:  sudo launchctl bootout system/io.lima-vm.daemon.myinstance && limactl autostart myinstance --condition=boot","handlingStrategy":"retry","validationCode":"svc=system/io.lima-vm.daemon.<instance>\nsudo launchctl print \"$svc\" >/dev/null 2>&1 && sudo launchctl bootout \"$svc\"\nsudo plutil -lint /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist","typeGuard":null,"tryCatchPattern":"err := daemonInstall(ctx, inst.Name, inst.Dir, userName, keepAlive)\nif err != nil && strings.Contains(err.Error(), \"failed to bootstrap LaunchDaemon\") {\n\t// Bootstrap failed is usually 'already bootstrapped': bootout then retry once\n\t_ = runSudo(ctx, \"launchctl\", \"bootout\", \"system/io.lima-vm.daemon.\"+inst.Name)\n\terr = daemonInstall(ctx, inst.Name, inst.Dir, userName, keepAlive)\n}","preventionTips":["Always bootout before re-running enable on an existing daemon","Verify the limactl binary path recorded in the plist still exists and is executable","Do not rebuild/move limactl between enable and bootstrap","Read the launchd numeric error code printed by the command for precise diagnosis"],"tags":["macos","launchd","daemon","sudo"],"backgroundTag":"launchctl-bootstrap-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}