-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor error message when target
is a broken symlink
#12789
Comments
Thanks for the report. Sounds pretty reasonable to enhance that. @rustbot label +S-accepted +A-error -S-triage |
It seems a good-first-issue for me. I will give it a try. 😉 |
@rustbot claim I will try to support it. if you have any idea, please let me know. 😁 |
Hi, I found the code that trigger this issue. paths:::create_dir_all_excluded_from_backups_atomic
It will failed when In my opinion, the simple way is to add the err context like
In addition, it is necessary to check whether the symlink is valid? |
@weihanglo Hi bro, what do you think? |
@linyihai Could you please give an example output to help us to check the new error message? |
Hi @linyihai, that looks about right. One more improvement you can do is using
The above error message should be sufficient for people to find what caused the error. I don't feel like we need more checks here. |
make the
the detailed error message is missing. |
I think the final output will be like this:
I lean to keep the initial error.
|
Fair enough. Feel free to open a pull request. |
@linyihai Are you sure that that cargo/crates/cargo-util/src/paths.rs Line 695 in a9d71d2
create_dir_all(parent)? call above would fail before reaching that code.
|
cargo/crates/cargo-util/src/paths.rs Lines 435 to 443 in a9d71d2
|
Problem
When running
cargo build
, Cargo tries to output totarget
. Iftarget
is an ordinary file, or a symlink that points to one, this (naturally) fails with$ cargo build error: failed to create directory `/path/to/crate/target/debug` Caused by: Not a directory (os error 20)
However, if
target
is a broken symlink, Cargo prints a much less helpful error message:$ ln -s /a/b/c target # assuming /a/b/c doesn't exist on your machine $ cargo build error: Not a directory (os error 20)
The
error: failed to create directory
part of the error message has been lost.Steps
cargo init
target
symlink with e.g.,ln -s /a/b/c target
(assuming you don't actually have/a/b/c
on your computer)cargo build
Possible Solution(s)
Cargo should catch the broken
target
symlink and print the same error message it would iftarget
were an ordinary file.Notes
No response
Version
The text was updated successfully, but these errors were encountered: