Repository navigation
fix(agents): detect all user-installed CLIs by hydrating PATH from login shell - #843
Merged
Merged
Conversation
…and ~/.vite-plus/bin Packaged Electron inherits a minimal PATH without shell rc files, so agent install-script fallback dirs stay invisible to `which` probes — the Agents settings page then shows OpenCode/Pi as "Not installed" even when the user can run them from Terminal. Add ~/bin, ~/.opencode/bin, and ~/.vite-plus/bin to the packaged PATH augmentation so preflight detection matches shell behavior. Fixes #829
…utton
Packaged Electron inherits a minimal launchd PATH that misses whatever
the user's shell rc files append — ~/.opencode/bin, ~/.cargo/bin, nvm
shims, pyenv, custom tool dirs. The preceding commit hardcoded two known
install locations; this replaces that whack-a-mole pattern with a
generic approach.
On packaged startup (non-Windows), spawn `${SHELL} -ilc 'echo $PATH'`
with a 5s timeout, parse the delimited PATH, and prepend any new
segments to process.env.PATH. The result is cached for the app session
so we pay the shell-init cost at most once.
Surface a Refresh button in Settings > Agents that forces a re-probe
and re-detects installed agents — handy right after installing a new
CLI, no restart needed.
Live-verified that a `zsh -ilc` spawn with a minimal launchd-style env
still resolves the user's full PATH (32+ segments including the
rc-appended dirs).
Set preserves insertion order, so PATH first-match-wins semantics are preserved without manual tracking. Set.prototype.difference (Node 22+) expresses the new-segments calculation in mergePathSegments as the set-difference operation it always was.
5 tasks
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…gin shell (stablyai#843) * fix(agents): detect opencode/pi CLIs installed under ~/.opencode/bin and ~/.vite-plus/bin Packaged Electron inherits a minimal PATH without shell rc files, so agent install-script fallback dirs stay invisible to `which` probes — the Agents settings page then shows OpenCode/Pi as "Not installed" even when the user can run them from Terminal. Add ~/bin, ~/.opencode/bin, and ~/.vite-plus/bin to the packaged PATH augmentation so preflight detection matches shell behavior. Fixes stablyai#829 * feat(agents): hydrate PATH from user's login shell + Agents Refresh button Packaged Electron inherits a minimal launchd PATH that misses whatever the user's shell rc files append — ~/.opencode/bin, ~/.cargo/bin, nvm shims, pyenv, custom tool dirs. The preceding commit hardcoded two known install locations; this replaces that whack-a-mole pattern with a generic approach. On packaged startup (non-Windows), spawn `${SHELL} -ilc 'echo $PATH'` with a 5s timeout, parse the delimited PATH, and prepend any new segments to process.env.PATH. The result is cached for the app session so we pay the shell-init cost at most once. Surface a Refresh button in Settings > Agents that forces a re-probe and re-detects installed agents — handy right after installing a new CLI, no restart needed. Live-verified that a `zsh -ilc` spawn with a minimal launchd-style env still resolves the user's full PATH (32+ segments including the rc-appended dirs). * refactor(hydrate-shell-path): simplify dedup with Set + Set.difference Set preserves insertion order, so PATH first-match-wins semantics are preserved without manual tracking. Set.prototype.difference (Node 22+) expresses the new-segments calculation in mergePathSegments as the set-difference operation it always was.
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.
Summary
GUI-launched Electron on macOS/Linux inherits a minimal launchd PATH that doesn't include whatever the user's shell rc files append —
~/.opencode/bin,~/.cargo/bin,~/.vite-plus/bin, nvm shims, pyenv, custom tool dirs. Result: the Agents settings page reports CLIs as "Not installed" even whenwhichresolves them fine from Terminal (see #829 repro withopencodeandpi).This PR replaces a whack-a-mole fix (hardcoding two known install paths) with a generic solution:
src/main/startup/hydrate-shell-path.ts): on packaged startup (non-Windows), spawn${SHELL} -ilc 'echo \$PATH'with a 5s timeout, parse the delimited PATH, and prepend new segments toprocess.env.PATH. Cached once per session.patchPackagedProcessPathstill seeds homebrew/nix/user bin dirs synchronously, so early IPC calls (before the shell spawn completes) aren't empty-handed, and we still resolve something reasonable if the spawn fails.Fixes #829
How it handles edge cases
ok: false, nothing merged, detection still runs against existing PATH.-ilc.pnpm devinherits a full PATH from the launching terminal, no spawn cost needed).Test plan