Bug report form
Describe the bug
The which command on Windows finds program files. It does so using the PATHEXT environment variable, which lists file extensions that are to be treated as executable on Windows. However, if I temporarily change $env.PATHEXT using with-env, the which command does not see the change.
For what it's worth, if I change $env.PATH using with-env, this does correctly affect the behaviour of which.
How to reproduce
Demonstration of which finding an executable based on PATHEXT:
❯ $env.PATH.30
C:\Users\Gustav\.local\scripts
❯ ls C:\Users\Gustav\.local\scripts\tmp_py.py
╭───┬──────────────────────────────────────────┬──────┬───────┬─────────────╮
│ # │ name │ type │ size │ modified │
├───┼──────────────────────────────────────────┼──────┼───────┼─────────────┤
│ 0 │ C:\Users\Gustav\.local\scripts\tmp_py.py │ file │ 127 B │ 2 years ago │
╰───┴──────────────────────────────────────────┴──────┴───────┴─────────────╯
❯ $env.PATHEXT
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYZ;.PYW;.PYZW
❯ which tmp_py
╭───┬─────────┬──────────────────────────────────────────┬──────────╮
│ # │ command │ path │ type │
├───┼─────────┼──────────────────────────────────────────┼──────────┤
│ 0 │ tmp_py │ C:\Users\Gustav\.local\scripts\tmp_py.py │ external │
╰───┴─────────┴──────────────────────────────────────────┴──────────╯
Demonstration of temporary change to PATHEXT not working:
❯ ls C:\Users\Gustav\.local\scripts\v.ps1
╭───┬──────────────────────────────────────┬──────┬────────┬─────────────╮
│ # │ name │ type │ size │ modified │
├───┼──────────────────────────────────────┼──────┼────────┼─────────────┤
│ 0 │ C:\Users\Gustav\.local\scripts\v.ps1 │ file │ 2.3 kB │ 5 years ago │
╰───┴──────────────────────────────────────┴──────┴────────┴─────────────╯
❯ which v
╭────────────╮
│ empty list │
╰────────────╯
❯ with-env { PATHEXT: ($env.PATHEXT + ";.ps1") } { which v }
╭────────────╮
│ empty list │
╰────────────╯
Demonstration that other commands see the change to PATHEXT:
❯ with-env { PATHEXT: ($env.PATHEXT + ";.ps1") } { py -c "import os; print(os.environ['PATHEXT'])" }
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYZ;.PYW;.PYZW;.ps1
Expected behavior
I expected the which command to correctly find executables with extensions added to PATHEXT via with-env, in the same way that it finds executables in directories added to PATH via with-env.
Configuration
❯ version | transpose key value | to md --pretty
| key |
value |
| version |
0.113.1 |
| major |
0 |
| minor |
113 |
| patch |
1 |
| branch |
|
| commit_hash |
7b7df4a |
| build_os |
windows-x86_64 |
| build_target |
x86_64-pc-windows-msvc |
| rust_version |
rustc 1.93.1 (01f6ddf75 2026-02-11) |
| rust_channel |
1.93.1-x86_64-pc-windows-msvc |
| cargo_version |
cargo 1.93.1 (083ac5135 2025-12-15) |
| build_time |
2026-05-29 22:36:34 +00:00 |
| build_rust_channel |
release |
| allocator |
standard |
| features |
default, mcp, network, plugin, rustls-tls, sqlite, trash-support |
| installed_plugins |
formats 0.103.0 |
| experimental_options |
example=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=false, native-clip=false, cell-path-types=false |
Bug report form
Describe the bug
The
whichcommand on Windows finds program files. It does so using thePATHEXTenvironment variable, which lists file extensions that are to be treated as executable on Windows. However, if I temporarily change$env.PATHEXTusingwith-env, thewhichcommand does not see the change.For what it's worth, if I change
$env.PATHusingwith-env, this does correctly affect the behaviour ofwhich.How to reproduce
Demonstration of
whichfinding an executable based onPATHEXT:Demonstration of temporary change to PATHEXT not working:
Demonstration that other commands see the change to
PATHEXT:Expected behavior
I expected the
whichcommand to correctly find executables with extensions added toPATHEXTviawith-env, in the same way that it finds executables in directories added toPATHviawith-env.Configuration
❯ version | transpose key value | to md --pretty