fix(desktop): find user-installed CLIs when shell probing fails - #9232
Open
CyberStefNef wants to merge 1 commit into
Open
fix(desktop): find user-installed CLIs when shell probing fails#9232CyberStefNef wants to merge 1 commit into
CyberStefNef wants to merge 1 commit into
Conversation
Contributor
ApprovabilityVerdict: Approved at 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.
CyberStefNef
force-pushed
the
fix/posix-cli-path-fallback
branch
from
September 3, 2026 05:28
7bd0ba4 to
10ead92
Compare
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.
What Changed
resolveKnownPosixCliDirsinpackages/shared/src/shell.tsreturns the standard CLI directories for macOS and Linux, beside the existingresolveKnownWindowsCliDirs. Both POSIX PATH hydration paths now fall back to it when neither the login shell norlaunchctl getenv PATHanswers:installPosixEnvironmentinapps/desktop/src/shell/DesktopShellEnvironment.tsandhydratePosixPathinapps/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 PATHis unset on recent macOS, so the second probe returns nothing either. Every bare-name spawn then fails with ENOENT: #7618 counted 1246 failedghspawns and zero successes over 14 hours, withgh auth statusnever running.#1799 built this chain and added the
launchctlprobe 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.@t3tools/desktop,@t3tools/shared, and the server.vp linton the five changed files with--report-unused-disable-directives.git diff --check: clean.Checklist
Note
Medium Risk
Changes process
PATHfor 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)
launchctlPATH 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~/.localifHOMEis blank), mirroring the existing Windows known-CLI helper and without checking that directories exist.Desktop & server:
installPosixEnvironmentandhydratePosixPathuse that list as the last preferred PATH segment before merging with the inherited PATH. Any PATH from the login shell orlaunchctlstill 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
hydratePosixPathandinstallPosixEnvironmentresolveKnownPosixCliDirsresolver that returns platform-specific CLI install directories (Homebrew on macOS, Linuxbrew on Linux, plus system-local and HOME-localbin).launchctlproduces a PATH.launchctlremains preferred and is used directly without adding the fallback directories.HOMEis blank or unset.Macroscope summarized 10ead92.