Better error message when registry is added to Cargo.toml instead of Cargo config #12576
Labels
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
A-registries
Area: registries
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
S-accepted
Status: Issue or feature is accepted, and has a team member available to help mentor or review
Problem
Alternative registries are added in Cargo-config (e.g.
~/.cargo/config.toml
), not in a project'sCargo.toml
file.If a registry is added in
Cargo.toml
but not used, a helpful warning is printed:If, however, a dependency is added that uses the alternate registry, only an error message is shown:
This is actually somewhat confusing: I initially didn't notice that the
dependencies
section belongs in a different file, so when I got this error, I thought it was a problem with the registry URL or syntax.Proposed Solution
Multiple possible solutions, with different levels of effort:
no index found
message to explicitly mentionconfig.toml
. For instance, it could be reworded asregistry index was not found in any config.toml
fileunused manifest keys
warning even if the manifest fails to parse (I'm not sure how easy this would be)no index found
message occurs, explicitly check to see ifCargo.toml
has aregistries
section, and if so, print a separate error message, something like "registries
must be defined inconfig.toml
; see https://doc.rust-lang.org/cargo/reference/config.html"registries
to be in eitherconfig.toml
orCargo.toml
(I'm assuming there's a good reason for not doing this, though).Notes
No response
The text was updated successfully, but these errors were encountered: