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