Skip to content

fix(desktop): resolve user shell PATH on macOS for MCP and localshell…#91

Open
DivXPro wants to merge 1 commit into
qqqqqf-q:mainfrom
DivXPro:fix/desktop-macos-path-resolution
Open

fix(desktop): resolve user shell PATH on macOS for MCP and localshell…#91
DivXPro wants to merge 1 commit into
qqqqqf-q:mainfrom
DivXPro:fix/desktop-macos-path-resolution

Conversation

@DivXPro

@DivXPro DivXPro commented May 28, 2026

Copy link
Copy Markdown
Contributor

… 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

… 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +280 to +281
if err == nil {
return parsePathHelperOutput(out), nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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__")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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