microsoft / vscode

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

Extension variables are not expanded in integrated terminal profiles #151715

Open brawaru opened 2 years ago

brawaru commented 2 years ago

Issue Type: Bug

  1. Install rioj7.command-variable extension that provides additional variables.
  2. Create a new terminal profile and set one environment variable TEST_1 to ${extension.commandvariable.workspace.folderPosix}
  3. Set environment variable TEST_2 to ${workspaceFolder}.
  4. Launch the terminal profile and check environment variables.
Example configuration ```json { "terminal.integrated.profiles.windows": { "PowerShell": { "source": "PowerShell", "icon": "terminal-powershell" }, "Command Prompt": { "path": [ "${env:windir}\\Sysnative\\cmd.exe", "${env:windir}\\System32\\cmd.exe" ], "args": [], "icon": "terminal-cmd" }, "Git Bash": { "source": "Git Bash" }, "MINGW64": { "icon": "terminal-bash", "path": "D:\\Users\\Brawaru\\Software\\MSYS64\\usr\\bin\\bash.exe", "args": ["-l"], "env": { "MSYSTEM": "MINGW64", "SYSTEMDRIVE": "C:", "SYSTEMROOT": "C:\\Windows", "WINDIR": "C:\\Windows", "TEST_1": "${extension.commandvariable.workspace.folderPosix}", "TEST_2": "${workspaceFolder}" }, "color": "terminal.ansiCyan", "overrideName": true } } } ```

Expected behaviour: TEST_1 is expanded to current workspace path but uses POSIX separators. TEST_2 is expanded to current workspace path with system separators.

Actual behaviour: TEST_1 is not expanded and stays ${extension.commandvariable.workspace.folderPosix}, only TEST_2 is expanded to current workspace path.

VS Code version: Code 1.68.0 (4af164ea3a06f701fe3e89a2bcbb421d2026b68f, 2022-06-08T11:44:16.822Z) OS version: Windows_NT x64 10.0.19043 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-4440 CPU @ 3.10GHz (4 x 3093)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|11.95GB (3.52GB free)| |Process Argv|-n --crash-reporter-id 00f2bb44-44e6-48df-99e8-c8d250a1afbb| |Screen Reader|no| |VM|0%|
Extensions (47) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|3.0.0 vscode-zipfs|arc|3.0.0 github-markdown-preview|bie|0.3.0 markdown-checkbox|bie|0.3.2 markdown-emoji|bie|0.2.1 markdown-footnotes|bie|0.0.7 markdown-mermaid|bie|1.14.0 markdown-preview-github-styles|bie|1.0.1 markdown-yaml-preamble|bie|0.1.0 postcss|css|1.0.9 reverse-search|Dan|2.0.2 languagetool-linter|dav|0.19.0 vscode-eslint|dba|2.2.2 npm-browser|den|1.1.3 typescript-notebook|don|2.0.6 EditorConfig|Edi|0.16.4 prettier-vscode|esb|9.5.0 codespaces|Git|1.8.3 copilot-nightly|Git|1.27.6109 go|gol|0.33.1 vscode-test-explorer|hbe|2.21.1 discord-vscode|icr|5.8.0 vscode-postfix-ts|ipa|1.10.0 vscode-icon-theme|jtl|1.6.6 bash-ide-vscode|mad|1.14.0 fluent-icons|mig|0.0.17 xml-format|mik|1.1.2 jupyter|ms-|2022.5.1001601848 jupyter-renderers|ms-|1.0.8 remote-wsl|ms-|0.66.3 hexeditor|ms-|1.9.6 test-adapter-converter|ms-|0.1.6 vsliveshare|ms-|1.0.5615 vscode-yaml-sort|Pas|5.3.1 command-variable|rio|1.36.0 crates|ser|0.5.10 mdx|sil|0.1.0 datapack-language-server|SPG|3.3.32 rewrap|stk|1.16.3 code-spell-checker|str|2.2.2 code-spell-checker-russian|str|2.0.5 svelte-vscode|sve|105.17.0 even-better-toml|tam|0.14.2 shellcheck|tim|0.19.5 vscodeintellicode|Vis|1.2.21 vscode-wakatime|Wak|18.1.5 material-theme|zhu|3.13.29 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 vstes516:30244333 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242:30382549 pythontb:30283811 vsjup518:30340749 pythonvspyt551cf:30345471 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593:30376534 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 vscscmwlcmt:30465135 cppdebug:30492333 vsclangdc:30486549 ```
meganrogge commented 1 year ago

Can only repro when shell integration is enabled

meganrogge commented 1 year ago

shellLaunchConfig.env is undefined within start, defined within setupPtyProcess, then not passed to spawn

meganrogge commented 1 year ago

The profiles are passed back correctly, so this is a terminal process issue related to shell integration

Could repro just in built in profiles - not necessary to have an extension contributed one