Skip to content

fix(desktop): find user-installed CLIs when shell probing fails - #9232

Open
CyberStefNef wants to merge 1 commit into
pingdotgg:mainfrom
CyberStefNef:fix/posix-cli-path-fallback
Open

fix(desktop): find user-installed CLIs when shell probing fails#9232
CyberStefNef wants to merge 1 commit into
pingdotgg:mainfrom
CyberStefNef:fix/posix-cli-path-fallback

Conversation

@CyberStefNef

@CyberStefNef CyberStefNef commented Sep 2, 2026

Copy link
Copy Markdown

What Changed

resolveKnownPosixCliDirs in packages/shared/src/shell.ts returns the standard CLI directories for macOS and Linux, beside the existing resolveKnownWindowsCliDirs. Both POSIX PATH hydration paths now fall back to it when neither the login shell nor launchctl getenv PATH answers: installPosixEnvironment in apps/desktop/src/shell/DesktopShellEnvironment.ts and hydratePosixPath in apps/server/src/os-jank.ts.

The fallback is last in the chain, so a shell that did answer still decides the order. Directories are not checked for existence, matching resolveKnownWindowsCliDirs.

Why

A Finder launch starts the app with /usr/bin:/bin:/usr/sbin:/sbin. Both hydration paths repair that from the login shell, but the probe collapses failures and timeouts into an empty result, so a profile slower than the 5s timeout leaves PATH untouched. launchctl getenv PATH is unset on recent macOS, so the second probe returns nothing either. Every bare-name spawn then fails with ENOENT: #7618 counted 1246 failed gh spawns and zero successes over 14 hours, with gh auth status never running.

#1799 built this chain and added the launchctl probe as its last step. This adds the next step, for machines where that probe is also empty. Raising the timeout does not help, since the probe fails for reasons unrelated to how long it is given.

Both Windows paths already end in resolveKnownWindowsCliDirs. POSIX ended in nothing.

Closes #7618

Verification

  • vp test run apps/desktop/src/shell/DesktopShellEnvironment.test.ts packages/shared/src/shell.test.ts apps/server/src/os-jank.test.ts: 54 passed.
  • Typecheck for @t3tools/desktop, @t3tools/shared, and the server.
  • vp lint on the five changed files with --report-unused-disable-directives.
  • git diff --check: clean.
  • Seven added tests: the macOS and Linux fallbacks in both hydration paths, and guards that the known directories stay out of the merge when either probe answers. Reverting the source change fails the fallback tests and leaves the guards passing.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Screenshots are not applicable because nothing visual changed
  • A video is not applicable because no motion or interaction changed

Note

Medium Risk
Changes process PATH for all POSIX desktop and server startups when probes fail; behavior shifts from minimal system PATH to hard-coded install locations, which could affect spawn resolution in edge environments but addresses widespread CLI spawn failures.

Overview
When login-shell and (on macOS) launchctl PATH probes return nothing—common for GUI/Finder launches with a minimal PATH—POSIX hydration no longer leaves only /usr/bin:/bin:….

Shared: Adds resolveKnownPosixCliDirs (macOS Homebrew//usr/local/~/.local/bin, Linux Linuxbrew//usr/local/~/.local/bin; skips ~/.local if HOME is blank), mirroring the existing Windows known-CLI helper and without checking that directories exist.

Desktop & server: installPosixEnvironment and hydratePosixPath use that list as the last preferred PATH segment before merging with the inherited PATH. Any PATH from the login shell or launchctl still wins and does not inject these defaults.

New unit tests cover macOS/Linux fallback merges and assert the known dirs are not added when either probe succeeds.

Reviewed by Cursor Bugbot for commit 10ead92. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add known CLI directory fallback to hydratePosixPath and installPosixEnvironment

  • Adds shared resolveKnownPosixCliDirs resolver that returns platform-specific CLI install directories (Homebrew on macOS, Linuxbrew on Linux, plus system-local and HOME-local bin).
  • Both desktop POSIX environment installation and server PATH hydration now prepend these known directories as a final fallback when neither the login shell nor launchctl produces a PATH.
  • A PATH from the login shell or launchctl remains preferred and is used directly without adding the fallback directories.
  • Risk: any caller relying on an empty PATH when probes fail will now receive a non-empty PATH composed of known CLI directories; the HOME-local entry is omitted when HOME is blank or unset.

Macroscope summarized 10ead92.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Sep 2, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 5d8d654

Macroscope's review found this PR approvable — This focused bug fix adds known POSIX CLI directories only when existing shell and launchctl PATH discovery fails, leaving successful probe paths unchanged. The implementation is small, isolated, and tested, with no schema, deployment, security-sensitive, or static-analysis configuration changes.

You can add or adjust custom eligibility rules. Learn more.

POSIX PATH hydration had no fallback when both the login-shell and
launchctl probes returned nothing, so a slow shell profile left the
desktop app and the server on the bare Finder PATH and every bare-name
CLI spawn failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: macOS Source Control reports installed Homebrew gh as unavailable

1 participant