Closed
Description
Problem
There seems to be a discrepancy in how RUSTUP_TOOLCHAIN
is set on Windows versus Mac and Linux.
Steps
- Create a Cargo project in a directory called
env
. Give it the followingmain.rs
:And the followingfn main() { println!("{}", env!("RUSTUP_TOOLCHAIN")); }
rust-toolchain
:[toolchain] channel = "nightly-2022-06-30"
- In a sibling directory, create another Cargo project with the following
main.rs
:fn main() { std::process::Command::new("cargo") .env_remove("RUSTUP_TOOLCHAIN") .current_dir("../env") .arg("run") .status() .unwrap(); }
cargo run
the latter. On Linux and Mac, the toolchain is printed as one might expect. But on Windows, one gets:error: environment variable `RUSTUP_TOOLCHAIN` not defined --> src\main.rs:2:20 | 2 | println!("{}", env!("RUSTUP_TOOLCHAIN")); | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: could not compile `env` due to previous error
Possible Solution(s)
Sorry, I don't have any.
Notes
I'm not sure if this is related to #3036.
Rustup version
rustup 1.25.1 (bb60b1e89 2022-07-12)
Installed toolchains
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\User\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-msvc (default)
nightly-2022-06-30-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.62.1 (e092d0b6b 2022-07-16)