-
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
[metadata] Add workspace.dependencies
and <dep>.workspace
to cargo-metadata
(Rust 1.64+)
#11141
Comments
What is is you are wanting to do programmatically with the |
I wanted to write a little tool to see if a dependency was inherited or not from the workspace, and if its features matched the ones defined in |
Another example, for my PR on cargo-edit, it would avoid reading the manifest twice, once through the metadata to resolve the version and one manually to find if |
The cost of reading the manifest multiple times feels relatively small to me in the context of |
For this specific case yes, at least in terms of IOs. In terms of code, it's quite a few lines to check a boolean. It's also lots of duplicated code in each program that want to check this |
To give numbers to what @epage is saying: When working on workspace inheritance we found a case where Looking at the issue of duplicated code for any project that has to deal with this, I am not very concerned. There is always going to be some level of this across the ecosystem. I would be concerned that changing the |
We can make cargo-metadata changes without them being breaking, it just comes with a complexity and performance penalty to all other cargo-metadata users. We have to weigh these out in adding more content to cargo-metadata. Ideally, we would add a query language on top of it so people can request what they want. Even with that, in this case, it requires cargo to do extra book keeping to track the extra information about workspace inheritance. From there, the question is how much of a need is there for this to weigh the needs of these users against everything else. |
That's what concerns me the most. To correctly check a workspace, the procedure is
The last step is easy but could also be a one-line check if it was present in the metadata, at very little cost for cargo I believe since it already must check for this when computing the version itself
Yes, it could be I'm the only person needing this, in which case it's not very useful. I have seen at least one other tool (on Reddit r/rust I think ?) that moves workspace crates to |
I'm going to propose to the cargo team that we close this. This adds a lot of bookkeeping on cargo's side while being one of several forms of normalized information where we don't track the unnormalized form. The workaround (read each manifest) is relatively trivial (its what cargo does in |
Since dependencies are shown for each workspace member - as well as other bits of information like which features they are using or using the default features, etc. - wouldn't it be idiomatic to show whether that information was inherited from a workspace? I appreciate from #4018 that identifying the "current" package isn't always authoritative, but it seems every package in a workspace already has package-specific "attributes" to its dependency list. Identifying the "current" crate isn't too difficult nor worry me too much with duplicative effort, but parsing dependencies for all the current and possible future permutations as @poliorcetics eludes to is something it seems either |
I don't see how this is a question of what is "idiomatic". It puts a big compatibility burden on us to show a partially-normalized form. There is also the question of how normalized
For any of these questions, this would also require us adding all of this bookkeeping to cargo so we can present it. |
Problem
cargo metada
does not show the workspace dependencies nor if a dependency is inherited from the workspace in its output.Proposed Solution
Add the missing metadata to the output.
Notes
We should also remember to update oli-obk/cargo_metadata at the same time to make it immediately available to most people
The text was updated successfully, but these errors were encountered: