openclaw - ✅(Solved) Fix gateway status misreports LaunchAgent as not installed during launchctl gaps [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55587Fetched 2026-04-08 01:37:37
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

openclaw gateway status can print contradictory output on macOS:

  • it shows an existing LaunchAgent plist and command
  • but then reports Service unit not found. / Service not installed. Run: openclaw gateway install

This happens when launchctl print gui/$UID/<label> fails temporarily or the job is unloaded, even though the LaunchAgent plist still exists.

Root Cause

src/daemon/launchd.ts currently sets missingUnit: true for any non-zero launchctl print result. On macOS that conflates:

  • a truly missing plist / uninstalled service
  • a valid plist that is temporarily not bootstrapped or between restart phases

Fix Action

Fixed

PR fix notes

PR #55591: fix(daemon): avoid false 'not installed' launchagent status

Description (problem / solution / changelog)

Summary

  • stop treating every non-zero result as a missing LaunchAgent
  • check whether the LaunchAgent plist still exists before setting
  • add focused tests for both existing-plist and missing-plist launchctl failure cases

Testing

  • pnpm test -- src/daemon/launchd.test.ts (fails in this environment because node_modules is missing)
  • pnpm install (fails in this environment due npm DNS/network error: EAI_AGAIN to registry.npmjs.org)

Closes #55587

Changed files

  • src/daemon/launchd.test.ts (modified, +43/-1)
  • src/daemon/launchd.ts (modified, +2/-1)
RAW_BUFFERClick to expand / collapse

Summary

openclaw gateway status can print contradictory output on macOS:

  • it shows an existing LaunchAgent plist and command
  • but then reports Service unit not found. / Service not installed. Run: openclaw gateway install

This happens when launchctl print gui/$UID/<label> fails temporarily or the job is unloaded, even though the LaunchAgent plist still exists.

Observed output

Example symptoms:

  • Service: LaunchAgent (not loaded)
  • Service file: ~/Library/LaunchAgents/ai.openclaw.gateway.plist
  • Runtime: unknown (Bad request. Could not find service ...)
  • Service unit not found.
  • Service not installed. Run: openclaw gateway install

Root cause

src/daemon/launchd.ts currently sets missingUnit: true for any non-zero launchctl print result. On macOS that conflates:

  • a truly missing plist / uninstalled service
  • a valid plist that is temporarily not bootstrapped or between restart phases

Expected behavior

If the plist still exists, status should treat the LaunchAgent as present but not currently loaded/running, and avoid install guidance.

Proposed fix

In readLaunchAgentRuntime():

  • check whether the plist exists before returning missingUnit: true
  • only mark missingUnit when the plist is absent
  • otherwise return a non-missing runtime state (for example stopped/unknown) with the launchctl detail preserved

Why this matters

This false negative makes local deployments look broken and pushes users toward unnecessary reinstall/cleanup steps during normal restart windows.

extent analysis

Fix Plan

To resolve the issue, we need to modify the readLaunchAgentRuntime() function in src/daemon/launchd.ts to correctly handle the case where the LaunchAgent plist exists but the launchctl print command fails.

Here are the steps:

  • Check if the plist file exists before returning missingUnit: true.
  • If the plist exists, return a non-missing runtime state (e.g., stopped or unknown) with the launchctl detail preserved.
  • Only mark missingUnit when the plist is absent.

Example code:

function readLaunchAgentRuntime(): { missingUnit: boolean; runtime: string } {
  const plistPath = '~/Library/LaunchAgents/ai.openclaw.gateway.plist';
  const plistExists = fs.existsSync(plistPath);

  if (!plistExists) {
    return { missingUnit: true, runtime: 'Service unit not found.' };
  }

  try {
    const launchctlOutput = execSync(`launchctl print gui/$UID/ai.openclaw.gateway`);
    // Process the launchctl output to determine the runtime state
    const runtime = parseLaunchctlOutput(launchctlOutput);
    return { missingUnit: false, runtime };
  } catch (error) {
    // If launchctl print fails, return a non-missing runtime state
    return { missingUnit: false, runtime: 'stopped' };
  }
}

function parseLaunchctlOutput(output: string): string {
  // Implement parsing logic to determine the runtime state from the launchctl output
  // For example:
  if (output.includes('Service is not loaded')) {
    return 'stopped';
  } else {
    return 'unknown';
  }
}

Verification

To verify the fix, run the openclaw gateway status command after applying the changes. The output should correctly indicate the presence of the LaunchAgent plist and its runtime state, even if the launchctl print command fails temporarily.

Extra Tips

  • Make sure to test the changes on different macOS versions and environments to ensure compatibility.
  • Consider adding additional logging or error handling to help diagnose any future issues with the launchctl command or plist file access.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

If the plist still exists, status should treat the LaunchAgent as present but not currently loaded/running, and avoid install guidance.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix gateway status misreports LaunchAgent as not installed during launchctl gaps [1 pull requests, 1 participants]