fix(daemon): clear launchd disabled state before bootstrap (#849) (thanks @ndraiman)

This commit is contained in:
Peter Steinberger
2026-01-15 03:35:24 +00:00
parent d51a9ebb0e
commit dfea2991c9
3 changed files with 97 additions and 2 deletions

View File

@@ -410,12 +410,12 @@ export async function installLaunchAgent({
await execLaunchctl(["bootout", domain, plistPath]);
await execLaunchctl(["unload", plistPath]);
// launchd can persist "disabled" state even after bootout + plist removal; clear it before bootstrap.
await execLaunchctl(["enable", `${domain}/${label}`]);
const boot = await execLaunchctl(["bootstrap", domain, plistPath]);
if (boot.code !== 0) {
throw new Error(`launchctl bootstrap failed: ${boot.stderr || boot.stdout}`.trim());
}
await execLaunchctl(["enable", `${domain}/${label}`]);
await execLaunchctl(["kickstart", "-k", `${domain}/${label}`]);
stdout.write(`${formatLine("Installed LaunchAgent", plistPath)}\n`);