Cargo with local crates.io mirror

⚓ Rust    📅 2025-11-05    👤 surdeus    👁️ 17      

surdeus

We try to achieve CI builds without internet access for our Rust projects. crates.io was mirrored by artifactory and rustup by panamax.
The first job in our CI pipeline installs Rust and after that, we try to install some cargo tools with cargo install. This fails, as cargo tries to reach out for crates.io:

cargo install --locked --index=sparse+https://cargo.packages.mycompany.net/artifactory/api/cargo/crates-io/index/ cargo2junit
    Updating `sparse+https://cargo.packages.mycompany.net/artifactory/api/cargo/crates-io/index/` index
 Downloading crates ...
  Downloaded cargo2junit v0.1.14 (registry `sparse+https://cargo.packages.mycompany.net/artifactory/api/cargo/crates-io/index/`)
  Installing cargo2junit v0.1.14 (registry `sparse+https://cargo.packages.mycompany.net/artifactory/api/cargo/crates-io/index/`)
    Updating crates.io index
warning: spurious network error (1 tries remaining): [28] Timeout was reached (Connection timed out after 60004 milliseconds)
error: failed to get `junit-report` as a dependency of package `cargo2junit v0.1.14 (registry `sparse+https://cargo.packages.mycompany.net/artifactory/api/cargo/crates-io/index/`)`
Caused by:
  download of config.json failed
Caused by:
  failed to download from `https://index.crates.io/config.json`
Caused by:
  [28]

As can be seen from the trace, I set up a ~/.cargo/config.toml with the local crates.io mirror. I expected cargo to get the index from this mirror, not from crates.io. Is this a bug?

5 posts - 2 participants

Read full topic

🏷️ Rust_feed