Skip to content

Add a --no-implicit-publish flag to cargo publish --workspace #16139

@t-moe

Description

@t-moe

Problem

We use cargo publish --workspace in our CI/CD pipeline to release multiple crates.

The problem is that newly added workspace members inherit the default publish behavior, equivalent to not setting the publish field at all. For example, if a user adds a new test or example crate (e.g., via cargo add hil-tests, which sets publish = null), our pipeline attempts to publish it unintentionally.

Proposed Solution

To prevent accidental publication of crates that haven't explicitly opted into being published, we request a new flag for cargo publish (e.g., --no-implicit-publish). When this flag is used, cargo publish should fail (bail) if any crate being considered for publishing does not have an explicit publish setting of either publish = false or a specific list of registries (e.g., publish = ["my-registry"]). This would force developers to make an explicit decision about publication status, significantly reducing the risk of accidental releases.

Notes

No response

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-publishS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions