lima-vm/lima · error
failed to enable LaunchDaemon: %w
Error message
failed to enable LaunchDaemon: %w
What it means
daemonInstall runs `sudo launchctl enable system/<service>` after installing the plist; this error wraps that command's nonzero exit. launchctl enable failing usually means the service target is malformed, the plist is invalid, or launchd rejected the operation.
Source
Thrown at cmd/limactl/autostart_darwin.go:136
tmp, err := os.CreateTemp("", "io.lima-vm.daemon.*.plist")
if err != nil {
return fmt.Errorf("failed to create temp file: %w", err)
}
defer os.Remove(tmp.Name())
if _, err := tmp.Write(content); err != nil {
return fmt.Errorf("failed to write temp plist: %w", err)
}
tmp.Close()
destPath := launchd.GetDaemonPlistPath(instName)
svcTarget := "system/" + launchd.DaemonServiceNameFrom(instName)
_ = runSudo(ctx, "launchctl", "bootout", svcTarget)
if err := runSudo(ctx, "install", "-m", "644", tmp.Name(), destPath); err != nil {
return fmt.Errorf("failed to install plist to %s: %w", destPath, err)
}
if err := runSudo(ctx, "launchctl", "enable", svcTarget); err != nil {
return fmt.Errorf("failed to enable LaunchDaemon: %w", err)
}
if err := runSudo(ctx, "launchctl", "bootstrap", "system", destPath); err != nil {
return fmt.Errorf("failed to bootstrap LaunchDaemon: %w", err)
}
logrus.Infof("LaunchDaemon installed for instance %q (runs as %q at boot)", instName, userName)
logrus.Infof("Plist: %s", destPath)
return nil
}
func daemonUninstall(ctx context.Context, instName string) error {
svcTarget := "system/" + launchd.DaemonServiceNameFrom(instName)
destPath := launchd.GetDaemonPlistPath(instName)
_ = runSudo(ctx, "launchctl", "bootout", svcTarget)
_ = runSudo(ctx, "launchctl", "disable", svcTarget)
if err := runSudo(ctx, "rm", "-f", destPath); err != nil {
return fmt.Errorf("failed to remove %s: %w", destPath, err)View on GitHub (pinned to dd909d0973)
Solutions
- Rerun the command and complete the sudo prompt
- Validate the installed plist: `sudo plutil -lint /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist`
- Check the service state: `sudo launchctl print system/io.lima-vm.daemon.<instance>`
- Try manual bootout then re-run limactl to get a clean state
Example fix
// before: limactl autostart myinstance --condition=boot (fails after stale state) // after: sudo launchctl bootout system/io.lima-vm.daemon.myinstance; limactl autostart myinstance --condition=boot
Defensive patterns
Strategy: try-catch
Validate before calling
sudo plutil -lint /Library/LaunchDaemons/io.lima-vm.daemon.<instance>.plist || echo "plist invalid" sudo launchctl print system/io.lima-vm.daemon.<instance> >/dev/null 2>&1 && echo "service already loaded"
Try / catch
if err := daemonInstall(ctx, inst.Name, inst.Dir, userName, keepAlive); err != nil {
if strings.Contains(err.Error(), "failed to enable LaunchDaemon") {
// recover: bootout stale state and retry once
_ = runSudo(ctx, "launchctl", "bootout", "system/io.lima-vm.daemon."+inst.Name)
return daemonInstall(ctx, inst.Name, inst.Dir, userName, keepAlive)
}
return err
} Prevention
- Bootout the service before re-enabling on existing installs
- Lint the plist with plutil after any manual edits
- Avoid installing system daemons over SSH on macOS versions that restrict the system domain
- Keep sudo sessions fresh across multi-step installs
When it happens
Trigger: `limactl autostart <instance> --condition=boot` on macOS when `sudo launchctl enable system/io.lima-vm.daemon.<instance>` fails: canceled sudo prompt, malformed plist at the destination, or launchctl unavailable in the current context (e.g. SSH session without proper domain access).
Common situations: Installing over SSH where the system domain is not accessible in older macOS versions; corrupted plist from a previous failed install; sudo session expired mid-sequence.
Related errors
- failed to bootstrap LaunchDaemon: %w
- failed to install plist to %s: %w
- failed to remove %s: %w
- failed to create temp file: %w
- failed to write temp plist: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/f60332f37b52aa91.
Report an issue: GitHub.