@@ -584,7 +584,7 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
584
584
585
585
match subcmd {
586
586
RustupSubcmd :: DumpTestament => common:: dump_testament ( process) ,
587
- RustupSubcmd :: Install { opts } => update ( cfg, opts) . await ,
587
+ RustupSubcmd :: Install { opts } => update ( cfg, opts, false ) . await ,
588
588
RustupSubcmd :: Uninstall { opts } => toolchain_remove ( cfg, opts) ,
589
589
RustupSubcmd :: Show { verbose, subcmd } => handle_epipe ( match subcmd {
590
590
None => show ( cfg, verbose) ,
@@ -610,11 +610,12 @@ pub async fn main(current_dir: PathBuf, process: &Process) -> Result<utils::Exit
610
610
force_non_host,
611
611
..UpdateOpts :: default ( )
612
612
} ,
613
+ false ,
613
614
)
614
615
. await
615
616
}
616
617
RustupSubcmd :: Toolchain { subcmd } => match subcmd {
617
- ToolchainSubcmd :: Install { opts } => update ( cfg, opts) . await ,
618
+ ToolchainSubcmd :: Install { opts } => update ( cfg, opts, false ) . await ,
618
619
ToolchainSubcmd :: List { verbose, quiet } => {
619
620
handle_epipe ( common:: list_toolchains ( cfg, verbose, quiet) )
620
621
}
@@ -791,7 +792,11 @@ async fn check_updates(cfg: &Cfg<'_>) -> Result<utils::ExitCode> {
791
792
Ok ( utils:: ExitCode ( 0 ) )
792
793
}
793
794
794
- async fn update ( cfg : & mut Cfg < ' _ > , opts : UpdateOpts ) -> Result < utils:: ExitCode > {
795
+ async fn update (
796
+ cfg : & mut Cfg < ' _ > ,
797
+ opts : UpdateOpts ,
798
+ ensure_active_toolchain : bool ,
799
+ ) -> Result < utils:: ExitCode > {
795
800
let mut exit_code = utils:: ExitCode ( 0 ) ;
796
801
797
802
common:: warn_if_host_is_emulated ( cfg. process ) ;
@@ -861,6 +866,13 @@ async fn update(cfg: &mut Cfg<'_>, opts: UpdateOpts) -> Result<utils::ExitCode>
861
866
if self_update {
862
867
exit_code &= common:: self_update ( || Ok ( ( ) ) , cfg. process ) . await ?;
863
868
}
869
+ } else if ensure_active_toolchain {
870
+ let ( toolchain, reason) = cfg. find_or_install_active_toolchain ( true ) . await ?;
871
+ info ! (
872
+ "the active toolchain `{}` has been installed" ,
873
+ toolchain. name( )
874
+ ) ;
875
+ info ! ( "it's active because: {reason}" ) ;
864
876
} else {
865
877
exit_code &= common:: update_all_channels ( cfg, self_update, opts. force ) . await ?;
866
878
info ! ( "cleaning up downloads & tmp directories" ) ;
0 commit comments