Skip to content

cargo metadata should return default workspace members #8033

@sunshowers

Description

@sunshowers
Contributor

Describe the problem you are trying to solve

For a workspace, it is possible to specify default members through the workspace.default-members key. It would be great to expose this information through cargo metadata.

Describe the solution you'd like
The same format as workspace_members in cargo metadata -- a list of package IDs.

Activity

added
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
on Mar 23, 2020
sunshowers

sunshowers commented on Mar 24, 2020

@sunshowers
ContributorAuthor
charles-r-earp

charles-r-earp commented on Apr 15, 2023

@charles-r-earp
Contributor

I implemented this here https://github.com/charles-r-earp/cargo. I fixed one test "cargo_metadata_simple".

sunshowers

sunshowers commented on Apr 15, 2023

@sunshowers
ContributorAuthor

@charles-r-earp that looks great! you can probably submit that as a PR to this repo.

weihanglo

weihanglo commented on Apr 26, 2023

@weihanglo
Member

Hello all. Thanks for the proposal and the pull request. I'd like to know more about why default members in cargo metadata output is useful. Could you share some details?

Will do a simple FCP collecting options from the team then if it is reasonable.

(And sorry for the way too late reply 😅)

added
S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.
on Apr 26, 2023
sunshowers

sunshowers commented on Apr 26, 2023

@sunshowers
ContributorAuthor

A simple use case is writing a linter that triggers only on default workspace members. Without support for this, one has to manually scrape the root Cargo.toml.

charles-r-earp

charles-r-earp commented on Apr 26, 2023

@charles-r-earp
Contributor

Cargo extensions and dev tools will want to emulate cargo, like having options like --manifest-path, --workspace, --package, etc. There are tools to do this like clap_cargo + cargo_metadata which makes use of cargo metadata. This allows cargo-foo bar to operate on all workspace default members just like cargo check / build / test / etc.

weihanglo

weihanglo commented on Apr 26, 2023

@weihanglo
Member

Thank you all for sharing!

I propose adding workspace default member information to the output of cargo metadata, to make external plugins easier to align to Cargo's behavior.

One concern is that the size of the output grows overtime.

@rfcbot fcp merge

We don't need to wait for 10 days after the poll btw.

rfcbot

rfcbot commented on Apr 26, 2023

@rfcbot
Collaborator

Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

rfcbot

rfcbot commented on May 2, 2023

@rfcbot
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

added
S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review
and removed
S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.
on May 3, 2023
added a commit that references this issue on May 4, 2023
6240788
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-metadataS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewT-cargoTeam: Cargodisposition-mergeFCP with intent to mergefinished-final-comment-periodFCP complete

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @ehuss@sunshowers@weihanglo@rfcbot@charles-r-earp

      Issue actions

        `cargo metadata` should return default workspace members · Issue #8033 · rust-lang/cargo