openclaw - 💡(How to fix) Fix gateway.cmd does not inherit system PATH when run under macOS LaunchAgent [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#71776Fetched 2026-04-26 05:08:31
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×4

When OpenClaw is launched via macOS LaunchAgent (e.g., for headless cron scheduling on a Mac), gateway.cmd runs with a minimal PATH that doesn't include user-installed binaries. Tool invocations that depend on node, python3, git, etc. either fail silently or pick up wrong versions (often falling back to system-bundled tools at /usr/bin/...).

Root Cause

  • Production deployment on a headless Mac Mini, running OpenClaw under a ~/Library/LaunchAgents/<name>.plist
  • Originally observed against OpenClaw v2026.2.26; persists in our deployment on later versions because we've worked around it (see below) and never re-tested without the workaround.

Fix Action

Workaround

Explicit PATH in the LaunchAgent plist:

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>

Works, but every macOS user setting up headless OpenClaw has to discover this independently. The failure mode is silent — tools just behave wrong.

Code Example

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
RAW_BUFFERClick to expand / collapse

Summary

When OpenClaw is launched via macOS LaunchAgent (e.g., for headless cron scheduling on a Mac), gateway.cmd runs with a minimal PATH that doesn't include user-installed binaries. Tool invocations that depend on node, python3, git, etc. either fail silently or pick up wrong versions (often falling back to system-bundled tools at /usr/bin/...).

Observed in

  • Production deployment on a headless Mac Mini, running OpenClaw under a ~/Library/LaunchAgents/<name>.plist
  • Originally observed against OpenClaw v2026.2.26; persists in our deployment on later versions because we've worked around it (see below) and never re-tested without the workaround.

Reproduction

  1. Install OpenClaw on macOS.
  2. Configure a LaunchAgent plist for the gateway with no explicit EnvironmentVariables.PATH key.
  3. Boot the agent under the LaunchAgent (not from an interactive shell).
  4. From an agent prompt, invoke a tool that shells out to node, python3, or git and depends on a homebrew/pyenv-managed version.
  5. Tool either fails silently or runs against /usr/bin/python3 (system) instead of the user-managed binary.

The root cause is that LaunchAgent inherits a minimal PATH (typically /usr/bin:/bin:/usr/sbin:/sbin) and gateway.cmd doesn't source the user's shell profile or accept a config-level PATH.

Workaround

Explicit PATH in the LaunchAgent plist:

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>

Works, but every macOS user setting up headless OpenClaw has to discover this independently. The failure mode is silent — tools just behave wrong.

Suggested fix

One of (in increasing intrusiveness):

  1. Document the LaunchAgent setup pattern explicitly in the macOS install docs so users don't hit this silently.
  2. Accept a PATH config key in OpenClaw config that gets prepended to the inherited environment when the gateway boots.
  3. Source the user's shell profile (~/.zshrc / ~/.bash_profile) before tool invocations on macOS LaunchAgent runs.

(1) alone would already prevent most of the pain.

Severity

High for macOS LaunchAgent users, zero impact for everyone else.

extent analysis

TL;DR

To fix the issue of OpenClaw launching via macOS LaunchAgent with a minimal PATH, explicitly set the PATH in the LaunchAgent plist or modify OpenClaw to accept a PATH config key.

Guidance

  • Verify the issue by checking the PATH environment variable when OpenClaw is launched via LaunchAgent, and compare it to the PATH when launched from an interactive shell.
  • Consider documenting the required LaunchAgent setup pattern in the macOS install docs to prevent users from encountering this issue silently.
  • If modifying OpenClaw, accept a PATH config key that gets prepended to the inherited environment when the gateway boots, or source the user's shell profile before tool invocations on macOS LaunchAgent runs.
  • Test any changes by invoking tools that depend on node, python3, or git and verifying that they use the correct versions.

Example

<key>EnvironmentVariables</key>
<dict>
  <key>PATH</key>
  <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>

Notes

This issue only affects macOS LaunchAgent users, and the severity is high for them, but zero impact for other users. The suggested fixes have varying levels of intrusiveness, and documenting the LaunchAgent setup pattern may be the simplest solution.

Recommendation

Apply the workaround by explicitly setting the PATH in the LaunchAgent plist, as this is a straightforward and effective solution that can be implemented immediately.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING