Config env snapshot doesn't handle case-insensitive env vars correctly on windows #11814
Closed
Description
opened on Mar 9, 2023
Problem
Some recent changes introduce snapshotting of env variables:
cargo/src/cargo/util/config/mod.rs
Lines 209 to 210 in a5d47a7
e. g. this PR #11727 by @kylematsuda
That introduces a little bug on windows where env vars are case-insensitive. env::var_os
would handle that correctly, but config.get_env_os
does a HashMap lookup which is case-sensitive.
e. g. the mentioned PR breaks the lookup of cargo subcommands on windows (where the env var is called Path
instead of PATH
).
Steps
- On windows install a cargo subcommand into a different directory
- Add the directory to your PATH
- Run cargo
- Cargo says: no such command:
<subcommand>
Workaround:
set PATH2=%PATH%
set PATH=
set PATH=%PATH2%
set PATH2=
This changes the casing of the env variable.
Possible Solution(s)
Wrap the keys in the env snapshot HashMap with some case-insenstive NewType struct.
Notes
No response
Version
nightly-2023-03-01
Activity