[fix] adopt the login shell PATH when launched outside a terminal - #22
Merged
Conversation
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.
✅ SonarQube Quality Gate passed — pathorsAI_patchbay0 open issues on this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. Everywhichlookup 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 andpatchbay-mcp:$SHELL -l -i -cfor its PATH (login + interactive, so both~/.zprofileand~/.zshrcget their say; fish gets its ownstring joinspelling). stdin/stderr on/dev/null, output parsed only between two markers printed by our ownprintf, and a 5s hard timeout with kill — a prompt-happy rc file can delay startup, never hang it.Verified
Ran
patchbay-mcpunderenv -i PATH=/usr/bin:/bin:/usr/sbin:/sbinand calledverifyfor gcloud over JSON-RPC: previouslyunsupported / not available on PATH, nowvalid — 'pathors' (jack@pathors.com) minted an access token.Unit tests cover the launchd-default gate, merge ordering/dedup, marker extraction, and the fish spelling.