File tree 3 files changed +25
-4
lines changed
3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,11 @@ continuous integration systems.",
78
78
pub fn exec ( config : & mut Config , args : & ArgMatches < ' _ > ) -> CliResult {
79
79
let registry = args. registry ( config) ?;
80
80
81
- config. reload_rooted_at_cargo_home ( ) ?;
81
+ if let Some ( path) = args. value_of_path ( "path" , config) {
82
+ config. reload_rooted_at ( path) ?;
83
+ } else {
84
+ config. reload_rooted_at ( config. home ( ) . clone ( ) . into_path_unlocked ( ) ) ?;
85
+ }
82
86
83
87
let workspace = args. workspace ( config) . ok ( ) ;
84
88
let mut compile_opts = args. compile_options ( config, CompileMode :: Build , workspace. as_ref ( ) ) ?;
Original file line number Diff line number Diff line change @@ -285,9 +285,8 @@ impl Config {
285
285
}
286
286
}
287
287
288
- pub fn reload_rooted_at_cargo_home ( & mut self ) -> CargoResult < ( ) > {
289
- let home = self . home_path . clone ( ) . into_path_unlocked ( ) ;
290
- let values = self . load_values_from ( & home) ?;
288
+ pub fn reload_rooted_at < P : AsRef < Path > > ( & mut self , path : P ) -> CargoResult < ( ) > {
289
+ let values = self . load_values_from ( path. as_ref ( ) ) ?;
291
290
self . values . replace ( values) ;
292
291
Ok ( ( ) )
293
292
}
Original file line number Diff line number Diff line change @@ -1358,3 +1358,21 @@ fn install_global_cargo_config() {
1358
1358
. with_stderr_contains ( "[..]--target nonexistent[..]" )
1359
1359
. run ( ) ;
1360
1360
}
1361
+
1362
+ #[ test]
1363
+ fn install_path_config ( ) {
1364
+ project ( )
1365
+ . file (
1366
+ ".cargo/config" ,
1367
+ r#"
1368
+ [build]
1369
+ target = 'nonexistent'
1370
+ "# ,
1371
+ )
1372
+ . file ( "src/main.rs" , "fn main() {}" )
1373
+ . build ( ) ;
1374
+ cargo_process ( "install --path foo" )
1375
+ . with_status ( 101 )
1376
+ . with_stderr_contains ( "[..]--target nonexistent[..]" )
1377
+ . run ( ) ;
1378
+ }
You can’t perform that action at this time.
0 commit comments