-
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-metadata always resolves features at the workspace level #7754
Comments
Are there any workarounds for this? |
A possible workaround for this issue is to create a dedicated package where you run |
For the solution, could we instead (or in addition? idk which) make a |
There are two fundamental problems here
|
It would be entirely backwards-compatible to add a new argument (
It sounds like this is a separate problem from this issue ticket, since we already can run into this problem with just build vs. normal dependencies being different in an existing workspace. Idk what the appropriate resolution is (I can't think of anything backwards-compatible with the current output), but it sounds like that can be worked on separately from my requested feature, as it will happen either way. |
By adding a
While these both tackle different problems, I see it rare that someone will want one without the other. If we have to rev the message format, we should be doing it at once. |
I'm unclear what you mean by "it doesn't behave like them"? All the other tools I can think of that take a
I don't think my proposal requires changing the message format? The output still looks the same, just providing the new flag adjusts the contents presented therein to only show some of the packages in a workspace, so I think it should be compatible with the existing output format (any existing tooling won't supply a |
What happens without The standard cargo behavior is to use the package for the discovered / specified manifest. When encountering a virtual workspace, the default members are selected (with "all" as a fallback). There are exceptions
One way we can workaround the CLI behavior is to rev the message format (one behavior for v1, another for v2). |
Any progress to this ? |
In my personal opinion, based on the above information, changing However, rust-lang/rfcs#3553 is somewhat like a "unit graph" of what was built. If that works for your use case, then that might be a good alternative. If this is for planning purposes, then we need a different solution and would need more information on how that fits into things. This would likely best be done on a different issue that is more focused on your need than this as this has a fairly specific scope. |
Thanks for your comments.
I found the cargo_util_schemas crate that can be used to Serialize/Deserialize. |
And the name for |
Problem
cargo-metadata
appears to always resolve features at the "workspace" level, rather than for root crate. This means thatcargo metadata
will report features as enabled that aren't actually whencargo build
is run in the same directory.Steps
cargo metadata --format-version 1 --manifest-path postgres-derive/Cargo.toml | jq '.resolve.nodes|.[]|select(.id|test("postgres-types"))'
.postgres-types
has thederive
andpostgres-derive
features enabled even though they are off by default for that crate. Thepostgres-derive-test
crate in the same workspace enables that feature, which I assume is where that's coming from:Possible Solution(s)
cargo metadata
should respect the root crate when resolving the crate graph.Notes
Output of
cargo version
: cargo 1.41.0-nightly (19a0de2 2019-12-12)The text was updated successfully, but these errors were encountered: