fix(desktop): resolve user shell PATH on macOS for MCP and localshell…#91
fix(desktop): resolve user shell PATH on macOS for MCP and localshell…#91DivXPro wants to merge 1 commit into
Conversation
… tools
macOS GUI apps launched from Finder/Dock inherit a stripped PATH
(/usr/bin:/bin:/usr/sbin:/sbin) instead of the full shell PATH that
includes Homebrew, pip, go install, etc. This causes MCP stdio tools
and localshell to fail finding user-installed programs.
- Add resolveUserShellPATH() called early in sidecar startup on darwin
- Uses /usr/libexec/path_helper (preferred) or shell login env as fallback
- Merges shell PATH into process environment, deduplicating entries
- Fix localshell processPath() to read actual os.Getenv("PATH") on unix
- Guarded to darwin-only; Windows reads PATH from registry so unaffected
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3285d1ccfb
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if err == nil { | ||
| return parsePathHelperOutput(out), nil |
There was a problem hiding this comment.
Probe the login shell even when path_helper succeeds
When /usr/libexec/path_helper exists, which is the normal macOS case, this returns before the login-shell probe below runs. path_helper only reconstructs the system path baseline, so PATH entries added by the user's shell startup files (for example ~/.local/bin, Go/Python tool dirs, pyenv/asdf shims) are still omitted, leaving MCP and localshell unable to find the same tools available in the user's terminal. Use path_helper as a baseline but still run and merge the login shell PATH instead of returning here.
Useful? React with 👍 / 👎.
| } | ||
| ctx, cancel := context.WithTimeout(context.Background(), timeout) | ||
| defer cancel() | ||
| cmd := exec.CommandContext(ctx, shell, "-ilc", "echo __PATH__$PATH__PATH__") |
There was a problem hiding this comment.
Delimit PATH without extending the variable name
If the path_helper branch cannot be used, this fallback does not actually print $PATH: in POSIX shells __PATH__$PATH__PATH__ expands the variable named PATH__PATH__, so the output lacks the closing marker and parseShellPATHOutput returns empty. In that fallback scenario the desktop process keeps the stripped GUI PATH; wrap the variable as ${PATH} (or quote via printf) so the marker is emitted separately.
Useful? React with 👍 / 👎.
… tools
macOS GUI apps launched from Finder/Dock inherit a stripped PATH (/usr/bin:/bin:/usr/sbin:/sbin) instead of the full shell PATH that includes Homebrew, pip, go install, etc. This causes MCP stdio tools and localshell to fail finding user-installed programs.