Skip to content

Allow different registries for push and pull when publishing workspaces #17282

Description

@Ruhrpottpatriot

Problem

We have an internal package that also uses derive macros. Therefore we use a cargo workspace with the main crate as workspace root and the derive crate inside of that, see this exemplary cargo.toml:

[package]
name = "foobar"
version = "0.5.0"
edition = "2024"

[features]
derive = ["dep:derive"]

[dependencies]
derive = { version = "=0.5.0", path = "./derive", optional = true, registry = "local" }

[workspace]
members = ["", "derive"]

We want to publish both crates to the private registry. However, the "local" registry is a group registry containing a proxy for crates.io and the registry for internal packages (for those interested: The product is Sonatype Nexus), meaning we can't directly push to the registry itself. Therefore we push to a "local-push" registry, which is part of the above group registry.

The problem now is, when we set the "derive" crate to pull from the group registry, but then use "cargo publish --workspace --registry local-push", the publish fails with an error, because cargo tries to pull dependencies from "local".

Proposed Solution

Allow users to use any registry to push to, even if the dependency has a different registry set as source. Assume that if a package is not found in the pull registry, that it also doesn't exist in the push registry. To prevent syncing issues, add a "--delay {seconds}" flag that spaces calls to cargo publish by the given amount.

Notes

No response

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-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