Skip to content

Terminal profile default discovery isn't working as expected #195768

Closed

Description

Type: Bug

I have followed the instructions to install fish with homebrew on my Apple Silicon mac. Fish is the default shell in any terminal and added to /etc/shells.

When starting VS Code and opening a terminal, it chooses zsh as my default. Even with forced defaultProfile.osx settings and overridden profiles.osx settings.

Fish is also not shown in the profiles list when selecting another terminal profile.

VS Code version: Code 1.83.1 (f1b07bd, 2023-10-10T23:57:32.750Z)
OS version: Darwin arm64 23.0.0
Modes:

System Info
Item Value
CPUs Apple M1 (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.16GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (46)
Extension Author (truncated) Version
vscode-nginx-conf ahm 0.3.2
github-markdown-preview bie 0.3.0
vscode-fish bma 1.0.37
vscode-intelephense-client bme 1.9.5
vscode-eslint dba 2.4.2
gitlens eam 14.4.0
EditorConfig Edi 0.16.4
prettier-vscode esb 10.1.0
copy-relative-path-and-line-numbers ezf 0.3.1
shell-format fox 7.2.5
copilot Git 1.126.0
copilot-chat Git 0.8.0
todo-tree Gru 0.0.226
prettier-sql-vscode inf 1.6.0
vscode-just kok 2.1.0
restructuredtext lex 189.3.0
rainbow-csv mec 3.7.1
dotenv mik 1.0.1
vscode-filesize mkx 3.1.0
vscode-docker ms- 1.27.0
vscode-language-pack-de MS- 1.83.2023101109
remote-containers ms- 0.315.1
remote-ssh ms- 0.106.5
remote-ssh-edit ms- 0.86.0
remote-explorer ms- 0.4.1
remote-server ms- 1.4.3
vscode-just-php-cs-fixer muu 0.6.2
vscode-sundial muu 3.4.1
gremlins nho 0.26.0
vscode-xml red 0.26.1
vscode-yaml red 1.14.0
git-autoconfig shy 0.0.2
svg-preview Sim 2.8.3
code-spell-checker str 3.0.1
code-spell-checker-german str 2.2.1
vscode-stylelint sty 1.2.4
even-better-toml tam 0.19.2
simple-rst tro 1.5.4
sort-lines Tyr 1.11.0
vscodeintellicode Vis 1.2.30
vscode-swiftformat vkn 1.6.7
vscode-icons vsc 12.5.0
php-debug xde 1.33.0
pretty-ts-errors yoa 0.5.2
save-as-root yy0 1.7.0
markdown-all-in-one yzh 3.5.1

(1 theme extensions excluded)

Activity

  1. muuvmuuv commented on Oct 17, 2023

    @muuvmuuv
    Author
  2. muuvmuuv commented on Oct 17, 2023

    @muuvmuuv
    ContributorAuthor

    Opening code from the command line works, so it won't be any extension.

  3. meganrogge commented on Oct 17, 2023

    @meganrogge
    Collaborator

    Fish is also not shown in the profiles list when selecting another terminal profile.

    This suggests either the location of fish is not discoverable to us due to some admin privileges associated with it or it's at a non standard path.

    Where is fish located for you?

  4. added
    info-needed
    terminal-shell-fish
    on Oct 17, 2023
  5. muuvmuuv commented on Oct 17, 2023

    @muuvmuuv
    ContributorAuthor

    I have installed it with Homebrew so /opt/homebrew/bin/fish. Bin is in path and I set default shell as well as appended it to /etc/shells.

  6. meganrogge commented on Oct 17, 2023

    @meganrogge
    Collaborator

    here's where my fish is /usr/local/bin/fish and it's working there. not sure for your case - but what happens if you create a profile,

    "fish": {
    			"path":  "/opt/homebrew/bin/fish",
    			"args": [
    				"-l"
    			]
    		},
    
  7. muuvmuuv commented on Oct 18, 2023

    @muuvmuuv
    ContributorAuthor

    Funny... if I let autocomplete in settings paste the default it includes fish but if I open the command prompt it doesn't show it as selection ^^

    image
  8. muuvmuuv commented on Oct 18, 2023

    @muuvmuuv
    ContributorAuthor

    Megan Rogge (@meganrogge) this works, yes. But I don't want to specify every shell, on another machine I may prefer something else and this would force it across my synced devices.

  9. added
    feature-request
    and removed
    info-needed
    on Nov 15, 2023
  10. 9 remaining items

  11. added
    linux
    on Dec 5, 2023
  12. changed the title [-]Cannot use fish shell[/-] [+]Terminal profile default discovery isn't working as expected[/+] on Dec 5, 2023
  13. removed their assignment
    on Dec 9, 2024
  14. nkramber commented on Oct 4, 2026

    @nkramber
    Contributor

    I'd like to work on this. I reproduced it on current main (macOS, fish 4.9.3 from Homebrew at /opt/homebrew/bin/fish, VS Code launched from the Dock rather than the CLI).

    Root cause. The default fish profile has the bare path fish, and bare names are only looked up on the PATH of the resolved shell environment:

    // For non-absolute paths, check if it's available on $PATH
    if (basename(actualPath) === actualPath) {
    // The executable isn't an absolute path, try find it on the PATH
    const envPaths: string[] | undefined = shellEnv.PATH ? shellEnv.PATH.split(delimiter) : undefined;
    const executable = await findExecutable(actualPath, undefined, envPaths, undefined, fsProvider.existsFile);
    if (!executable) {
    return validateProfilePaths(profileName, defaultProfileName, potentialPaths, fsProvider, shellEnv, args);
    }
    profile.path = executable;
    profile.isFromPath = true;
    return profile;
    }

    That environment is resolved by running $SHELL as a login shell. If that fails or times out, the pty host uses {} and the lookup falls back to launchd's /usr/bin:/bin:/usr/sbin:/sbin:

    private async _resolveShellEnv(): Promise<typeof process.env> {
    if (isWindows) {
    return process.env;
    }
    try {
    return await getResolvedShellEnv(this._configurationService, this._logService, { _: [] }, process.env);
    } catch (error) {
    this._logService.error('ptyHost was unable to resolve shell environment', error);
    return {};
    }
    }

    So whenever /opt/homebrew/bin isn't on that PATH, the fish profile is dropped. It disappears from the picker, and defaultProfile.osx: "fish" can't match it, so it silently falls back to $SHELL:

    // IMPORTANT: Only allow the default profile name to find non-auto detected profiles as
    // to avoid unsafe path profiles being picked up.
    return this.availableProfiles.find(e => e.profileName === defaultProfileName && !e.isAutoDetected);

    That matches every symptom in the report:

    • zsh even with defaultProfile.osx: "fish": after chsh, apps launched from the Dock can still get the old $SHELL=/bin/zsh until you log out, and zsh's PATH lacks /opt/homebrew/bin when brew shellenv only lives in config.fish.
    • "Worked once, then failed after reopening": it works whenever shell-env resolution happens to find fish, and fails when resolution times out.
    • Launching from the CLI works: that inherits the terminal's full PATH.

    Even with a correct $SHELL=fish, a failed resolution means you get the generated fallback (fish without -l) instead of the fish profile.

    Proposed fix (terminalProfiles.ts only, plus a unit test):

    • When a profile's path is a bare name that matches the basename of the user's login shell, also try that login shell's absolute path. The PATH lookup still comes first, so nothing changes when the shell is on PATH.
    • Login shell = $SHELL (resolved env and process) plus os.userInfo().shell. The latter reads the user database, so it's current even when the GUI session's $SHELL predates chsh.
    • Add a test in terminalProfiles.test.ts showing that a fish profile not on PATH is found through the login shell, and that other bare names (e.g. tmux) aren't.
    • Not changed: profile defaults, how the default follows $SHELL when defaultProfile is unset, shell-env resolution, and Windows.

    Megan Rogge (@meganrogge) two non-blocking questions:

    1. Is the login-shell fallback the approach you'd prefer, or would you rather also probe the usual Homebrew dirs (/opt/homebrew/bin, /usr/local/bin) so Homebrew tmux/pwsh are found too?
    2. A profile found this way shows its full path in the picker (like absolute-path profiles do) instead of fish. OK?
  15. added
    unreleased
    on Nov 5, 2026
  16. added a commit that references this issue on Nov 5, 2026
    a360507
  17. added
    insiders-released
    and removed
    unreleased
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bughelp wantedinsiders-releasedlinuxmacosterminal-profilesverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions