Skip to content

Commit 09c4b28

Browse files
rami3lChrisDenton
authored andcommitted
fix(config): improve error when overridden active custom toolchain isn't installed
1 parent 38b3eb6 commit 09c4b28

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ impl<'a> Cfg<'a> {
649649
Err(RustupError::ToolchainNotInstalled(_)) => {
650650
if matches!(toolchain_name, ToolchainName::Custom(_)) {
651651
bail!(
652-
"Toolchain {toolchain_name} in {} is custom and not installed",
652+
"custom toolchain specified in override file '{}' is not installed",
653653
toolchain_file.display()
654654
)
655655
}

tests/suite/cli_rustup.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2487,7 +2487,37 @@ async fn file_override_not_installed_custom() {
24872487
raw::write_file(&toolchain_file, "gumbo").unwrap();
24882488

24892489
cx.config
2490-
.expect_err(&["rustc", "--version"], "custom and not installed")
2490+
.expect_err(
2491+
&["rustup", "show", "active-toolchain"],
2492+
"custom toolchain specified in override file",
2493+
)
2494+
.await;
2495+
cx.config
2496+
.expect_err(
2497+
&["rustc", "--version"],
2498+
"custom toolchain specified in override file",
2499+
)
2500+
.await;
2501+
}
2502+
2503+
#[tokio::test]
2504+
async fn file_override_not_installed_custom_toml() {
2505+
let cx = CliTestContext::new(Scenario::None).await;
2506+
let cwd = cx.config.current_dir();
2507+
let toolchain_file = cwd.join("rust-toolchain.toml");
2508+
raw::write_file(&toolchain_file, r#"toolchain.channel = "i-am-the-walrus""#).unwrap();
2509+
2510+
cx.config
2511+
.expect_err(
2512+
&["rustup", "show", "active-toolchain"],
2513+
"custom toolchain specified in override file",
2514+
)
2515+
.await;
2516+
cx.config
2517+
.expect_err(
2518+
&["rustc", "--version"],
2519+
"custom toolchain specified in override file",
2520+
)
24912521
.await;
24922522
}
24932523

0 commit comments

Comments
 (0)