File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ use cargo_test_support::{
18
18
thread_wait_timeout, Execs , Project ,
19
19
} ;
20
20
use itertools:: Itertools ;
21
+ use std:: env;
21
22
use std:: fmt:: Write ;
22
23
use std:: path:: Path ;
23
24
use std:: path:: PathBuf ;
@@ -167,12 +168,19 @@ fn populate_cache(
167
168
( cache_dir, src_dir)
168
169
}
169
170
171
+ /// Returns an `Execs` that will run the rustup `cargo` proxy from the global
172
+ /// system's cargo home directory.
170
173
fn rustup_cargo ( ) -> Execs {
171
- // Get the path to the rustup cargo wrapper. This is necessary because
172
- // cargo adds the "deps" directory into PATH on Windows, which points to
173
- // the wrong cargo.
174
- let rustup_cargo = Path :: new ( & std:: env:: var_os ( "CARGO_HOME" ) . unwrap ( ) ) . join ( "bin/cargo" ) ;
175
- execs ( ) . with_process_builder ( process ( rustup_cargo) )
174
+ // Modify the PATH to ensure that `cargo` and `rustc` comes from
175
+ // CARGO_HOME. This is necessary because cargo adds the "deps" directory
176
+ // into PATH on Windows, which points to the wrong cargo.
177
+ let real_cargo_home_bin = Path :: new ( & std:: env:: var_os ( "CARGO_HOME" ) . unwrap ( ) ) . join ( "bin" ) ;
178
+ let mut paths = vec ! [ real_cargo_home_bin] ;
179
+ paths. extend ( env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) ) ;
180
+ let path = env:: join_paths ( paths) . unwrap ( ) ;
181
+ let mut e = execs ( ) . with_process_builder ( process ( "cargo" ) ) ;
182
+ e. env ( "PATH" , path) ;
183
+ e
176
184
}
177
185
178
186
#[ cargo_test]
You can’t perform that action at this time.
0 commit comments