microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.45k stars 29.35k forks source link

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

Open muuvmuuv opened 1 year ago

muuvmuuv commented 1 year ago

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 (f1b07bd25dfad64b0167beb15359ae573aecd2cc, 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)
muuvmuuv commented 1 year ago

Just tried again, and it worked once and after quitting and reopening it failed again, finding fish as my default.

muuvmuuv commented 1 year ago

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

meganrogge commented 1 year ago

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?

muuvmuuv commented 1 year ago

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.

meganrogge commented 1 year ago

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"
            ]
        },
muuvmuuv commented 1 year ago

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
muuvmuuv commented 1 year ago

@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.

vscodenpa commented 1 year ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Tyriar commented 11 months ago

Fish shell discovery seems to be working fine for me, pulling in the default does indeed look like it's likely broken. I didn't test too extensively as I was having problems setting my system default shell. Open to contributors who want to validate they can reproduce the bug and then fix/verify it.

The profile resolution works by finding fish on the $PATH if it exists via the default config value:

https://github.com/microsoft/vscode/blob/d70a46b6bd65aade0248f900a6e67a85f1c2cde2/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts#L243-L246

The default value for the terminal.integrated.defaultProfile.osx setting is null:

https://github.com/microsoft/vscode/blob/d70a46b6bd65aade0248f900a6e67a85f1c2cde2/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts#L408

This ends up being transferred to the pty host and evaluated here where it will be a string profile name or falsy:

https://github.com/microsoft/vscode/blob/d70a46b6bd65aade0248f900a6e67a85f1c2cde2/src/vs/platform/terminal/node/terminalProfiles.ts#L61

This is used to set whether a profile is the default here:

https://github.com/microsoft/vscode/blob/d70a46b6bd65aade0248f900a6e67a85f1c2cde2/src/vs/platform/terminal/node/terminalProfiles.ts#L472

Looks like this should fall back to checking env.SHELL vs profile.path or basename(profile.path)