Skip to content

Commit 28f5e91

Browse files
authored
subcommand: Parse and propagate [env] vars at the earliest possible moment (#18)
Strangely enough I added this call at a random place in `Subcommand::new()`, instead of considering that it was both: 1. Breaking the logic for deducing `target_dir` in two separated blocks; 2. Preventing the first block - which reads environment variables! - from seeing what was configured in `.cargo/config.toml` through `[env]`. Fix this by moving the call straight after identifying the root directory for the selected package.
1 parent 6c77c51 commit 28f5e91

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/subcommand.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ impl Subcommand {
4343
)?;
4444
let root_dir = manifest_path.parent().unwrap();
4545

46+
// TODO: Find, parse, and merge _all_ config files following the hierarchical structure:
47+
// https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
48+
let config = LocalizedConfig::find_cargo_config_for_workspace(&root_dir)?;
49+
if let Some(config) = &config {
50+
config.set_env_vars().unwrap();
51+
}
52+
4653
let target_dir = args
4754
.target_dir
4855
.clone()
@@ -59,13 +66,6 @@ impl Subcommand {
5966
}
6067
});
6168

62-
// TODO: Find, parse, and merge _all_ config files following the hierarchical structure:
63-
// https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
64-
let config = LocalizedConfig::find_cargo_config_for_workspace(&root_dir)?;
65-
if let Some(config) = &config {
66-
config.set_env_vars().unwrap();
67-
}
68-
6969
let target_dir = target_dir.unwrap_or_else(|| {
7070
utils::find_workspace(&manifest_path, &package)
7171
.unwrap()

0 commit comments

Comments
 (0)