Skip to content

[fix] adopt the login shell PATH when launched outside a terminal - #22

Merged
YJack0000 merged 1 commit into
mainfrom
claude/gcloud-cli-path-issue-3634b6
Aug 23, 2026
Merged

[fix] adopt the login shell PATH when launched outside a terminal#22
YJack0000 merged 1 commit into
mainfrom
claude/gcloud-cli-path-issue-3634b6

Conversation

@YJack0000

Copy link
Copy Markdown
Contributor

Problem

Launched from Finder/Dock (or spawned by a GUI MCP client like Claude Desktop), patchbay inherits launchd's bare PATH=/usr/bin:/bin:/usr/sbin:/sbin. Every which lookup inside the process fails for anything the user's shell startup files add — ~/google-cloud-sdk/bin, Homebrew, npm prefixes — so the panel answered every tier-2 action with "the gcloud CLI is not available on PATH" for a gcloud that works fine in any terminal.

Fix

New patchbay_core::shell_path::adopt_login_shell_path(), called at startup of the panel and patchbay-mcp:

  • Runs only when the inherited PATH is the launchd default (every entry in the known system set). A PATH with any user entry means a real environment reached us — left untouched, so terminal launches pay nothing.
  • Asks $SHELL -l -i -c for its PATH (login + interactive, so both ~/.zprofile and ~/.zshrc get their say; fish gets its own string join spelling). stdin/stderr on /dev/null, output parsed only between two markers printed by our own printf, and a 5s hard timeout with kill — a prompt-happy rc file can delay startup, never hang it.
  • Merges shell-first (the shell's ordering is what the terminal resolves with), deduplicated; any failure leaves the PATH as it was.

Verified

Ran patchbay-mcp under env -i PATH=/usr/bin:/bin:/usr/sbin:/sbin and called verify for gcloud over JSON-RPC: previously unsupported / not available on PATH, now valid — 'pathors' (jack@pathors.com) minted an access token.

Unit tests cover the launchd-default gate, merge ordering/dedup, marker extraction, and the fish spelling.

macOS hands GUI apps and launchd children a bare
/usr/bin:/bin:/usr/sbin:/sbin, so the panel — and an MCP server spawned
by a GUI client — reported installed CLIs as "not available on PATH"
while the same probes worked in a terminal. At startup, when the
inherited PATH is the launchd default, ask the user's login shell for
its PATH (stdin/stderr on /dev/null, 5s hard timeout, marker-delimited
output) and adopt it. A PATH with any user entry on it is left alone.
@github-actions

Copy link
Copy Markdown

✅ SonarQube Quality Gate passed — pathorsAI_patchbay

0 open issues on this PR.

@YJack0000
YJack0000 merged commit 8f82f14 into main Aug 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant