@@ -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,7 @@ 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 && ( !toolchain. exists ( ) || !components_exist ( & distributable, & components, & targets) ?)
703
704
{
704
705
distributable. install_from_dist ( true , false , & components, & targets, profile) ?;
705
706
}
@@ -789,15 +790,8 @@ impl Cfg {
789
790
} )
790
791
}
791
792
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
793
pub fn create_command_for_dir ( & self , path : & Path , binary : & str ) -> Result < Command > {
800
- let ( ref toolchain, _) = self . toolchain_for_dir ( path) ?;
794
+ let ( ref toolchain, _) = self . find_or_install_override_toolchain_or_default ( path, true ) ?;
801
795
802
796
if let Some ( cmd) = self . maybe_do_cargo_fallback ( toolchain, binary) ? {
803
797
Ok ( cmd)
0 commit comments