Skip to content

Commit 1efb562

Browse files
committed
Auto merge of #12107 - ehuss:disallow-rustup-toolchain, r=weihanglo
Disallow RUSTUP_TOOLCHAIN in the [env] table. This adds RUSTUP_TOOLCHAIN to the list of disallowed keys in the `[env]` table. This is intended to help prevent confusion and broken environments, along with the same reasoning as #12101 and #11590.
2 parents 1490d10 + 2dccb71 commit 1efb562

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/cargo/util/config/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,15 +1751,16 @@ impl Config {
17511751
// from the [env] table. Recursive calls to cargo would use the new
17521752
// value, possibly behaving differently from the outer cargo.
17531753
//
1754-
// - RUSTUP_HOME: Under normal usage with rustup, this will have no
1755-
// effect because the rustup proxy sets RUSTUP_HOME, and that would
1756-
// override the [env] table. If the outer cargo is executed directly
1754+
// - RUSTUP_HOME and RUSTUP_TOOLCHAIN: Under normal usage with rustup,
1755+
// this will have no effect because the rustup proxy sets
1756+
// RUSTUP_HOME and RUSTUP_TOOLCHAIN, and that would override the
1757+
// [env] table. If the outer cargo is executed directly
17571758
// circumventing the rustup proxy, then this would affect calls to
17581759
// rustc (assuming that is a proxy), which could potentially cause
17591760
// problems with cargo and rustc being from different toolchains. We
17601761
// consider this to be not a use case we would like to support,
17611762
// since it will likely cause problems or lead to confusion.
1762-
for disallowed in &["CARGO_HOME", "RUSTUP_HOME"] {
1763+
for disallowed in &["CARGO_HOME", "RUSTUP_HOME", "RUSTUP_TOOLCHAIN"] {
17631764
if env_config.contains_key(*disallowed) {
17641765
bail!(
17651766
"setting the `{disallowed}` environment variable is not supported \

tests/testsuite/cargo_env_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn env_no_disallowed() {
6666
.file("src/lib.rs", "")
6767
.build();
6868

69-
for disallowed in &["CARGO_HOME", "RUSTUP_HOME"] {
69+
for disallowed in &["CARGO_HOME", "RUSTUP_HOME", "RUSTUP_TOOLCHAIN"] {
7070
p.change_file(
7171
".cargo/config",
7272
&format!(

0 commit comments

Comments
 (0)