Skip to content

Commit 019b4e1

Browse files
Fixes error message
1 parent 97707a8 commit 019b4e1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/cargo/util/config/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ impl Config {
452452
} else if let Some(dir) = env::var_os("CARGO_TARGET_DIR") {
453453
// Check if the CARGO_TARGET_DIR environment variable is set to an empty string.
454454
if dir.to_string_lossy() == "" {
455-
anyhow::bail!("the target directory is set to an empty string in the CARGO_TARGET_DIR environment variable.")
455+
anyhow::bail!("the target directory is set to an empty string in the `CARGO_TARGET_DIR` environment variable")
456456
}
457457

458458
Ok(Some(Filesystem::new(self.cwd.join(dir))))
@@ -461,9 +461,10 @@ impl Config {
461461

462462
// Check if the target directory is set to an empty string in the config.toml file.
463463
if val.raw_value() == "" {
464-
anyhow::bail!(
465-
"the target directory is set to an empty string in the config.toml file.",
466-
)
464+
anyhow::bail!(format!(
465+
"the target directory is set to an empty string in {}",
466+
val.value().definition
467+
),)
467468
}
468469

469470
Ok(Some(Filesystem::new(path)))

src/cargo/util/config/path.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ use std::path::PathBuf;
1010
pub struct ConfigRelativePath(Value<String>);
1111

1212
impl ConfigRelativePath {
13+
/// Returns the underlying value.
14+
pub fn value(&self) -> &Value<String> {
15+
&self.0
16+
}
17+
1318
/// Returns the raw underlying configuration value for this key.
1419
pub fn raw_value(&self) -> &str {
1520
&self.0.val

tests/testsuite/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ target-dir = ''
14971497

14981498
assert_error(
14991499
config.target_dir().unwrap_err(),
1500-
"the target directory is set to an empty string in the config.toml file.",
1500+
"the target directory is set to an empty string in [..]/.cargo/config",
15011501
);
15021502
}
15031503

0 commit comments

Comments
 (0)