{"record":{"id":"ff79b88d26ba458a","repo":"lima-vm/lima","slug":"failed-to-disable-the-autostart-entry-for-instance","errorCode":null,"errorMessage":"failed to disable the autostart entry for instance %#q: %w","messagePattern":"failed to disable the autostart entry for instance %#q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/autostart/managers.go","lineNumber":106,"sourceCode":"\t}\n\tif err := os.WriteFile(entryFilePath, content, 0o644); err != nil {\n\t\treturn fmt.Errorf(\"failed to write the autostart entry for instance %#q: %w\", inst.Name, err)\n\t}\n\tif t.enabler != nil {\n\t\treturn t.enabler(ctx, true, inst.Name)\n\t}\n\treturn nil\n}\n\nfunc (t *TemplateFileBasedManager) UnregisterFromStartAtLogin(ctx context.Context, inst *limatype.Instance) error {\n\tif registered, err := t.IsRegistered(ctx, inst); err != nil {\n\t\treturn fmt.Errorf(\"failed to check if the autostart entry for instance %#q is registered: %w\", inst.Name, err)\n\t} else if !registered {\n\t\treturn nil\n\t}\n\tif t.enabler != nil {\n\t\tif err := t.enabler(ctx, false, inst.Name); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to disable the autostart entry for instance %#q: %w\", inst.Name, err)\n\t\t}\n\t}\n\tif err := os.Remove(t.filePath(inst.Name)); err != nil {\n\t\treturn fmt.Errorf(\"failed to remove the autostart entry for instance %#q: %w\", inst.Name, err)\n\t}\n\treturn nil\n}\n\nfunc (t *TemplateFileBasedManager) renderTemplate(instName, workDir string, getExecutable func() (string, error)) ([]byte, error) {\n\tif t.template == \"\" {\n\t\treturn nil, errors.New(\"no template available\")\n\t}\n\tselfExeAbs, err := getExecutable()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdata := map[string]string{\n\t\t\"Binary\":   selfExeAbs,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/autostart/managers.go#L88-L124","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// manually finish the failed unregister\nsystemctl --user disable --now lima-default.service 2>/dev/null || true\nrm ~/.config/systemd/user/lima-default.service\nsystemctl --user daemon-reload","handlingStrategy":"fallback","validationCode":"// verify systemd user session before unregistering\nif runtime.GOOS == \"linux\" {\n    if os.Getenv(\"XDG_RUNTIME_DIR\") == \"\" {\n        os.Setenv(\"XDG_RUNTIME_DIR\", \"/run/user/\"+strconv.Itoa(os.Getuid()))\n    }\n}\n","typeGuard":null,"tryCatchPattern":"if err := mgr.UnregisterFromStartAtLogin(ctx, inst); err != nil {\n    log.Warnf(\"disable failed (%v); removing entry file manually\", err)\n    os.Remove(entryPath(inst.Name))\n    exec.Command(\"systemctl\", \"--user\", \"daemon-reload\").Run()\n}\n","preventionTips":["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"],"tags":["autostart","systemd","launchd","linux"],"backgroundTag":"systemctl-disable-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}