File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ error_chain! {
2222 description( "toolchain is not installed" )
2323 display( "toolchain '{}' is not installed" , t)
2424 }
25+ BinaryNotFound ( t: String , bin: String ) {
26+ description( "toolchain does not contain binary" )
27+ display( "toolchain '{}' does not have the binary `{}`" , t, bin)
28+ }
2529 NeedMetadataUpgrade {
2630 description( "rustup's metadata is out of date. run `rustup self upgrade-data`" )
2731 }
Original file line number Diff line number Diff line change @@ -301,13 +301,20 @@ impl<'a> Toolchain<'a> {
301301 } ;
302302
303303 let bin_path = self . path . join ( "bin" ) . join ( & binary) ;
304- let mut cmd = Command :: new ( if utils:: is_file ( & bin_path) {
304+ let path = if utils:: is_file ( & bin_path) {
305305 & bin_path
306306 } else {
307- // If the bin doesn't actually exist in the sysroot, let the OS try
308- // to resolve it globally for us
307+ let recursion_count = env:: var ( "RUST_RECURSION_COUNT" ) . ok ( )
308+ . and_then ( |s| s. parse ( ) . ok ( ) ) . unwrap_or ( 0 ) ;
309+ if recursion_count > 3 {
310+ return Err ( ErrorKind :: BinaryNotFound ( self . name . clone ( ) ,
311+ binary. to_string_lossy ( )
312+ . into ( ) )
313+ . into ( ) )
314+ }
309315 Path :: new ( & binary)
310- } ) ;
316+ } ;
317+ let mut cmd = Command :: new ( & path) ;
311318 self . set_env ( & mut cmd) ;
312319 Ok ( cmd)
313320 }
You can’t perform that action at this time.
0 commit comments