Skip to content

Commit

Permalink
Auto merge of #12820 - linyihai:broken-symlink-target, r=weihanglo
Browse files Browse the repository at this point in the history
add detailed message when target folder path is invalid

# What does this PR try to resolve?
close #12789

add more detailed message when target folder path is invalid

# How should we test and review this PR?

Before this PR, if the target folder refer to broken symbolic link like /a/b/c, then run cargo build, the output is:

```
error: Not a directory (os error 20)
```
the detailed error message is missing.

This PR will add the error context for it, the finall output will be
```
cargo build
error: failed to create directory `/root/workspace/playground/target`

Caused by:
  Not a directory (os error 20)
```
  • Loading branch information
bors committed Oct 14, 2023
2 parents c3fc03e + ceac419 commit f7e7cc2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ pub fn create_dir_all_excluded_from_backups_atomic(p: impl AsRef<Path>) -> Resul
// we can infer from it's another cargo process doing work.
if let Err(e) = fs::rename(tempdir.path(), path) {
if !path.exists() {
return Err(anyhow::Error::from(e));
return Err(anyhow::Error::from(e))
.with_context(|| format!("failed to create directory `{}`", path.display()));
}
}
Ok(())
Expand Down

0 comments on commit f7e7cc2

Please sign in to comment.