Skip to content

Commit

Permalink
Disallow RUSTUP_TOOLCHAIN in the [env] table.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed May 8, 2023
1 parent 1490d10 commit 2dccb71
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 2dccb71

Please sign in to comment.