-
Notifications
You must be signed in to change notification settings - Fork 14
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
Mismatch between cargo pkgid
and cargo metadata
(and human-readable names)
#55
Comments
As far as I can tell, there is no way to map theses. The next best thing I can think of is trying to get Internally, |
The "package_id" field in
cargo metadata
is not a valid package id specification.Take the output of
cargo metadata | jq '.packages[0].id'
of your local crate. I get"abort_on_panic 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)"
This is not a valid package id specification (
cargo pkgid
fails). The correct equivalent is "https://github.com/rust-lang/crates.io-index#abort_on_panic:2.0.0".How are we supposed to convert back and forth between these two seemingly incompatible formats? To go from
cargo pkgid
->cargo metadata
, I had to re-implement my own matching logic and search back over the metadata :(Human Redable package ids
Say I have a
cargo_metadata::PackageId
.How do I print this back to the user as a
cargo pkgid
?The simple answer is to print back the crate's name. In most cases this is unambiguous. Right now (in my current crate)
syn
refers unambiguously to a single version. That's goodBut that doesn't work if there are multiple versions of the crate. What if we have
libc:0.1.12
and alsolibc:0.2.109
?At this point, a simple "print package name" is not a good way to output a
PackageId
, becauselibc
would be ambiguous.In addition
cargo pkgid
supports arbitrary urls likehttps://github.com/Techcable/my-library#0.2.0-alpha.5
. Version + name could be ambiguous in the presence of git dependencies :(You don't want to have to output a full
https://github.com/rust-lang/crates.io-index#syn:1.0.82
whensyn
is unambiguous, but you also want to be able to handle the ambiguity when it comes out.Workarounds
As a hack to workaround the lack of
cargo pkgid --short <pkg>
in mycargo outdir
tool, I had to write a post-processing pass pass to analyze for potential conflicts. Then I had to normalize cargo metadata ids back to the minimal package id.Once again this is made more difficult to
cargo_metadata::PackageId
using a non-standard format that is incompatible withcargo pkgid
, it's also super difficult to go from package ids -> human readable "short" package ids.So there are there two problems :(
The text was updated successfully, but these errors were encountered: