Skip to content

Windows environment variables are case preserving (but case-insensitive) #9630

Closed
@ChrisDenton

Description

@ChrisDenton

I recently submitted a PR to stop Rust ASCII upper casing environment variables: rust-lang/rust#85270. This causes the following test to fail.

let target = rustc_host();
let env_key = format!(
"CARGO_TARGET_{}_LINKER",
target.to_lowercase().replace('-', "_")
);
let mut execs = p.cargo("build -v --target");
execs.arg(target).env(&env_key, "nonexistent-linker");
if cfg!(windows) {
// Windows env keys are case insensitive, so no warning, but it will
// fail due to the missing linker.
execs
.with_stderr_does_not_contain("warning:[..]")
.with_status(101);

I think it's because something relies on a new process upper casing key names? Which only happened before because Rust manually ASCII upper cased keys when starting a new process.


Hm, that seems to be the assumption here:

fn check_environment_key_case_mismatch(&self, key: &ConfigKey) {
if cfg!(windows) {
// In the case of windows the check for case mismatch in keys can be skipped
// as windows already converts its environment keys into the desired format.
return;
}

Whereas Windows itself does no such conversion.


cc @ehuss ? (only because you most recently touched the relevant test 🙂)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions