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

Environment variables are not expanded #170104

Closed
anthonyvdotbe opened this issue Dec 27, 2022 · 8 comments
Closed

Environment variables are not expanded #170104

anthonyvdotbe opened this issue Dec 27, 2022 · 8 comments
Assignees
Labels
confirmation-pending info-needed Issue requires more information from poster terminal-external windows VS Code on Windows issues
Milestone

Comments

@anthonyvdotbe
Copy link

Type: Bug

With 2 environment variables as follows:

JAVA_HOME = %JAVA_HOME_DEFAULT%
JAVA_HOME_DEFAULT=C:\path\to\directory

and these VS Code settings:

{
    "terminal.explorerKind": "external",
    "terminal.external.windowsExec": "wt"
}

then when I do Open in Windows Terminal and type echo $Env:JAVA_HOME (with PowerShell 7.3.1 being my default profile in Windows Terminal), the output is %JAVA_HOME_DEFAULT%.

However, when I open Windows Terminal outside of VS Code and type the same, the output is correct: C:\path\to\directory.

VS Code version: Code - Insiders 1.75.0-insider (6ed4d43, 2022-12-23T05:21:57.802Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: Yes

Extensions: none

A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
vsc_aacf:30263846
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30404738
cppdebug:30492333
vsclangdf:30492506
c4g48928:30535728
dsvsc012:30540252
pynewext54:30618038
pylantcb52:30590116
pyindex848:30611229
nodejswelcome1:30587009
pyind779:30611226
pythonsymbol12cf:30622697
fim-prod:30623723

@meganrogge meganrogge added bug Issue identified by VS Code Team member as probable bug confirmation-pending terminal-external labels Jan 6, 2023
@Tyriar
Copy link
Member

Tyriar commented Jan 6, 2023

When I set environment variables that equal others, they get automatically resolved via the environment variable window. I set TEST_VAR1 to %TEST_VAR2% and this is what happened:

image

How are you setting JAVA_HOME in this case?

@Tyriar Tyriar added info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug confirmation-pending labels Jan 6, 2023
@anthonyvdotbe
Copy link
Author

In PowerShell 7.3.1 I do:

[Environment]::SetEnvironmentVariable('TEST_VAR1', 'foo', 'User')
[Environment]::SetEnvironmentVariable('TEST_VAR2', '%TEST_VAR1%', 'User')

Then in the environment variable window the result is:

image

@anthonyvdotbe
Copy link
Author

@Tyriar the info-needed label can be removed (or further questions asked if my response was unclear)

@meganrogge meganrogge added confirmation-pending and removed info-needed Issue requires more information from poster labels Feb 23, 2023
@meganrogge meganrogge added this to the Backlog milestone Feb 23, 2023
@Tyriar
Copy link
Member

Tyriar commented Feb 28, 2023

This is working fine for me, whether I run the regular open external command or right click a folder and open in WT:

image

@Tyriar Tyriar added info-needed Issue requires more information from poster windows VS Code on Windows issues labels Feb 28, 2023
@anthonyvdotbe
Copy link
Author

@Tyriar Here's what I did in a stock Windows Sandbox:

[Environment]::SetEnvironmentVariable('TEST_VAR1', 'foo', 'User')
[Environment]::SetEnvironmentVariable('TEST_VAR2', '%TEST_VAR1%', 'User')
  • open VS Code and change the configuration:
{
    "terminal.explorerKind": "external",
    "terminal.external.windowsExec": "wt"
}
  • in VS Code, Open Folder -> Downloads, right-click the VS Code .zip I downloaded earlier, choose Open in Windows Terminal
  • in the opened Terminal, run:
echo $Env:TEST_VAR2

which gives: %TEST_VAR1%

@anthonyvdotbe anthonyvdotbe changed the title Environment variables are not expanded with external terminal Environment variables are not expanded Mar 31, 2023
@anthonyvdotbe
Copy link
Author

Just found out the exact same thing happens in VS Code's terminal. To reproduce I downloaded the current insiders version (1.78.0-insider f31dffc), opened an internal terminal, typed echo $Env:JAVA_HOME and got %JAVA_HOME_DEFAULT% as output.

@Tyriar have you already tried with the reproduction steps in my previous comment? And is there anything else I can do to move this issue forward?

@anthonyvdotbe
Copy link
Author

When using an external terminal, this is due to an issue in Windows Terminal.
However, the same issue occurs when using an internal terminal.

@Tyriar
Copy link
Member

Tyriar commented May 17, 2023

Looks like the upstream problem is fixed. It will come through to us eventually, it's shipped with Windows though so it's quite a slow process.

@Tyriar Tyriar closed this as completed May 17, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmation-pending info-needed Issue requires more information from poster terminal-external windows VS Code on Windows issues
Projects
None yet
Development

No branches or pull requests

3 participants