Uh oh!
There was an error while loading. Please reload this page.
fix(desktop): find user-installed CLIs when shell probing fails - #9232
Open
CyberStefNef wants to merge 2 commits into
Open
fix(desktop): find user-installed CLIs when shell probing fails#9232CyberStefNef wants to merge 2 commits into
CyberStefNef wants to merge 2 commits into
Conversation
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.
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. |
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 freeto 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 desktop and server POSIX startups when probes fail; behavior is intentional but affects every child-process spawn in those scenarios.Overview
Adds shared
resolveKnownPosixCliDirs(Homebrew/Linuxbrew,/usr/local/bin, and$HOME/.local/binwhenHOMEis set) as the last POSIX PATH fallback, mirroring the existing Windows known-CLI list.Desktop
installPosixEnvironmentand serverhydratePosixPathnow use it when the login-shell probe and (on macOS)launchctl getenv PATHboth return nothing—e.g. GUI/Finder launches with only/usr/bin:/bin:…and slow or empty shell probes. A PATH from either probe is unchanged; the hardcoded dirs are not mixed in when a probe succeeds.New tests cover macOS/Linux fallback merges, and guards that known dirs stay out when shell or launchctl answers.
Reviewed by Cursor Bugbot for commit 7bd0ba4. 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 7bd0ba4.