Repository navigation
Find terminal profiles at the login shell path when it's not on PATH - #339556
Merged
Megan Rogge (meganrogge) merged 3 commits intoNov 5, 2026
Merged
Megan Rogge (meganrogge) merged 3 commits into
Megan Rogge (meganrogge) merged 3 commits into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Login-shell candidates can override the configured ordering of profile path fallbacks.
Review effort: Balanced
Findings: 1
What changed in this PR
Improves Unix terminal profile discovery when a login shell is absent from PATH.
Changes:
- Adds absolute login-shell paths as profile fallbacks.
- Preserves profile metadata during fallback validation.
- Adds Unix regression coverage.
| File | Description |
|---|---|
terminalProfiles.ts |
Adds login-shell discovery and fallback validation. |
terminalProfiles.test.ts |
Tests bare-name profile resolution outside PATH. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Megan Rogge (meganrogge)
approved these changes
Nov 3, 2026
Megan Rogge (meganrogge)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the fix!
Megan Rogge (meganrogge)
enabled auto-merge (squash)
November 3, 2026 19:30
roblourens
approved these changes
Nov 3, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 3, 2026
Megan Rogge (meganrogge)
merged commit Nov 5, 2026
a360507
into
microsoft:main
63 of 82 checks passed
| function getLoginShells(shellEnv: typeof process.env): string[] { | ||
| const shells = [shellEnv.SHELL, process.env.SHELL]; | ||
| try { | ||
| shells.push(userInfo().shell ?? undefined); |
Comment on lines
+248
to
+249
| const bareNames = paths.filter((e): e is string => isString(e) && basename(e) === e); | ||
| paths.push(...bareNames.flatMap(name => (loginShells ?? []).filter(e => basename(e) === name))); |
CAPITAL8 (Capital-8)
pushed a commit
to Capital-8/vscode
that referenced
this pull request
Nov 10, 2026
Bound the account database lookup and preserve configured path fallback order. Follow up to microsoft#339556 and microsoft#195768. Co-authored-by: Copilot <[email protected]>
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.


Fixes #195768
On macOS and Linux, a terminal profile with a bare path (the default
fish,zsh,bash, … entries) is only looked up on the PATH of the resolved shell environment. That environment comes from running$SHELLas a login shell, and when resolution fails or times out, the lookup falls back to the pty host's own PATH. For VS Code launched from the macOS Dock, that's launchd's/usr/bin:/bin:/usr/sbin:/sbin. So a Homebrew fish at/opt/homebrew/bin/fishthat is the user's login shell can disappear from the profile list. An explicitterminal.integrated.defaultProfile.osx: "fish"then can't match it and silently falls back to$SHELL, which in a Dock-launched app can still be the old shell afterchsh.Approach described on the issue: #195768 (comment)
Change
src/vs/platform/terminal/node/terminalProfiles.ts:getValidatedProfile(Unix only): when a profile's path is a bare name equal to the basename of the user's login shell, that login shell's absolute path is added as an extra candidate after the PATH lookup. It's validated like any absolute path (exists check), so nothing changes when the shell is on PATH, and other bare names (e.g.tmux) are unaffected.getLoginShells:$SHELLfrom the resolved environment and from the process, plusos.userInfo().shell, which reads the user database and so is current even when the session's$SHELLpredateschsh. Only absolute paths are kept, de-duplicated. It's passed down throughdetectAvailableUnixProfiles→transformToTerminalProfiles→getValidatedProfile.detectAvailableProfilestakes an optionaltestLoginShellsfor tests, like the existingtestPwshSourcePaths.validateProfilePaths(all platforms): when a bare name isn't found on PATH, the recursive call now passesenv,overrideNameandisAutoDetectedlike the other two recursive calls do. Previously they were dropped, which would have stripped them from a profile resolved through the login-shell candidate. This also affects any profile with a path array whose bare first entry isn't on PATH (e.g.["pwsh.exe", "C:\\tools\\pwsh.exe"]on Windows): itsenvandoverrideNameare now kept instead of silently dropped. The built-in default profiles set neither.A profile found this way shows its full path in the profile picker (
fish, /opt/homebrew/bin/fish -l), like other absolute-path profiles. Unchanged: profile defaults, how the default follows$SHELLwhendefaultProfileis unset, and shell environment resolution.How to test
macOS with fish from Homebrew (
brew install fish), Code - OSS launched the way the Dock does (noVSCODE_CLI, launchd PATH):with
/tmp/xdg-nobrew/fish/config.fishcontainingset -gx PATH /usr/bin /bin /usr/sbin /sbin, so the resolved shell env has no/opt/homebrew/bin, and"terminal.integrated.defaultProfile.osx": "fish"in the profile's settings.-l(generated fallback profile), and Terminal: Select Default Profile has nofishentry. After:fish -lfrom thefishprofile, and the picker listsfish, /opt/homebrew/bin/fish -l.SHELL=/bin/zshin the command above while the account's login shell is fish (chsh -s /opt/homebrew/bin/fish), i.e. a stale$SHELL, and a zsh config whose PATH lacks/opt/homebrew/bin. Before: zsh, silently. After:fish -l.fish, fish -land fish starts as before.Results from my runs (dev build, Dock-style launch,
defaultProfile.osx: "fish"):$SHELL=fish, shell env resolution times outfish(no-l), fish missing from pickerfish -l$SHELL=fish, resolved PATH without Homebrewfish -l, fish in picker$SHELL=zsh, resolution times outfish -l$SHELL=zsh, zsh PATH without Homebrewfish -lfish -lAutomated:
src/vs/workbench/contrib/terminal/test/node/terminalProfiles.test.ts›should find a bare-name profile at the login shell path when it is not on PATH(fails without this change; it also fails if only thevalidateProfilePathschange is reverted). All terminal unit tests pass locally. Linux uses the same code path, verified only through the unit test. On Windows the only change is thevalidateProfilePathsfix above. The login-shell candidate is Unix only.