-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Better error message on Flycheck Error message #11891
Better error message on Flycheck Error message #11891
Conversation
I think it should only show that hint when you actually configured rust-analyzer to use clippy. |
Ye we use |
This is strange. In my currently configured setup (Devcontainer/Codespaces) I do not have Here's the Dockerfile for my Devcontainer (it's rather simple):
Thanks in advance! NINJA EDIT: "rust-analyzer.checkOnSave.command": "clippy" was tucked in Devcontainer's Sorry for any trouble |
Good to know you figured out why :)
If not that's fine then I'll do that in a bit, just wanna know if we can close this PR otherwise. |
@Veykril I am going to try to make it emit stderr. Updating this PR in a few. Thank you for the patience! (I'm looking to learn more and more about Rust in general 🙏 ) |
@Veykril as requested, the PR has been updated and we are now outputting the contents of stderr together with the final error message. Thank you for your time in reviewing this! |
cargo clippy
clippy
as the checker)
crates/flycheck/src/lib.rs
Outdated
"Cargo watcher failed, the command produced no valid metadata (exit code: {:?})", | ||
output.status | ||
"Cargo watcher failed, the command produced no valid metadata (exit code: {:?})\nCargo's stderr output:\n{}", | ||
output.status, from_utf8(&output.stderr).unwrap_or("(Error: Could not fetch Cargo's stderr output)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use from_utf8_lossy instead? That is infallible. In any case the error should say that the stderr is not valid UTF-8 if you keep using from_utf8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to use output.stderr
here, we use streaming_output
to fill in the error output into the error
local here which is what contains the error (See the Err(e)
branch below this one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! |
clippy
as the checker)
I have commented on this S-unactionable issue that the Flycheck error message should maybe provide a hint about what tool it actually runs. Searching on some places on the Internet I've found multiple people, including myself, losing copious amounts of time on the same issue. So I've decided to make this very small PR :-)
From an user experience standpoint, the current error message is unhelpful to the end user, because the end user does not know exactly what it needs to check/fix (outdated, broken, or missing
cargo clippy
). In my own case,cargo clippy
was actually missing altogether (developing offrust:1.59.0-bullseye
official Docker image).Thanks in advance!