Skip to content

Commit 23c1a51

Browse files
committed
Improve error message in join_paths when env contains a path separator
1 parent 82a92a2 commit 23c1a51

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

crates/cargo-util/src/paths.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ use tempfile::Builder as TempFileBuilder;
1818
/// environment variable this is will be used for, which is included in the
1919
/// error message.
2020
pub fn join_paths<T: AsRef<OsStr>>(paths: &[T], env: &str) -> Result<OsString> {
21-
env::join_paths(paths.iter())
22-
.with_context(|| {
23-
let paths = paths.iter().map(Path::new).collect::<Vec<_>>();
24-
format!("failed to join path array: {:?}", paths)
25-
})
26-
.with_context(|| {
27-
format!(
28-
"failed to join search paths together\n\
29-
Does ${} have an unterminated quote character?",
30-
env
31-
)
32-
})
21+
env::join_paths(paths.iter()).with_context(|| {
22+
let paths = paths.iter().map(Path::new).collect::<Vec<_>>();
23+
format!(
24+
"failed to join paths from `${}` together\
25+
\n \
26+
If you set `${}` manually, check if it contains an unterminated quote character \
27+
or path separators (usually `:` or `:`). Please avoid using them.\
28+
\n\n \
29+
Otherwise, check if any of paths listed contain one of those characters: {:?}",
30+
env, env, paths
31+
)
32+
})
3333
}
3434

3535
/// Returns the name of the environment variable used for searching for

0 commit comments

Comments
 (0)