fix(shell): find user CLIs when POSIX PATH probes fail #24632
Problem#
When POSIX login-shell discovery yields no PATH and macOS launchctl also yields none, startup can miss user-installed CLIs outside the inherited system directories.
Change#
Append a small set of known CLI directories only after those probes fail. Preserve the inherited PATH order and deduplicate entries, so existing nvm/mise/fnm choices retain priority. Successful probe results, Windows handling, caching, mise metadata and AppImage cleanup remain unchanged. Share the directory list between desktop startup and standalone server startup.
Thanks to @CyberStefNef for the original investigation and implementation in #9232. The takeover preserves that history, integrates main, removes six redundant tests and keeps one behavioral regression. An independent review identified the inherited-PATH precedence issue; the final implementation and retained test address it.
Scope and approval#
This is an empty-probe fallback, not a general search of every provider install directory. Provider-specific locations such as ~/.opencode/bin remain outside this bounded list. Refs #7618; it does not establish that incident's root cause or claim to close it. No merge or auto-merge is requested.
Verification#
- 84 focused tests passed, 1 skipped across desktop shell, shared shell and server startup tests. Scoped desktop/server/shared typechecks and targeted lint/format passed.
- Removing the fallback fails the retained regression; restoring prepend behavior fails its inherited-order assertion. Existing main tests reject adding fallback directories to successful probe results.
- Four actual Linux process cases at
d328c42283683b5d1461ef4b52b711b0f968607cinvoked the production desktop environment service and standalonefixPathwith real Node process spawning. Failed/empty shell probes repaired PATH and enabled a unique executable in an isolated~/.local/bin; an inherited duplicate executable still won. Successful-probe controls omitted the fallback directories. - Private HOME/state and captured processes were cleaned up. No Electron/Finder, macOS launchctl, Windows, real provider CLI or complete server-bootstrap verification is claimed.
Model and harness: Claude Opus 5.5 tests and independent review, Claude Fable 5.1 implementation, GPT-6.1 Sol independent review and process proof through T3 Code; standard service tiers.
Takeover#
Thanks @CyberStefNef for the investigation and original fix in #9232. This replacement rebuilds the same bounded fallback against current main; the description above is preserved historical context.
The original unconditional candidate list now filters existing directories; both startup paths share it and retain their existing merges. Three behavioral regressions replace the original mocked case. No parser was added.
Directory decision: platform Homebrew bin (Apple Silicon/Linuxbrew), /usr/local/bin (Intel Homebrew/manual installs), and $HOME/.local/bin (per-user installers). No provider-specific or extra bun/cargo directories.
Evidence#
Captures compare 5a969c17e7 before with 7217838f9d after. The five takeover files are identical at final merge d8646e3df4.
| Fixture | Complete standalone server + actual Electron, before → after |
|---|---|
| L1: all probes fail | CLI absent / command-v exit 1 → private H-only CLI v2.1.0 / exit 0 |
| L2: empty PATH, brew absent, local prefix a file | Only existing H appended; inherited nonexistent entry preserved |
| L3: partial metadata, no PATH | Inherited toolchain v2.1.1 wins both; only missing brew appended |
| L4: successful PATH probe | Probe v2.1.2 wins both; no fallback added |
| L5: PATH unset, all fallback dirs absent | No fallback invented; CLI absent both; existing interactive-shell defaults documented |
| H1: filesystem and caller checks | 326 real-filesystem assertions; 61 focused tests pass, 2 existing skips |
| M1 / W1 | Native macOS launchctl / Windows unverified on Linux; platform plumbing unchanged |
Complete matrix/capture ledger · 54 artifacts, including recordings and two diffs per still pair · reproduction scripts/stubs/logs · proof audit: SUFFICIENT.
Before — real Electron Settings, fixture unavailable:

After — real Electron Settings, fixture detected:

Before — terminal resolution fails:

After — terminal resolves the appended user directory:

Verification log
- Code review round 1: GPT-6.1 Sol and Claude Opus 5.5 both MERGE; no blockers. Pre-existing whitespace-only shell-PATH discrepancy noted, outside this change.
- Independent revert proof: base production bytes with new tests → 3 fail, 58 pass, 2 skip; replacement → 61 pass, 2 skip across desktop/server/shared shell files.
- Main merged by merge commit; post-merge same scoped tests 61 pass / 2 skip. Targeted lint and whitespace checks pass. Shared/server/desktop scoped typechecks pass. Final verification record.
- Proof audit inspected all 48 images, sampled six recordings, checked 20/20 runtime captures, and independently reproduced a real server capture with no behavioral delta.
- Environment: Ubuntu 24.04.5 x86_64, Node 26.12.1, Electron 44.9.3, headless-desktop/Xvfb. Version-only CLI stubs prove discovery, not authentication or agent turns.
- Isolation incident: an early helper inherited host HOME and host keyring mtime changed; contents were not inspected/restored. All desktop rows were repeated with wrapper-level private HOME/XDG. See ledger for limits of the isolation evidence. No live userdata used. Captured processes stopped.
- Native macOS/Windows remain unverified; no new launchctl API/branch behavior. No other blockers. CI pending at publication; dispatcher owns monitoring. Nothing merged.
- Models/harness: Claude Opus 5.5 tests/implementation/reviewer B; GPT-6.1 Sol lead/reviewer A/evidence/proof audit, through T3 Code (Claude Agent and Codex), standard options.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
d8646e3Macroscope's review found this PR approvable — This is a bounded shell-environment bug fix that adds existing standard CLI directories only when POSIX PATH discovery fails, while preserving inherited PATH precedence and successful probe behavior. The accompanying tests cover the fallback for desktop and server startup paths.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB −7 B (−0.1%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB −7 B (−0.6%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB −7 B (−0.1%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −7 B (−0.6%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
14b828e· PR result:d8646e3· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: takeover/pr-9232
- File: .coderabbit.config.ts
- Commit: d8646e3
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
3a51d18d-b02e-4d54-8044-916e403de644
Commits-
Reviewing files that changed from the base of the PR and between 14b828e58e746eeb0bd84073b36387014320cf59 and d8646e3df43d350fc827b07efc8f0ecc3a398d47.
Files selected for processing: 5-
apps/desktop/src/shell/DesktopShellEnvironment.test.tsapps/desktop/src/shell/DesktopShellEnvironment.tsapps/server/src/os-jank.test.tsapps/server/src/os-jank.tspackages/shared/src/shell.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
Walkthrough
-
When POSIX shell probes provide no PATH, desktop and server PATH hydration now add existing CLI directories. A shared helper checks platform-specific and common locations. Tests cover Linux and macOS cases, including nonempty probe results.
Changes: POSIX PATH fallback
Priority:Layer / File(s) Summary Discover existing CLI directories
packages/shared/src/shell.tsThe shared shell module checks platform-specific Homebrew locations, /usr/local/bin, and$HOME/.local/binwhenHOMEis set. It returns only paths that are directories.Apply PATH fallback
apps/desktop/src/shell/DesktopShellEnvironment.ts,apps/desktop/src/shell/DesktopShellEnvironment.test.ts,apps/server/src/os-jank.ts,apps/server/src/os-jank.test.tsDesktop and server PATH hydration include existing CLI directories when neither the shell nor macOS launchctlprovides a PATH. Tests cover empty and nonempty probe results and inherited PATH handling. NormalEstimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- pingdotgg/t3code#7618: The PATH fallback adds existing Homebrew and user CLI directories when macOS PATH probes return no PATH.
Suggested labels:
size:MSuggested reviewers:
t3dotgg
Merge Risk:
Minimal · up tod8646-
The fallback is bounded to failed PATH probes and preserves the inherited PATH. No actionable merge-blocking issue is established by the supplied evidence.
Pre-merge checks:
4-
Check name Status Explanation Title check The title "fix(shell): find user CLIs when POSIX PATH probes fail" matches the main change. The PR appends existing user CLI directories (Homebrew bin, /usr/local/bin, $HOME/.local/bin) to PATH only w… Description check The description follows the repository template. It has Problem, Change, Scope and approval, and Verification sections, and each contains substantive content. The Problem section states the failure mo… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Title check
-
Explanation
The title "fix(shell): find user CLIs when POSIX PATH probes fail" matches the main change. The PR appends existing user CLI directories (Homebrew bin, /usr/local/bin, $HOME/.local/bin) to PATH only when the POSIX login-shell probe and the macOS launchctl probe both return no PATH. It is a conventional commit title in plain language and is concise, so it is specific enough for a teammate scanning history.
Full details: Description check
-
Explanation
The description follows the repository template. It has Problem, Change, Scope and approval, and Verification sections, and each contains substantive content. The Problem section states the failure mode. The Change section explains the bounded fallback and the shared directory list. Scope and approval explains that the change is an empty-probe fallback, references issue
#7618without claiming to close it, and notes that no merge is requested. Verification lists focused tests, Linux process cases, and the limits of the evidence, including what was not verified (native macOS launchctl, Windows, real provider CLIs). The description is long and includes a takeover section, a large evidence table, and a verification log that go beyond the template. The Scope and approval section does not link a triaged issue or maintainer approval for the direction. The template asks for a link to the triaged bug issue or a discussion with explicit maintainer approval, or an explanation of why a small obvious fix qualifies without one. The author supplies a takeover of PR#9232and an explanation of scope, but no maintainer approval is linked.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:needs-verification
Note
Written by
claude-opus-5-5(Claude Code), reviewed bygpt-6.1-sol(Hermes), on behalf of KevinIndependent standalone-server check at d8646e3d on Linux with a zsh login shell and provider CLIs in
$HOME/.local/bin.Scenario before 91ea0e18 this PR d8646e3d Normal zsh startup Claude/Grok discovered discovered Only zsh startup delayed beyond the probe timeout; bash responds not discovered not discovered Both zsh and bash probes time out not discovered discovered This confirms the bounded empty-probe fallback, rather than a regression: when zsh times out but
/bin/bashreturns a nonempty PATH without$HOME/.local/bin, the successful-probe behavior is intentionally preserved. The PR does not claim to repair that case.Steps: launch the server from source with a private HOME,
env -i SHELL=/usr/bin/zsh PATH=/usr/bin:/bin, and CLI links in$HOME/.local/bin. Addsleep 6to the private zsh startup file; add it to.bash_profiletoo for the all-fail row. Read installation state from the sandbox's provider caches.Not checked: Electron at this head, macOS, Windows, authentication or provider turns.
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes