Skip to content

Windows std::env::vars() uppercases environment variables #85242

Closed
@sophiajt

Description

@sophiajt

I tried this code:

    for v in std::env::vars() {
        println!("{:?}", v);
    }

I expected to see this happen: a case-sensitive list of environment variables and values, matching the output of Environment.GetEnvironmentVariables from C# and .NET and the output of Get-ChildItem Env: from PowerShell.

It seems we should align the std::env::vars() output to match the modern APIs for Windows that Microsoft provides.

Instead, this happened: std::env::vars() returns all environment variable names in all uppercase.

Rust via std::env::vars():

SYSTEMDRIVE = C:
<snip>

C# via Environment.GetEnvironmentVariables:

SystemDrive = C:
<snip>

Meta

rustc --version --verbose:

>rustc --version --verbose
rustc 1.51.0-nightly (04caa632d 2021-01-30)
binary: rustc
commit-hash: 04caa632dd10c2bf64b69524c7f9c4c30a436877
commit-date: 2021-01-30
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
LLVM version: 11.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions