Skip to content

cargo publish should default to alt registry if defined in Cargo.toml #8036

@lily-mara

Description

@lily-mara

When working with multiple Rust projects, some private and some public, it can be frustrating to remember where each package needs to be published. Currently, cargo publish defaults to crates.io. This is a great default for public packages that will be used across the community. However, many companies want to use private Rust packages for writing internal tools/libraries.

Currently, Cargo.toml supports the lib.publish field to limit publishing to one or more registries. This prevents cargo from publishing private packages to crates.io, which is a great feature. I propose a slight augmentation to cargo publish's default behavior. If Cargo.toml's lib.publish field contains a single registry, then cargo publish should default to publishing to this registry. This makes the default publish command cargo publish for every package, no matter where it's being published to.

The "single value" limitation could also be lifted, and cargo publish could publish to every registry defined in the lib.publish field, but that seems like more of a surprise than this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-registriesArea: registriesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-publish

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions