-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Error message when trying to remove a typo'd dependency could be clearer #16499
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-addS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or review
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
When using
cargo remove, specifying a dependency name that is not present inCargo.tomlresults in an error message suggesting the "closest" package by name.Currently, if
foois a dependency:$ cargo remove fo Removing fo from dependencies error: the dependency `fo` could not be found in `dependencies`; dependency `foo` existsThe "dependency
fooexists" part is unclear, particularly if the crate name is longer and the typo in the command is not noticed right away.It comes from
cargo/src/cargo/util/toml_mut/manifest.rs
Line 686 in 6d1bd93
Proposed Solution
Option 1
Change the message to something such as "Did you mean...?"
$ cargo remove fo Removing fo from dependencies error: the dependency `fo` could not be found in `dependencies`; Did you mean `foo`?Option 2
Use
closest_msg$ cargo remove fo Removing fo from dependencies error: the dependency `fo` could not be found in `dependencies` help: a dependency with a similar name exists: fooNotes
Option 2 is closer to the compiler's message if you typo a variable name.