Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$Env:Path Incorrect in VSCode Integrated Terminal with PowerShell #189251

Closed
Tracked by #189320
adamgranthendry opened this issue Jul 30, 2023 · 4 comments
Closed
Tracked by #189320
Assignees
Labels
confirmation-pending *duplicate Issue identified as a duplicate of another issue(s) terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc.

Comments

@adamgranthendry
Copy link

adamgranthendry commented Jul 30, 2023

Type: Bug

This is a duplicate of issue #74606, which I am requesting to reopen as it was closed inconclusively and the issue is occuring for me on later versions of VSCode and Windows 10.

  1. In VSCode, execute the following in the Integrated Terminal using PowerShell Core (version 7.3.6):
$Env:Path -split ';' | ForEach-Object { $_ | Add-Content -Path 'path_vscode.txt' }
  1. In Windows 10 PowerShell Core, enter:
$Env:Path -split ';' | ForEach-Object { $_ | Add-Content -Path 'path_localmachine.txt' }

VSCode's integrated terminal does not render Path properly, while Windows PowerShell Core proper does.

VS Code version: Code 1.80.2 (2ccd690, 2023-07-27T20:40:28.909Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Xeon(R) Gold 6248R CPU @ 3.00GHz (48 x 2993)
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
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) undefined
Memory (System) 190.65GB (160.69GB free)
Process Argv --crash-reporter-id 9e9db912-c31c-4be1-8c40-4080829b5095
Screen Reader no
VM 0%
Extensions (122)
Extension Author (truncated) Version
arepl alm 2.0.5
preview-pdf ana 1.0.0
vscode-color ans 0.4.5
vscode-icontheme-nomo-dark be5 1.3.6
github-markdown-preview bie 0.3.0
markdown-checkbox bie 0.4.0
markdown-emoji bie 0.3.0
markdown-footnotes bie 0.1.1
markdown-mermaid bie 1.19.0
markdown-preview-github-styles bie 2.0.2
markdown-yaml-preamble bie 0.1.0
mermaid-markdown-syntax-highlighting bpr 1.5.2
htmltagwrap bra 0.0.9
solargraph cas 0.24.0
vscode-innosetup cho 1.9.2
path-intellisense chr 2.8.4
js-codeformer cms 2.6.1
gitignore cod 0.9.0
doxdocgen csc 1.4.0
vscode-markdownlint Dav 0.51.0
githistory don 0.6.20
vscode-html-css ecm 1.13.1
replacequotes eda 0.0.1
pre-commit-helper ela 0.4.3
RunOnSave eme 0.2.0
prettier-vscode esb 9.19.0
markdown-table-formatter fcr 2.2.4
code-runner for 0.12.0
graphviz-markdown-preview gee 0.0.8
html-snippets gey 0.2.3
vscode-github-actions git 0.25.8
gitlab-workflow Git 3.71.0
gc-excelviewer Gra 4.2.57
language-cython guy 0.0.7
markdown-table-maker hel 1.0.3
output-colorizer IBM 0.1.2
nsis idl 4.2.4
pynsist idl 0.12.2
vscode-cython-annotate ita 0.1.6
vscode-picture Jak 1.0.0
latex-workshop Jam 9.13.3
markdown-extended jeb 1.1.3
better-cpp-syntax jef 1.17.2
nbpreviewer jit 1.2.2
vscode-graphviz joa 0.0.6
columnpaste joh 0.0.8
vscode-peacock joh 4.2.2
cmake-language-support-vscode jos 0.0.9
endwise kai 1.5.1
vscode-colorize kam 0.11.1
markdown-math koe 0.1.0
tag-inserter l7s 1.4.0
python-sphinx-highlight leo 0.3.0
restructuredtext lex 189.3.0
quickstart lol 0.1.0
csvtomarkdown mar 0.0.1
vscode-3dviewer md2 1.0.0
markdown-shortcuts mdi 0.12.0
rainbow-csv mec 3.7.0
git-graph mhu 1.30.0
vscode-docker ms- 1.26.0
vscode-dotnet-runtime ms- 1.6.0
black-formatter ms- 2023.4.1
flake8 ms- 2023.6.0
isort ms- 2023.10.1
pylint ms- 2023.6.0
python ms- 2023.12.0
vscode-pylance ms- 2023.7.40
jupyter ms- 2023.6.1101941928
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.0.17
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
remote-containers ms- 0.299.0
remote-ssh ms- 0.102.0
remote-ssh-edit ms- 0.86.0
remote-wsl ms- 0.80.2
cmake-tools ms- 1.14.34
cpptools ms- 1.16.3
cpptools-extension-pack ms- 1.3.0
powershell ms- 2023.6.0
remote-explorer ms- 0.4.1
test-adapter-converter ms- 0.1.8
pytest-fixtures nic 0.3.0
autodocstring njp 0.6.1
emoji Per 1.0.1
vscode-versionlens pfl 1.5.0
material-icon-theme PKi 4.29.0
polacode pnp 0.3.4
run-on-save puc 1.5.1
ruby reb 0.28.1
vscode-xml red 0.26.1
vscode-yaml red 1.14.0
vscode-sort-json ric 1.20.0
vscode-json-validate rio 1.4.3
LiveServer rit 5.7.9
trailing-spaces sha 0.4.1
markdown-preview-enhanced shd 0.6.8
vscode-table-formatter shu 1.2.1
html5-boilerplate sid 1.1.1
vscode-dicom smi 1.4.0
code-spell-checker str 2.20.5
code-spell-checker-medical-terms str 2.0.3
code-spell-checker-scientific-terms str 0.2.0
even-better-toml tam 0.19.2
ejs-snippets Tao 0.1.0
ayu tea 1.0.5
latex-utilities tec 0.4.10
shellcheck tim 0.33.0
simple-rst tro 1.5.3
cmake twx 0.0.17
tiff-preview uco 0.0.1
vscode-choosealicense ult 0.9.2
errorlens use 3.12.0
vscode-icons vsc 12.4.0
gitblame wad 10.4.0
HTML5-extension-pack wal 1.0.0
vscode-todo-highlight way 1.0.5
extension-manager web 0.0.5
vscode-ruby win 0.28.0
markdown-pdf yza 1.4.4
markdown-all-in-one yzh 3.5.1

(3 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
py29gd2263:30792226
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
vscrpc:30673769
showlangstatbar:30737416
vsctsb:30748421
03d35959:30757346
pythonfmttext:30731395
pythoncmv:30756943
fixshowwlkth:30771522
showindicator:30785052
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonnoceb:30797650
e537b577:30795824
dsvsc013:30795093
dsvsc014cf:30797590

path_vscode.txt

path_localmachine.txt

NOTE: I've also tried Command Prompt in the Integrated Terminal and get the same incorrect value for %PATH%:

echo %Path:;=&echo.%"
@adamgranthendry
Copy link
Author

FWIW, I have many variables I need in Path. So, I use a Path2 variable in Path to overcome the Windows environment variable length limit (see below). Path2 consists of other environment variables listed in %VAR1%;%VAR2%;%VAR3% fashion.

AFAIK, Path2 is not cut off at any known length limit (e.g. 32,767) in either the expanded (C:\Users\...;C:\Program Files\...) or unexpanded (i.e. %VAR1%;%VAR2%;%VAR3%) version of the variable. Even if it were, it does not explain why Windows PowerShell Core on the desktop can read Path just fine with this setup.

Path2

C:\Users\hendra11\Code\external\commitizen\venv\Scripts
C:\Program Files\PowerShell\7
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\OpenSSH\
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
%PATH2%
...

To overcome the problem, as a temporary workaround, I removed %PATH2% from Path and instead set it to be appended to Path in my $PROFILE:

$ModifiedPath = "$env:Path;$env:Path2"
$ExpandedPath = $ExecutionContext.InvokeCommand.ExpandString($ModifiedPath)
$Env:Path = $ExpandedPath

I do not run into any issues when I use this method.

However, it would be good to know why the original problem fails in VSCode and not PowerShell on the desktop.

@Tyriar Tyriar added this to the Backlog milestone Aug 2, 2023
@meganrogge meganrogge added the terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. label Dec 4, 2023
@meganrogge
Copy link
Contributor

/duplicate #170104

@vscodenpa vscodenpa added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 18, 2023
@adam-grant-hendry
Copy link

@Tyriar @meganrogge What's the final status of this? Is it a no-fix? This appears unresolved.

@meganrogge
Copy link
Contributor

You'll eventually get the fix. See #170104 (comment)

@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmation-pending *duplicate Issue identified as a duplicate of another issue(s) terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc.
Projects
None yet
Development

No branches or pull requests

6 participants