-
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
cargo info
reads local crate instead of crates.io when running from the crate directory
#14810
Comments
@Rustin170506 unsure how to word the documentation besides just not saying where its coming from. |
Then I'm assuming the intent is to prefer the local crate if it exists. That's already good to know, because then I know I can always specify |
Yes, it was intentional though I don't remember why we chose that behavior. Another aspect dependent on your local project is what version is shown. It will prefer versions in your lockfile (and maybe also versions compatible with your MSRV?). This is purely meant to be a UX command and tries to give the information that can be assumed to be most helpful for the user.
If you are parsing the output, understand that the output is not a stable format intended for programmatic use. We can change pretty much anything about it without it being a breaking change. |
Ok, that would be an issue. However, with some quick testing, it seems that using
Yes, this is fine by me. I checked for a -cargo search "$name" | sed -n '1s/^'"$name"' = "\([0-9.]*\)".*$/\1/p'
+cargo info --registry=crates-io -q "$name" | sed -n 's/^version: //p' |
Problem
I naively expected that
cargo info
would always show information from crates.io (as its documentation suggests). However, it seems thatcargo info foo-bar
would not show information from crates.io if running from the directory of cratefoo-bar
itself. One has to explicitly pass--registry=crates-io
to obtain information from crates.io.Steps
Cargo.toml
file.cargo info foo-bar
(wherefoo-bar
is thepackage.name
value in theCargo.toml
file).Expected: It will contact crates.io and show information from there.
Actual: It reads and show information from the local crate.
Possible Solution(s)
Either update the documentation to mention that local crate is favored. Or always fetch from crates.io.
Notes
cargo help info
shows:It mentions things like
package
(something published on crates.io) andcrates.io
. It doesn't say that it will read the local file system.Version
The text was updated successfully, but these errors were encountered: