{"record":{"id":"e2ea79fa1f51e84e","repo":"lima-vm/lima","slug":"failed-to-install-plist-to-s-w","errorCode":null,"errorMessage":"failed to install plist to %s: %w","messagePattern":"failed to install plist to (.+?): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/autostart_darwin.go","lineNumber":133,"sourceCode":"\t\treturn fmt.Errorf(\"failed to render daemon plist: %w\", err)\n\t}\n\n\ttmp, err := os.CreateTemp(\"\", \"io.lima-vm.daemon.*.plist\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create temp file: %w\", err)\n\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)","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/autostart_darwin.go#L115-L151","documentation":"After staging the plist, daemonInstall copies it into /Library/LaunchDaemons via `sudo install -m 644`; this error wraps that sudo command's failure. Since the destination requires root, the copy fails when sudo is denied/canceled or the destination path is bad.","triggerScenarios":"`limactl autostart <instance> --condition=boot` on macOS when `sudo install -m 644 <tmp> /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist` exits nonzero: user canceled the sudo password prompt, user lacks sudo rights, or destination directory missing/odd permissions.","commonSituations":"Non-admin macOS account without sudo privileges; sudo timeout while the user is not at the terminal; MDM policies blocking writes to /Library/LaunchDaemons; stale LaunchDaemon file owned by another user blocking install.","solutions":["Rerun the command and enter the sudo password when prompted","Verify the account is an administrator: `groups` should include `admin`","Manually confirm write access: `ls -ld /Library/LaunchDaemons`","If a conflicting plist exists, remove it first: `sudo rm /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist`"],"exampleFix":"// before: limactl autostart myinstance --condition=boot  (sudo prompt canceled)\n// after:  sudo -v && limactl autostart myinstance --condition=boot","handlingStrategy":"try-catch","validationCode":"sudo -v 2>/dev/null || { echo \"sudo unavailable: need admin rights\"; exit 1; }\nls -ld /Library/LaunchDaemons >/dev/null || exit 1","typeGuard":null,"tryCatchPattern":"err := daemonInstall(ctx, inst.Name, inst.Dir, userName, keepAlive)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to install plist\") {\n\t\tlogrus.Error(\"Could not write to /Library/LaunchDaemons: confirm admin rights and accept the sudo prompt\")\n\t\treturn\n\t}\n\tpanic(err)\n}","preventionTips":["Always run boot-condition autostart from an interactive admin terminal","Cache sudo credentials with `sudo -v` just before scripted runs","Check MDM policies permit writes to /Library/LaunchDaemons","Remove conflicting stale plists before reinstalling"],"tags":["macos","launchd","sudo","permissions"],"backgroundTag":"sudo-permission-denied","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}