Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shell): find user CLIs when POSIX PATH probes fail #24632

Openjuliusmarmingewants to merge 4 commits intomain fromtakeover/pr-9232opened View on GitHub

juliusmarmingecommented

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 d328c42283683b5d1461ef4b52b711b0f968607c invoked the production desktop environment service and standalone fixPath with 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.

FixtureComplete standalone server + actual Electron, before → after
L1: all probes failCLI absent / command-v exit 1 → private H-only CLI v2.1.0 / exit 0
L2: empty PATH, brew absent, local prefix a fileOnly existing H appended; inherited nonexistent entry preserved
L3: partial metadata, no PATHInherited toolchain v2.1.1 wins both; only missing brew appended
L4: successful PATH probeProbe v2.1.2 wins both; no fallback added
L5: PATH unset, all fallback dirs absentNo fallback invented; CLI absent both; existing interactive-shell defaults documented
H1: filesystem and caller checks326 real-filesystem assertions; 61 focused tests pass, 2 existing skips
M1 / W1Native 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: Before: fixture CLI unavailable

After — real Electron Settings, fixture detected: After: fixture CLI detected

Before — terminal resolution fails: Before: command resolution fails

After — terminal resolves the appended user directory: After: command resolves user CLI

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. Approvability

      Verdict: Approved at d8646e3

      Macroscope'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).
    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 14b828e · PR result: d8646e3 · Source CI: success

      Scenario 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.

    3. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • apps/desktop/src/shell/DesktopShellEnvironment.ts
      • apps/server/src/os-jank.test.ts
      • apps/server/src/os-jank.ts
      • packages/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

      Layer / File(s)Summary
      Discover existing CLI directories
      packages/shared/src/shell.ts
      The shared shell module checks platform-specific Homebrew locations, /usr/local/bin, and $HOME/.local/bin when HOME is 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.ts
      Desktop and server PATH hydration include existing CLI directories when neither the shell nor macOS launchctl provides a PATH. Tests cover empty and nonempty probe results and inherited PATH handling.
      Priority: Normal

      Estimated 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:M

      Suggested reviewers: t3dotgg

      Merge Risk: Minimal · up to d8646

      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: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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 #7618 without 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 #9232 and 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
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsbugfix

    5. juliusmarminge added labelspr:needs-verification

    6. Note

      Written by claude-opus-5-5 (Claude Code), reviewed by gpt-6.1-sol (Hermes), on behalf of Kevin

      Independent standalone-server check at d8646e3d on Linux with a zsh login shell and provider CLIs in $HOME/.local/bin.

      Scenariobefore 91ea0e18this PR d8646e3d
      Normal zsh startupClaude/Grok discovereddiscovered
      Only zsh startup delayed beyond the probe timeout; bash respondsnot discoverednot discovered
      Both zsh and bash probes time outnot discovereddiscovered

      This confirms the bounded empty-probe fallback, rather than a regression: when zsh times out but /bin/bash returns 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. Add sleep 6 to the private zsh startup file; add it to .bash_profile too 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.