File tree 3 files changed +40
-5
lines changed
3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -452,6 +452,25 @@ impl<'a> InstalledCommonToolchain<'a> {
452
452
path_entries. push ( cargo_home. join ( "bin" ) ) ;
453
453
}
454
454
455
+ if cfg ! ( target_os = "windows" ) {
456
+ // Historically rustup has included the bin directory in PATH to
457
+ // work around some bugs (see
458
+ // https://github.com/rust-lang/rustup/pull/3178 for more
459
+ // information). This shouldn't be needed anymore, and it causes
460
+ // problems because calling tools recursively (like `cargo
461
+ // +nightly metadata` from within a cargo subcommand). The
462
+ // recursive call won't work because it is not executing the
463
+ // proxy, so the `+` toolchain override doesn't work.
464
+ //
465
+ // This is opt-in to allow us to get more real-world testing.
466
+ if process ( )
467
+ . var_os ( "RUSTUP_WINDOWS_PATH_ADD_BIN" )
468
+ . map_or ( true , |s| s == "1" )
469
+ {
470
+ path_entries. push ( self . 0 . path . join ( "bin" ) ) ;
471
+ }
472
+ }
473
+
455
474
env_var:: prepend_path ( "PATH" , path_entries, cmd) ;
456
475
}
457
476
}
Original file line number Diff line number Diff line change @@ -586,11 +586,25 @@ fn recursive_cargo() {
586
586
fs:: create_dir_all ( & cargo_bin_path) . unwrap ( ) ;
587
587
fs:: copy ( & real_mock_cargo, & cargo_subcommand) . unwrap ( ) ;
588
588
589
- expect_stdout_ok (
589
+ let args = & [ "cargo" , "--recursive-cargo-subcommand" ] ;
590
+ if cfg ! ( windows) {
591
+ expect_err (
592
+ config,
593
+ & [ "cargo" , "--recursive-cargo-subcommand" ] ,
594
+ "bad mock proxy commandline" ,
595
+ ) ;
596
+ }
597
+
598
+ let out = run (
590
599
config,
591
- & [ "cargo" , "--recursive-cargo-subcommand" ] ,
592
- "hash-nightly-2" ,
600
+ args[ 0 ] ,
601
+ & args[ 1 ..] ,
602
+ & [ ( "RUSTUP_WINDOWS_PATH_ADD_BIN" , "0" ) ] ,
593
603
) ;
604
+ if !out. ok || !out. stdout . contains ( "hash-nightly-2" ) {
605
+ clitools:: print_command ( args, & out) ;
606
+ panic ! ( "expected hash-nightly-2 in output" ) ;
607
+ }
594
608
} ) ;
595
609
}
596
610
Original file line number Diff line number Diff line change @@ -62,16 +62,18 @@ fn main() {
62
62
Command :: new ( rustc) . arg ( "--version" ) . status ( ) . unwrap ( ) ;
63
63
}
64
64
Some ( "--recursive-cargo-subcommand" ) => {
65
- Command :: new ( "cargo-foo" )
65
+ let status = Command :: new ( "cargo-foo" )
66
66
. arg ( "--recursive-cargo" )
67
67
. status ( )
68
68
. unwrap ( ) ;
69
+ assert ! ( status. success( ) ) ;
69
70
}
70
71
Some ( "--recursive-cargo" ) => {
71
- Command :: new ( "cargo" )
72
+ let status = Command :: new ( "cargo" )
72
73
. args ( & [ "+nightly" , "--version" ] )
73
74
. status ( )
74
75
. unwrap ( ) ;
76
+ assert ! ( status. success( ) ) ;
75
77
}
76
78
Some ( "--echo-args" ) => {
77
79
let mut out = io:: stderr ( ) ;
You can’t perform that action at this time.
0 commit comments