Skip to content

Command.env not working since nightly-2021-07-05 #87859

Closed
@seven1oe

Description

@seven1oe

Command.env not work after nightly-2021-07-05 or commit 8345538(maybe).

Here is my test main.rs:

use std::process::Command;
fn main() {
    Command::new("gcc").env("PATH", "C:\\msys64\\mingw64\\bin").spawn().expect("gcc not found");
}
> rustup default stable-x86_64-pc-windows-gnu
info: using existing install for 'stable-x86_64-pc-windows-gnu'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'
  stable-x86_64-pc-windows-gnu unchanged - rustc 1.54.0 (a178d0322 2021-07-26)

> rustc main.rs -o stable.exe

> stable.exe      # gcc found !!
gcc.exe: fatal error: no input files
compilation terminated.
> rustup default nightly-2021-07-05-x86_64-pc-windows-gnu
info: using existing install for 'nightly-2021-07-05-x86_64-pc-windows-gnu'
info: default toolchain set to 'nightly-2021-07-05-x86_64-pc-windows-gnu'
  nightly-2021-07-05-x86_64-pc-windows-gnu unchanged - rustc 1.55.0-nightly (b3d11f95c 2021-07-04)

> rustc main.rs -o nightly.exe

> nightly.exe      # gcc not found !!
thread 'main' panicked at 'gcc not found: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }', main.rs:4:73
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This also affects rustc search for linker after nightly-2021-07-05 (with link-self-contained=yes or without mingw installed)

Run the rustc in cargo's bin works fine, but run the rustc in toolchain's bin show this:

error: linker `x86_64-w64-mingw32-gcc` not found

cmd.env("PATH", env::join_paths(new_path).unwrap());

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions