@@ -409,7 +409,7 @@ impl Cfg {
409
409
}
410
410
411
411
pub fn which_binary ( & self , path : & Path , binary : & str ) -> Result < Option < PathBuf > > {
412
- let ( toolchain, _) = self . find_or_install_override_toolchain_or_default ( path) ?;
412
+ let ( toolchain, _) = self . find_or_install_override_toolchain_or_default ( path, true ) ?;
413
413
Ok ( Some ( toolchain. binary_file ( binary) ) )
414
414
}
415
415
@@ -620,6 +620,7 @@ impl Cfg {
620
620
pub fn find_or_install_override_toolchain_or_default (
621
621
& self ,
622
622
path : & Path ,
623
+ install : bool ,
623
624
) -> Result < ( Toolchain < ' _ > , Option < OverrideReason > ) > {
624
625
fn components_exist (
625
626
distributable : & DistributableToolchain < ' _ > ,
@@ -699,7 +700,9 @@ impl Cfg {
699
700
let targets: Vec < _ > = targets. iter ( ) . map ( AsRef :: as_ref) . collect ( ) ;
700
701
701
702
let distributable = DistributableToolchain :: new ( & toolchain) ?;
702
- if !toolchain. exists ( ) || !components_exist ( & distributable, & components, & targets) ?
703
+ if install
704
+ && ( !toolchain. exists ( )
705
+ || !components_exist ( & distributable, & components, & targets) ?)
703
706
{
704
707
distributable. install_from_dist ( true , false , & components, & targets, profile) ?;
705
708
}
@@ -789,15 +792,8 @@ impl Cfg {
789
792
} )
790
793
}
791
794
792
- pub fn toolchain_for_dir (
793
- & self ,
794
- path : & Path ,
795
- ) -> Result < ( Toolchain < ' _ > , Option < OverrideReason > ) > {
796
- self . find_or_install_override_toolchain_or_default ( path)
797
- }
798
-
799
795
pub fn create_command_for_dir ( & self , path : & Path , binary : & str ) -> Result < Command > {
800
- let ( ref toolchain, _) = self . toolchain_for_dir ( path) ?;
796
+ let ( ref toolchain, _) = self . find_or_install_override_toolchain_or_default ( path, true ) ?;
801
797
802
798
if let Some ( cmd) = self . maybe_do_cargo_fallback ( toolchain, binary) ? {
803
799
Ok ( cmd)
0 commit comments