File tree 3 files changed +11
-9
lines changed
3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
19
19
let args = cli ( ) . try_get_matches ( ) ?;
20
20
21
21
// Update the process-level notion of cwd
22
- // This must be completed before config is initialized
23
- assert_eq ! ( config. is_init( ) , false ) ;
24
22
if let Some ( new_cwd) = args. get_one :: < std:: path:: PathBuf > ( "directory" ) {
25
23
// This is a temporary hack. This cannot access `Config`, so this is a bit messy.
26
24
// This does not properly parse `-Z` flags that appear after the subcommand.
@@ -40,6 +38,7 @@ pub fn main(config: &mut LazyConfig) -> CliResult {
40
38
. into ( ) ) ;
41
39
}
42
40
std:: env:: set_current_dir ( & new_cwd) . context ( "could not change to requested directory" ) ?;
41
+ config. get_mut ( ) . reload_cwd ( ) ;
43
42
}
44
43
45
44
// CAUTION: Be careful with using `config` until it is configured below.
@@ -661,13 +660,6 @@ impl LazyConfig {
661
660
Self { config : None }
662
661
}
663
662
664
- /// Check whether the config is loaded
665
- ///
666
- /// This is useful for asserts in case the environment needs to be setup before loading
667
- pub fn is_init ( & self ) -> bool {
668
- self . config . is_some ( )
669
- }
670
-
671
663
/// Get the config, loading it if needed
672
664
///
673
665
/// On error, the process is terminated
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ fn main() {
21
21
setup_logger ( ) ;
22
22
23
23
let mut config = cli:: LazyConfig :: new ( ) ;
24
+ config. get ( ) ;
24
25
25
26
let result = if let Some ( lock_addr) = cargo:: ops:: fix_get_proxy_lock_addr ( ) {
26
27
cargo:: ops:: fix_exec_rustc ( config. get ( ) , & lock_addr) . map_err ( |e| CliError :: from ( e) )
Original file line number Diff line number Diff line change @@ -565,6 +565,15 @@ impl Config {
565
565
self . search_stop_path = Some ( path) ;
566
566
}
567
567
568
+ /// Run after calling [`std::env::set_current_dir`]
569
+ pub fn reload_cwd ( & mut self ) -> CargoResult < ( ) > {
570
+ let cwd = env:: current_dir ( )
571
+ . with_context ( || "couldn't get the current directory of the process" ) ?;
572
+ self . cwd = cwd;
573
+ self . reload_rooted_at ( self . cwd . clone ( ) ) ?;
574
+ Ok ( ( ) )
575
+ }
576
+
568
577
/// Reloads on-disk configuration values, starting at the given path and
569
578
/// walking up its ancestors.
570
579
pub fn reload_rooted_at < P : AsRef < Path > > ( & mut self , path : P ) -> CargoResult < ( ) > {
You can’t perform that action at this time.
0 commit comments