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! {
22
22
description( "toolchain is not installed" )
23
23
display( "toolchain '{}' is not installed" , t)
24
24
}
25
+ BinaryNotFound ( t: String , bin: String ) {
26
+ description( "toolchain does not contain binary" )
27
+ display( "toolchain '{}' does not have the binary `{}`" , t, bin)
28
+ }
25
29
NeedMetadataUpgrade {
26
30
description( "rustup's metadata is out of date. run `rustup self upgrade-data`" )
27
31
}
Original file line number Diff line number Diff line change @@ -301,13 +301,20 @@ impl<'a> Toolchain<'a> {
301
301
} ;
302
302
303
303
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) {
305
305
& bin_path
306
306
} 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 > 4 {
310
+ return Err ( ErrorKind :: BinaryNotFound ( self . name . clone ( ) ,
311
+ binary. to_string_lossy ( )
312
+ . into ( ) )
313
+ . into ( ) )
314
+ }
309
315
Path :: new ( & binary)
310
- } ) ;
316
+ } ;
317
+ let mut cmd = Command :: new ( & path) ;
311
318
self . set_env ( & mut cmd) ;
312
319
Ok ( cmd)
313
320
}
You can’t perform that action at this time.
0 commit comments