-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve cargo add -F crate/invalid_feat
error discovery
#11100
Comments
I feel like this is the key to the problem that we should focus on.
Good call, we should probably not show the table like this. We should probably split up The error should probably follow our usual pattern of providing a suggestion if one exists and showing everything if one doesn't exist. |
One nice thing with providing the table, even on error, is that you can quickly see if you accidentally typoed or misremembered the feature flags name.
Perhaps for the attached example:
the error could be
what does this mean? |
I think that is also what the alternative I brought up does.
This is an example of an existing "not found" error in cargo: https://github.com/rust-lang/cargo/pull/10999/files |
so something like this?
I don't see how to do multiple errors from |
There are 3 scenarios
In what way are you wanting to do multiple errors? |
in the
I was thinking of something like https://docs.rs/color-eyre/latest/color_eyre/section/trait.Section.html#tymethod.with_error but already built-in, i.e emitting errors, not just one error. |
Hmm, I'm thinking we should start with a simpler error message and move on from there. We should just do |
I like the latter! Looks better and less noisy. |
While the long list is less cluttered, I feel like it undoes the goal of this Issue which is to draw more attention to the error itself. I would prefer the comma-separated list when things are long like this. |
You made me recall this auto-generated feature list. 1505 features in a Cargo.toml This may deserve a new issue if we want to address, along with other places with similar issues. |
@Emilgardis I think I prefer the first as the second is a bit more repetitive "available features" isn't actually available because its missing enabled features (its legal to specify already enabled features) |
should the naming be changed for |
We should either merge the lists of rename it to "disabled features". The thing I like about separate lists is that the disabled list is most likely what people will want to search through so this provides a way to shrink it down. |
awesome, I've implemented this in the original pr |
I think theres one more thing to do here, should probably clearly signal that the command failed, and that nothing was changed for the crate in the manifest Originally posted by @Emilgardis in #11098 (comment) There's also the consideration of providing typo helping, i.e if feature name is within levenshtein distance y of (an)other feature(s), provide a "help: did you mean feature_x?" or similar |
For me, I like to keep issues well scoped so they have a clear end. The goal here was to improve visibility of the error.
What isn't clear at the moment at least compared to any other cargo error?
Is this an actual point of confusion you had or theoretical? If its theoretical, I'd like confirmation on people actually being confused so we better understand what problem we are trying to solve and to understand how wide scoping it is across cargo commands. I would also personally see this in a distinct issue with its own discussion thread.
I see typo hints as a distinct issue. In addition, a dedicated issue would be useful as there is a lot of UX there'll probably be a lot of back and forth on how to make this look and having a dedicated thread for that would help keep everything straight. |
One way to interpret and interact with
if the disabled and enabled features are long, it could be easy to miss that
I've definitely had and have seen others have this problem of missing the fact that nothing was written with the previous error reporting, for me it's solved with the new way (and possibly because I now know the actual implementation) but I can see how it can be a bit confusing still. |
Problem
When using
cargo add -F crate/feat
, if thefeat
feature does not exist, the error is not presented until the end.This can be easy to miss, as most cargo warnings are presented with more context/text around them.
cargo add
however spits out a features table as if everything is ok and then presents an error.Proposed Solution
Attach more context in the output to clearly signal that "hey, this is not correct, check the error message"
Notes
this has been implemented in #11098, creating this per request.
The text was updated successfully, but these errors were encountered: