Skip to content

Stability of cargo metadata output #10424

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

Closed
Person-93 opened this issue Feb 25, 2022 · 3 comments
Closed

Stability of cargo metadata output #10424

Person-93 opened this issue Feb 25, 2022 · 3 comments
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug Command-metadata

Comments

@Person-93
Copy link

Problem

The output of cargo metadata --format-version=1 is a bit different in beta. For optional dependency foo, it adds "foo" = ["dep:foo"] to the feature list. This breaks one of my crates that reads the output it.

Steps

Run cargo +beta metadata --fomat-version=1 in any workspace with optional dependencies.

Possible Solution(s)

Define and document a policy for what type of changes are allowed in the output without requiring a bump to the format version argument.

Notes

The crate in question is a CI tool for running a cargo command repeatedly with all valid sets of features. It reads the metadata so that it doesn't run the two extra times for features that are dependencies of other features. As of now, it makes its list of feature sets by reading the features field to get the list of features and their dependencies, and the dependencies field to get the list of optional dependencies.
With the beta version, are all optional dependencies guaranteed to show up in the feature list?

Version

cargo 1.60.0-beta.1 (ea2a21c 2022-02-15)
release: 1.60.0-beta.1
commit-hash: ea2a21c994ca1e4d4c49412827b3cf4dcb158b1d
commit-date: 2022-02-15
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1m)
os: Debian 11 (bullseye) [64-bit]
@Person-93 Person-93 added the C-bug Category: bug label Feb 25, 2022
@ehuss
Copy link
Contributor

ehuss commented Feb 27, 2022

It definitely would be great to clarify the documentation for how things can change. In general, new versions may introduce new fields. The change in value formats is a little more nebulous, so it might be difficult to specify exactly what can and can't change. The types of the values won't change (like for example, a string won't change to an array), but the contents might (for example, if cargo ever adds a new dependency kind, then the "kind" could add a new value).

@ehuss ehuss added A-documenting-cargo-itself Area: Cargo's documentation Command-metadata labels Feb 27, 2022
@Person-93
Copy link
Author

I think the important thing is that the values can be used the same way, although that might be a bit nebulous as well.
My crate reads the features from the manifest and then compiles and runs the tests with different combinations of features. The problems is that the new dependencies can't be passed to cargo as part of the feature list.

@weihanglo
Copy link
Member

#12313 is an effort of this, and for external tool maintainers we occasionally post announcement that may potentially break tools on Zulip t-cargo/build-integration. Please subscribe if you're interested.

#12377 is also relevant however regarding --message-format=json.

Close as resolved via #12313. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation C-bug Category: bug Command-metadata
Projects
None yet
Development

No branches or pull requests

3 participants