Duplicate WT_SESSION and WT_PROFILE_ID in WSLENV env var #9931

Closed
opened 2026-01-31 02:07:47 +00:00 by claunia · 6 comments
Owner

Originally created by @abarani on GitHub (Jul 30, 2020).

Environment

Windows build number: 10.0.19041.388
Windows Terminal version (if applicable): 1.1.2021.0

Steps to reproduce

  • Open Windows Terminal
  • setx WSLENV "${env:WSLENV}:TEST/p"
  • Close and reopen Windows Terminal
  • echo $env:WSLENV

Expected behavior

WT_SESSION:WT_PROFILE_ID:TEST/p

Actual behavior

WT_SESSION:WT_SESSION::WT_PROFILE_ID:TEST/p:WT_PROFILE_ID

I think the right thing to do here is to split WSLENV by : and check those vars are already set instead of just simply prepending and appending a string.

Probable related PRs:

Originally created by @abarani on GitHub (Jul 30, 2020). # Environment ```none Windows build number: 10.0.19041.388 Windows Terminal version (if applicable): 1.1.2021.0 ``` # Steps to reproduce - Open Windows Terminal - `setx WSLENV "${env:WSLENV}:TEST/p"` - Close and reopen Windows Terminal - `echo $env:WSLENV` # Expected behavior WT_SESSION:WT_PROFILE_ID:TEST/p # Actual behavior WT_SESSION:WT_SESSION::WT_PROFILE_ID:TEST/p:WT_PROFILE_ID --- I think the right thing to do here is to split `WSLENV` by `:` and check those vars are already set instead of just simply prepending and appending a string. Probable related PRs: - https://github.com/microsoft/terminal/pull/4157 - https://github.com/microsoft/terminal/pull/4852
Author
Owner

@DHowett commented on GitHub (Jul 30, 2020):

Good catch! There's an inherent danger in using setx to immortalize the contents of an environment variable at runtime, because even TEST/p is going to get duplicated if you keep doing that ...

I'm not sure it harms anything other than aesthetics, but I'll tag this one up as a code health issue.

@DHowett commented on GitHub (Jul 30, 2020): Good catch! There's an inherent danger in using `setx` to immortalize the contents of an environment variable at runtime, because even `TEST/p` is going to get duplicated if you keep doing that ... I'm not sure it harms anything other than aesthetics, but I'll tag this one up as a code health issue.
Author
Owner

@huiyooumich commented on GitHub (Mar 21, 2022):

Hello, this is my first time making a contribution here! I would like to work on this.

@huiyooumich commented on GitHub (Mar 21, 2022): Hello, this is my first time making a contribution here! I would like to work on this.
Author
Owner

@zadjii-msft commented on GitHub (Mar 21, 2022):

@huiyooumich awesome, go for it! I don't think you'd be stepping on anyone's toes here. I'm pretty sure ConptyConnection::_LaunchAttachedClient in ConptyConnection.cpp is where we're setting up the environment variables. Let us know if you need any pointers ☺️

@zadjii-msft commented on GitHub (Mar 21, 2022): @huiyooumich awesome, go for it! I don't think you'd be stepping on anyone's toes here. I'm pretty sure `ConptyConnection::_LaunchAttachedClient` in `ConptyConnection.cpp` is where we're setting up the environment variables. Let us know if you need any pointers ☺️
Author
Owner

@huiyooumich commented on GitHub (Jun 30, 2022):

Unfortunately, I have stopped working on this due to lack of time. But thank you so much for the advice and I hope if anyone else wants to give this a go they'll find it a lot easier.

@huiyooumich commented on GitHub (Jun 30, 2022): Unfortunately, I have stopped working on this due to lack of time. But thank you so much for the advice and I hope if anyone else wants to give this a go they'll find it a lot easier.
Author
Owner

@Weichenleeeee123 commented on GitHub (Jul 22, 2025):

Hi , I'm a newcomer here and i would like to take this task if there's no one had taken it.

@Weichenleeeee123 commented on GitHub (Jul 22, 2025): Hi , I'm a newcomer here and i would like to take this task if there's no one had taken it.
Author
Owner

@DHowett commented on GitHub (Jul 28, 2025):

@Weichenleeeee123 thanks for working on this bug!

@DHowett commented on GitHub (Jul 28, 2025): @Weichenleeeee123 thanks for working on this bug!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9931