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

"Path" env variable gets stomped - windows #242373

Open
sharpencrag opened this issue Mar 1, 2025 · 2 comments
Open

"Path" env variable gets stomped - windows #242373

sharpencrag opened this issue Mar 1, 2025 · 2 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@sharpencrag
Copy link

Type: Bug

Windows environment variables are supposed to be case-insensitive; however, if VS Code is launched from a shell where the Path variable is PATH instead of Path (such as one created by Python), Code's environment will create a second Path variable instead of inheriting PATH from the parent shell.

Steps:

  1. Create a shell that uses PATH instead of Path. The simplest way I found is to just create a shell from python:
# make_shell.py
import os
import subprocess

command = ["cmd", "/Q", "/K"]
print("Path is now PATH")
subprocess.call(command, shell=True, env=os.environ)
> python make_shell.py
Path is now PATH
> |
  1. Launch VS Code from this new shell

  2. Check your environment variables in the terminal

cmd: set path will show both PATH and Path -- modifications to PATH made upstream are not be reflected on Path

pwsh: trying to use dir env: will throw an error. Using write-host $env:path will show Path, and any changes to PATH upstream will be lost

Same effect occurs on Insider build. I don't know when exactly this behavior changed, but pre-configured shells are a pretty big piece of some developer tools we use

VS Code version: Code 1.97.2 (e54c774, 2025-02-12T23:20:35.343Z)
OS version: Windows_NT x64 10.0.26100
Modes:

System Info
Item Value
CPUs AMD Ryzen 9 7900X3D 12-Core Processor (24 x 4400)
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
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.73GB (44.66GB free)
Process Argv
Screen Reader no
VM 0%
Extensions disabled
@Tyriar
Copy link
Member

Tyriar commented Mar 3, 2025

You said cmd shows both Path and PATH? I don't see that with your repro, do you see something different to this?

Image

modifications to PATH made upstream are not be reflected on Path

By modifying PATH inside this cmd session, it's expected to NOT be carried over to the "upstream" process (pwsh or python in my example)?

I see the same thing for pwsh. Does setting "terminal.integrated.experimental.windowsUseConptyDll": true help?

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Mar 3, 2025
@sharpencrag
Copy link
Author

sharpencrag commented Mar 3, 2025

@Tyriar -- Thanks for looking into this! I use Python to create a cmd session, then launch Code from that session -- it's only in the VS Code terminal that you can see the duplicated path variable.

This is an even easier way to demonstrate, you can launch Code directly from python without making a new interactive session:

# launch_code.py
import os
import subprocess

print("Path is now PATH")
subprocess.call(["code", "--new-window"], shell=True, env=os.environ)

Image

Tried with terminal.integrated.experimental.windowsUseConptyDll - no change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants