Skip to content

Commit

Permalink
Auto merge of #12107 - ehuss:disallow-rustup-toolchain, r=weihanglo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 8, 2023
2 parents 1490d10 + 2dccb71 commit 1efb562
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,15 +1751,16 @@ impl Config {
// from the [env] table. Recursive calls to cargo would use the new
// value, possibly behaving differently from the outer cargo.
//
// - RUSTUP_HOME: Under normal usage with rustup, this will have no
// effect because the rustup proxy sets RUSTUP_HOME, and that would
// override the [env] table. If the outer cargo is executed directly
// - RUSTUP_HOME and RUSTUP_TOOLCHAIN: Under normal usage with rustup,
// this will have no effect because the rustup proxy sets
// RUSTUP_HOME and RUSTUP_TOOLCHAIN, and that would override the
// [env] table. If the outer cargo is executed directly
// circumventing the rustup proxy, then this would affect calls to
// rustc (assuming that is a proxy), which could potentially cause
// problems with cargo and rustc being from different toolchains. We
// consider this to be not a use case we would like to support,
// since it will likely cause problems or lead to confusion.
for disallowed in &["CARGO_HOME", "RUSTUP_HOME"] {
for disallowed in &["CARGO_HOME", "RUSTUP_HOME", "RUSTUP_TOOLCHAIN"] {
if env_config.contains_key(*disallowed) {
bail!(
"setting the `{disallowed}` environment variable is not supported \
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_env_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn env_no_disallowed() {
.file("src/lib.rs", "")
.build();

for disallowed in &["CARGO_HOME", "RUSTUP_HOME"] {
for disallowed in &["CARGO_HOME", "RUSTUP_HOME", "RUSTUP_TOOLCHAIN"] {
p.change_file(
".cargo/config",
&format!(
Expand Down

0 comments on commit 1efb562

Please sign in to comment.