Skip to content

fix: adopt the login shell's PATH so a Finder launch finds the agent CLIs - #84

Merged
IAmJSD merged 1 commit into
mainfrom
fix/macos-gui-path
Aug 30, 2026
Merged

IAmJSD merged 1 commit into
mainfrom
fix/macos-gui-path

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Aug 30, 2026

Copy link
Copy Markdown
Member

Problem

In the signed macOS build, the AI panel reports The Claude Code CLI ("claude") is not on PATH even when it plainly is — launching the same build from a terminal works.

A Finder/Dock launch inherits launchd's minimal PATH (/usr/bin:/bin:/usr/sbin:/sbin); the user's shell additions (~/.local/bin, /opt/homebrew/bin, npm prefixes…) never reach the GUI process. Backend::available() and the agent SDKs' own spawns both resolve through the process PATH, so both miss the CLIs.

Fix

ai::adopt_login_shell_path(), called early in main (unix-only), the same approach Zed and VS Code take:

  • Skipped when TERM is set — a terminal launch already carries the right PATH.
  • Runs $SHELL -l -i -c printing $PATH between marker strings, and adopts the fenced value. Login + interactive so both profile and rc files contribute (installers append to either); the markers strip whatever banners those files print.
  • The printf runs under sh inside the shell, because fish expands its own "$PATH" space-joined while its exported environment is colon-joined.
  • stdin is null so an interactive shell can't wait on it, and a 5-second timeout means a hung rc file degrades to today's behavior instead of hanging launch.

Testing

cargo check clean. Probe verified end-to-end on Linux with a fake $HOME whose profile prints a banner and prepends a dir: the value between the markers comes back with the rc's edit and without the noise. Needs a Finder-launched macOS build for final confirmation.

🤖 Generated with Claude Code

…CLIs

A macOS app launched from Finder/Dock inherits launchd's minimal PATH,
so the AI panel reported claude/codex as not installed even though a
terminal launch found them fine. Ask the user's login shell for its PATH
once at startup (marker-fenced, sh-wrapped for fish, 5s timeout) and
adopt it before availability is probed or the SDKs spawn anything.

Co-Authored-By: Claude Fable 5 <[email protected]>
@IAmJSD
IAmJSD merged commit 7cac047 into main Aug 30, 2026
3 checks passed
@IAmJSD
IAmJSD deleted the fix/macos-gui-path branch August 30, 2026 21:03
IAmJSD added a commit that referenced this pull request Aug 30, 2026
Asking the login shell for its PATH is a whole shell startup — 0.75s on
a real dotfile setup — and every Finder launch since #84 has waited out
that shell before the window was created, because the answer was
published with `set_var` and that is only sound before other threads
exist.

The probe moves to its own thread and stops touching the process
environment. Its answer is published through a mutex/condvar and handed
to each spawn explicitly: `path::current()` never waits and is what
`Backend::available` and the picker read, `path::resolved()` waits (five
seconds for the shell, six for a caller) and is only ever called from a
worker thread about to spawn a CLI. Both SDKs are given an absolute
`cli_path`/`command` plus a PATH override for the children they spawn in
turn, so nothing depends on the app's own environment any more — which
also spares the Claude SDK its discovery pass, a `claude --version`
spawn on every connect.

Availability computed while the probe is still out can say a CLI is
missing when it is merely off launchd's PATH, so the workspace watches
for the answer and redoes it, refreshing the model catalogs if the panel
is open.


Claude-Session: https://claude.ai/code/session_012FgdQwG9FfmLWtpRvC7VWP

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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