File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,11 @@ continuous integration systems.",
7878pub fn exec ( config : & mut Config , args : & ArgMatches < ' _ > ) -> CliResult {
7979 let registry = args. registry ( config) ?;
8080
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+ }
8286
8387 let workspace = args. workspace ( config) . ok ( ) ;
8488 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 {
285285 }
286286 }
287287
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 ( ) ) ?;
291290 self . values . replace ( values) ;
292291 Ok ( ( ) )
293292 }
Original file line number Diff line number Diff line change @@ -1358,3 +1358,21 @@ fn install_global_cargo_config() {
13581358 . with_stderr_contains ( "[..]--target nonexistent[..]" )
13591359 . run ( ) ;
13601360}
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