Skip to content

Alternative registries should be allowed to be local sources #17070

@CAD97

Description

@CAD97

Problem

If you have a set of crates in local registry or directory source formats that is not a direct mirror/vendor of a hosted crate repository, it's currently required to specify both an alternative registry with a placeholder index URI and source replacement to redirect the registry to the local files, e.g.:

[registries.debian]
index = "file:///usr/share/cargo/index/" # placeholder; does not exist
[source.debian]
registry = "file:///usr/share/cargo/index/"
replace-with = "debian-local"
[source.debian-local]
directory = "/usr/share/cargo/registry/"

Proposed Solution

It should be possible to directly define an alternative registry that uses a local source format, e.g.:

[registries.debian]
directory = "/usr/share/cargo/registry/"

A related but orthogonal improvement in this space would be to automatically define a default value for sources.{registry}.registry when registries.{registry}.index is set.

Notes

Defining a registry source and defining an alternative registry have a lot of overlap. crates-io is privileged in that it's the default registry, but also that sources.crates-io.registry is predefined, so source overriding it only requires setting sources.crates-io.replace-with, unlike for any alternative registry.

Packaging Rust crates for Debian currently does so using source replacement of the crates-io registry despite also carrying (sometimes non-negligible) patches to the upstream crate sources. I'm not sure the exact reason why they do this, but reducing the overhead of properly utilizing an alternative registry seems like a good idea independent of whether Debian adopts it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-directory-sourceArea: directory sources (vendoring)A-local-registry-sourceArea: local registry sources (vendoring)C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions