Skip to content

Custom registries are infectious to downstream dependents #12271

@w4

Description

@w4

Problem

When depending on custom registries over Git, the consumer is currently expected to also have a reference to the same registry in their .cargo/config.toml.

Steps

  1. crate-a containing:
    $ cat Cargo.toml
    [package]
    name = "crate-a"
    version = "0.1.0"
    edition = "2021"
    
    [dependencies]
    some-crate = { version = "0.1", registry = "some-registry" }
    
    $ cat .cargo/config.toml
    [registries]
    some-registry = { index = "ssh://registry.x.com/path/to/some-registry" }
    
  2. crate-b containing:
    $ cat Cargo.toml
    [package]
    name = "crate-b"
    version = "0.1.0"
    edition = "2021"
    
    [dependencies]
    crate-a = { version = "0.1", git = "https://git.x.com/path/to/crate-a" }
    
    $ cat .cargo/config.toml
    cat: .cargo/config.toml: No such file or directory
    
  3. Compiling crate-b gives the cryptic error:
    error: no matching package named `crate-a` found
    location searched: https://git.x.com/path/to/crate-a
    
  4. Which can be fixed by adding
    [registries]
    some-registry = { index = "ssh://registry.x.com/path/to/some-registry" }
    
    to crate-b's .cargo/config.toml

Possible Solution(s)

Potentially a flag that can be set in the dependent's .cargo/config.toml to allow git dependencies to use arbitrary registries?

Notes

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-crate-dependenciesArea: [dependencies] of any kindA-registriesArea: registriesC-bugCategory: bugS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    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