-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
wt.exe
ignores environment of parent (calling) process
#11094
Comments
On second thought, I now realize why this behaviour is by design. Each new window/tab/pane fetches the environment block from the system itself (the registry, perhaps?). If it were to inherit it from the parent, it won't have up to date values. Is this reasoning correct? Please close this if it is 😅. |
It's... complicated. @rashil2000, you're right that it keeps the environment up to date. However, it should try to merge the environment if possible. 😄 |
I'm curious to know what it'll do in case of "merge conflicts" 😅 Like if I set SOME_VAR in both the calling process and in the Start Menu->Environment Variables dialog. |
I'd be worried that automated merging could create an inconsistent state, with conflicting variables or values. I see no reason to deviate from Explorer's behavior in this regard. To that end, Terminal would listen for |
I second that thought -- it should not try to merge environment variables. Merging will likely end badly - as there are complex scenarios, and it is unlikely that users would foresee this and will get surprised. Maybe a cmdline option to control if it should listen for WM_SETTINGCHANGE? So if users really want the terminal to only inherit their env vars from the parent process they can get it. |
Hey all! Thanks for the discussion here. We've decided to make the call: We aren't going to merge environment variables, and applications spawned inside a Terminal will always have an "up to date" view of the user's environment. How we achieve this is up in the air (whether we can rely on The best thing we can do is always give you a consistent new environment -- trying to guess which one you wanted and what you wanted from that one will result in us accidentally being wrong, rather than being consistent. Thanks! |
Please follow #1125 for future updates about this! |
Windows Terminal version (or Windows build number)
10.0.19043.1165 1.10.1933.0
Other Software
No response
Steps to reproduce
set SOME_VAR=some_value
conhost
. In the newly launched window, check for SOME_VAR variable. It'll be set. Close this new window.wt
. In the newly launched window, check for SOME_VAR variable. It'll be absent.Expected Behavior
I expect any new processes launched from the original shell to inherit the parent's environment.
Actual Behavior
The
wt.exe
executable is probably the first ever process I have seen (in my limited experience) that ignores the parent's environment. All other processes (including conhost) inherit the environment.Note that I searched for similar issues, and found numerous ones pertaining to refreshing the environment variables automatically for new tabs/panes. This is not that.
There is actually an issue - #4259 - which slightly mentions this sort of thing, but again the issue title there is regarding panes and not the process in general.
The text was updated successfully, but these errors were encountered: