microsoft / vscode

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

In 2nd VSCode run, environment variables are no longer inherited from the current process #212964

Closed JHag6694 closed 1 week ago

JHag6694 commented 2 weeks ago

Does this issue occur when all extensions are disabled: Yes

Steps to Reproduce:

  1. Open a command prompt
  2. Start a 1st VSCode with code.exe
  3. Add a new environment variable : set MYVAR="1"
  4. Start a 2d VSCode with code.exe
  5. In Terminal panel windows, you can check that environment variables MYVAR does not exist

Same problem if you change a value. Environment is inherited/shared from 1st VScode run. Behavior has changed between 1.85- and 1.86+ Not sure if it is deliberate (no mention found in Release Notes) or a bug.

VSCodeTriageBot commented 2 weeks ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.89.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

meganrogge commented 2 weeks ago

I believe this is already fixed, can you see if you can reproduce in the Insiders build? /label info-needed

JHag6694 commented 2 weeks ago

I believe this is already fixed, can you see if you can reproduce in the Insiders build? /label info-needed

Tested and reproduced today with Insiders build

meganrogge commented 1 week ago

@bpasero or @deepak1556 do you know why this would've changed?

bpasero commented 1 week ago

In your batch file, try passing --preserve-env to VS Code. Refs:

https://github.com/microsoft/vscode/blob/7215958b3c57945b49d3b70afdba7fb47319ca85/src/vs/platform/launch/electron-main/launchMainService.ts#L122-L133