New tab of PowerShell Core in Terminal gets outdated environment variables #6408

Closed
opened 2026-01-31 00:37:47 +00:00 by claunia · 2 comments
Owner

Originally created by @ThoAppelsin on GitHub (Feb 13, 2020).

Environment

Windows build number: 10.0.18362.0
Windows Terminal version (if applicable): 0.8.10261.0

PowerShell Core 6.2.3

Steps to reproduce

  1. Open Windows Terminal and a tab of PowerShell Core.
  2. Create a new environment variable called SOME_VARIABLE with the value some value. Two example ways of doing this is:
    • Via the System Properties > Environment Variables > User variables for [username] > New..., and so on.
    • Via the command [System.Environment]::SetEnvironmentVariable('SOME_VARIABLE', "some value", [System.EnvironmentVariableTarget]::User)
  3. Open a new tab of PowerShell Core.
  4. Type $env:SOME_VARIABLE.

Expected behavior

I expect to have that variable set to the value "some value".

Actual behavior

The variable is not set. If one opens a new window instead at step 4, there the variable is actually set to the value "some value", as expected.

Comments

It seems that every window of Windows Terminal obtains a copy of the environment variables when it is launched, and each tab inherits from the window's variables. If only the new tabs were consequently initializing faster... They unfortunately still do take their time, 1.5 seconds, to load my personal and system profiles.

I was relying on the environment variables to bookmark directories across terminals. This breaks my workflow. I can instead use a file as a workaround.

Originally created by @ThoAppelsin on GitHub (Feb 13, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18362.0 Windows Terminal version (if applicable): 0.8.10261.0 PowerShell Core 6.2.3 ``` # Steps to reproduce 1. Open Windows Terminal and a tab of PowerShell Core. 1. Create a new environment variable called `SOME_VARIABLE` with the value `some value`. Two example ways of doing this is: - Via the System Properties > Environment Variables > User variables for [username] > New..., and so on. - Via the command `[System.Environment]::SetEnvironmentVariable('SOME_VARIABLE', "some value", [System.EnvironmentVariableTarget]::User)` 1. Open a new **tab** of PowerShell Core. 1. Type `$env:SOME_VARIABLE`. # Expected behavior I expect to have that variable set to the value "some value". # Actual behavior The variable is not set. If one opens a new **window** instead at step 4, there the variable is actually set to the value "some value", as expected. # Comments It seems that every window of Windows Terminal obtains a copy of the environment variables when it is launched, and each tab inherits from the window's variables. If only the new tabs were consequently initializing faster... They unfortunately still do take their time, 1.5 seconds, to load my personal and system profiles. I was relying on the environment variables to bookmark directories across terminals. This breaks my workflow. I can instead use a file as a workaround.
claunia added the Resolution-Duplicate label 2026-01-31 00:37:47 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Feb 13, 2020):

/dup #4545 #1125, thanks!

@DHowett-MSFT commented on GitHub (Feb 13, 2020): /dup #4545 #1125, thanks!
Author
Owner

@ghost commented on GitHub (Feb 13, 2020):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Feb 13, 2020): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6408