lima-vm/lima · error
failed to disable the autostart entry for instance %#q: %w
Error message
failed to disable the autostart entry for instance %#q: %w
What it means
This error means the enabler callback (e.g. `systemctl --user disable` or `launchctl unload`) failed while unregistering an autostart entry for the instance. The entry file still exists on disk; only the disable step failed, so the entry may re-activate at next login.
Source
Thrown at pkg/autostart/managers.go:106
}
if err := os.WriteFile(entryFilePath, content, 0o644); err != nil {
return fmt.Errorf("failed to write the autostart entry for instance %#q: %w", inst.Name, err)
}
if t.enabler != nil {
return t.enabler(ctx, true, inst.Name)
}
return nil
}
func (t *TemplateFileBasedManager) UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error {
if registered, err := t.IsRegistered(ctx, inst); err != nil {
return fmt.Errorf("failed to check if the autostart entry for instance %#q is registered: %w", inst.Name, err)
} else if !registered {
return nil
}
if t.enabler != nil {
if err := t.enabler(ctx, false, inst.Name); err != nil {
return fmt.Errorf("failed to disable the autostart entry for instance %#q: %w", inst.Name, err)
}
}
if err := os.Remove(t.filePath(inst.Name)); err != nil {
return fmt.Errorf("failed to remove the autostart entry for instance %#q: %w", inst.Name, err)
}
return nil
}
func (t *TemplateFileBasedManager) renderTemplate(instName, workDir string, getExecutable func() (string, error)) ([]byte, error) {
if t.template == "" {
return nil, errors.New("no template available")
}
selfExeAbs, err := getExecutable()
if err != nil {
return nil, err
}
data := map[string]string{
"Binary": selfExeAbs,View on GitHub (pinned to dd909d0973)
Solutions
- Read the wrapped error; run `systemctl --user daemon-reload` then retry unregister
- Check that a user systemd session exists: `systemctl --user status` (on SSH/headless, set XDG_RUNTIME_DIR=/run/user/$(id -u))
- Manually disable and delete: `systemctl --user disable --now lima-<instance>.service` and remove the file under ~/.config/systemd/user/
- If the unit is unknown to systemd, just delete the entry file manually and re-run
Example fix
// manually finish the failed unregister systemctl --user disable --now lima-default.service 2>/dev/null || true rm ~/.config/systemd/user/lima-default.service systemctl --user daemon-reload
Defensive patterns
Strategy: fallback
Validate before calling
// verify systemd user session before unregistering
if runtime.GOOS == "linux" {
if os.Getenv("XDG_RUNTIME_DIR") == "" {
os.Setenv("XDG_RUNTIME_DIR", "/run/user/"+strconv.Itoa(os.Getuid()))
}
}
Try / catch
if err := mgr.UnregisterFromStartAtLogin(ctx, inst); err != nil {
log.Warnf("disable failed (%v); removing entry file manually", err)
os.Remove(entryPath(inst.Name))
exec.Command("systemctl", "--user", "daemon-reload").Run()
}
Prevention
- Run `systemctl --user daemon-reload` after touching unit files manually
- Ensure a systemd user session exists (loginctl enable-linger for headless use)
- Don't hand-edit Lima-generated unit files; re-register via limactl instead
- Set XDG_RUNTIME_DIR when operating over SSH
When it happens
Trigger: UnregisterFromStartAtLogin finds the entry registered, then calls t.enabler(ctx, false, inst.Name); a non-zero exit from systemctl --user disable (unit unknown to systemd, systemd user session not running) or launchctl unload failure produces this wrapped error.
Common situations: Entry file was hand-copied or edited so systemd no longer recognizes the unit; systemd --user daemon-reload wasn't run after manual changes; running over SSH without a user session bus (XDG_RUNTIME_DIR unset) so systemctl --user fails; stale entry left from an older Lima version with a different unit name.
Related errors
- failed to check if the autostart entry for instance %#q is r
- failed to start the instance %#q via systemctl: %w
- failed to stop the instance %#q via systemctl: %w
- failed to check if the autostart entry for instance %#q is r
- failed to request start via autostart manager: %w
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/ff79b88d26ba458a.
Report an issue: GitHub.