Profile with custom environment for PATH causes WSL to lose standard PATH values #23455

Closed
opened 2026-01-31 08:42:45 +00:00 by claunia · 1 comment
Owner

Originally created by @reduckted on GitHub (Jul 20, 2025).

Windows Terminal version

1.22.11141.0

Windows build number

10.0.19045.0

Other Software

WSL: 2.5.9.0
Ubuntu: 22.04.3 LTS

Steps to reproduce

Install WSL and a distro (I'm using Ubuntu, but it doesn't seem to matter which one you use).

Use the standard profile for cmd, as well as a custom profile that prepends to the PATH envrionment variable:

{
    "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
    "name": "cmd"
},
{
    "guid": "{324dd25d-8c2a-4ffb-a877-92b93f2bb404}",
    "name": "cmd with custom PATH",
    "commandline": "cmd.exe",
    "environment": {
        "PATH": "C:\\Code;%PATH%"
    }
}

Note

This also occurs when using pwsh, but it's easier to demonstrate using cmd because you don't need to escape the $ symbol.

Open Windows Terminal and use the standard cmd profile. Run wsl echo $PATH. The output will be something like this:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/System32:/mnt/c/Windows:<...snip...>

Use the custom "cmd with custom PATH" profile. Run wsl echo $PATH. The output will be something like this:

/usr/lib/wsl/lib:/mnt/c/Code:/mnt/c/Windows/System32:/mnt/c/Windows:<...snip...>

Expected Behavior

The value of $PATH in WSL when using the "cmd with custom PATH" profile includes the standard /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games values.

Actual Behavior

The standard PATH values are missing.

Originally created by @reduckted on GitHub (Jul 20, 2025). ### Windows Terminal version 1.22.11141.0 ### Windows build number 10.0.19045.0 ### Other Software WSL: 2.5.9.0 Ubuntu: 22.04.3 LTS ### Steps to reproduce Install WSL and a distro (I'm using Ubuntu, but it doesn't seem to matter which one you use). Use the standard profile for `cmd`, as well as a custom profile that prepends to the `PATH` envrionment variable: ```json { "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", "name": "cmd" }, { "guid": "{324dd25d-8c2a-4ffb-a877-92b93f2bb404}", "name": "cmd with custom PATH", "commandline": "cmd.exe", "environment": { "PATH": "C:\\Code;%PATH%" } } ``` > [!NOTE] > This also occurs when using `pwsh`, but it's easier to demonstrate using `cmd` because you don't need to escape the `$` symbol. Open Windows Terminal and use the standard `cmd` profile. Run `wsl echo $PATH`. The output will be something like this: ``` /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/System32:/mnt/c/Windows:<...snip...> ``` Use the custom "cmd with custom PATH" profile. Run `wsl echo $PATH`. The output will be something like this: ``` /usr/lib/wsl/lib:/mnt/c/Code:/mnt/c/Windows/System32:/mnt/c/Windows:<...snip...> ``` ### Expected Behavior The value of `$PATH` in WSL when using the "cmd with custom PATH" profile includes the standard `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games` values. ### Actual Behavior The standard PATH values are missing.
Author
Owner

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

Ah, we should probably not add PATH to WSLENV. It looks like that upsets WSL.

... I'm somewhat surprised that WSL doesn't handle that more gracefully.

Anyway, we should be able to fix it locally.

@DHowett commented on GitHub (Jul 30, 2025): Ah, we should probably not add `PATH` to `WSLENV`. It looks like that upsets WSL. ... I'm somewhat surprised that WSL doesn't handle that more gracefully. Anyway, we should be able to fix it locally.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23455