From ff576412359b23b586d214a21ece873d48ca8563 Mon Sep 17 00:00:00 2001 From: killuazoldyck680 Date: Fri, 12 Jun 2026 22:48:40 +0530 Subject: [PATCH] cli: prompt user to install stable toolchain when environment is empty --- src/cli/rustup_mode.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 47fd31ec71..fcf95d73f9 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -675,6 +675,24 @@ pub async fn main( )?; cfg.toolchain_override = matches.plus_toolchain; + let is_install_cmd = match &subcmd { + RustupSubcmd::Install { .. } => true, + RustupSubcmd::Toolchain { subcmd } => { + matches!(subcmd, ToolchainSubcmd::Install { .. }) + } + _ => false, + }; + + if !is_install_cmd && cfg.list_toolchains()?.is_empty() && cfg.find_default()?.is_none() { + use std::io::Write; + let mut stderr = cfg.process.stderr().lock(); + writeln!(stderr, "info: no toolchains installed")?; + writeln!( + stderr, + "hint: run 'rustup toolchain install stable' to install the default toolchain" + )?; + } + match subcmd { RustupSubcmd::DumpTestament => common::dump_testament(process), RustupSubcmd::Install { opts } => update(cfg, opts, true).await,