-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-configurationArea: cargo config files and env varsArea: cargo config files and env varsA-gitArea: anything dealing with gitArea: anything dealing with gitC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
Description
Problem
When depending on custom registries over Git, the URL to the registry is lost, forcing the user to redefine it in its own .cargo/config.toml.
This put the responsibility on the consumer to know about the custom registries of its Git dependencies.
This also allow some "man on the middle" trick by providing another second level dependency by defining same registry name with different URL in the consumer .cargo/config.toml.
Steps
- 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" }
- 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
- 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
Possible Solution(s)
One possible solution will be to resolve dependency url using the .cargo/config.toml at the level the dependency is defined.
Notes
If crate-b -> crate-a -> some-crate only involves Git resolver or custom registry there is no issue.
Only happens when Git and Custom registry are mixed.
Version
cargo 1.86.0 (adf9b6ad1 2025-02-28)
release: 1.86.0
commit-hash: adf9b6ad14cfa10ff680d5806741a144f7163698
commit-date: 2025-02-28
host: x86_64-unknown-linux-gnu
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.12.0-DEV (sys:0.4.79+curl-8.12.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w 11 Sep 2023
os: Debian 12.0.0 (bookworm) [64-bit]
Metadata
Metadata
Assignees
Labels
A-configurationArea: cargo config files and env varsArea: cargo config files and env varsA-gitArea: anything dealing with gitArea: anything dealing with gitC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.