Skip to content

env_clear does not work on Windows #31259

Closed
@nagisa

Description

@nagisa

Running Command with env_clear will reproducibly result in Error with OS code 87.

> cargo script -e '::std::process::Command::new(\"gcc.exe\").env_clear().output(
).unwrap()'
   Compiling expr v0.1.0 (file:///C:/Users/drk/AppData/Local/Cargo/script-cache/
expr-37b14ef2470ffe18)
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Error
{ repr: Os { code: 87, message: "The parameter is incorrect." } }', ../src/libco
re\result.rs:688
An unknown error occurred

if env_clear is omitted, it works:

To learn more, run the command again with --verbose.
> cargo script -e '::std::process::Command::new(\"gcc.exe\").output().unwrap()'
   Compiling expr v0.1.0 (file:///C:/Users/drk/AppData/Local/Cargo/script-cache/
expr-67fa84126914720e)
Output { status: ExitStatus(ExitStatus(1)), stdout: "", stderr: "gcc.exe: fatal
error: no input files\r\ncompilation terminated.\r\n" }

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions