diff --git a/src/config.rs b/src/config.rs index 3698b15056..d12147b5ef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -317,7 +317,7 @@ impl Cfg { ErrorKind::OverrideToolchainNotInstalled(name.to_string()) }) } else { - toolchain.install_from_dist(false, &[], &[])?; + toolchain.install_from_dist(true, &[], &[])?; Ok(Some((toolchain, reason))) } } @@ -478,7 +478,7 @@ impl Cfg { ) -> Result { let toolchain = self.get_toolchain(toolchain, false)?; if install_if_missing && !toolchain.exists() { - toolchain.install_from_dist(false, &[], &[])?; + toolchain.install_from_dist(true, &[], &[])?; } if let Some(cmd) = self.maybe_do_cargo_fallback(&toolchain, binary)? { diff --git a/tests/cli-v2.rs b/tests/cli-v2.rs index 958c7c9533..580bab90fc 100644 --- a/tests/cli-v2.rs +++ b/tests/cli-v2.rs @@ -4,8 +4,8 @@ pub mod mock; use crate::mock::clitools::{ - self, expect_err, expect_not_stderr_ok, expect_not_stdout_ok, expect_ok, expect_stderr_ok, - expect_stdout_ok, set_current_dist_date, this_host_triple, Config, Scenario, + self, expect_err, expect_not_stderr_ok, expect_not_stdout_ok, expect_ok, expect_ok_ex, + expect_stderr_ok, expect_stdout_ok, set_current_dist_date, this_host_triple, Config, Scenario, }; use std::fs; use std::io::Write; @@ -1185,3 +1185,36 @@ fn test_complete_profile_skips_missing_when_forced() { ); }) } + +#[test] +fn run_with_install_flag_against_unavailable_component() { + setup(&|config| { + let trip = TargetTriple::from_build(); + make_component_unavailable(config, "rust-std", &trip); + expect_ok_ex( + config, + &[ + "rustup", + "run", + "--install", + "nightly", + "rustc", + "--version", + ], + "1.3.0 (hash-nightly-2) +", + for_host!( + r"info: syncing channel updates for 'nightly-{0}' +info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2) +warning: Force-skipping unavailable component 'rust-std-{0}' +info: downloading component 'cargo' +info: downloading component 'rust-docs' +info: downloading component 'rustc' +info: installing component 'cargo' +info: installing component 'rust-docs' +info: installing component 'rustc' +" + ), + ); + }); +}