How to force cargo to use an internal server? (registry)

⚓ Rust    📅 2025-08-11    👤 surdeus    👁️ 4      

surdeus

Question:

How can I force cargo to NOT use "https://cargo.io" - and instead use my specified URL?

Why?
I am working in an "closed" or "air gapped environment" -I have no internet connection.
I am setting up my own internal "crates.io" mirror.

Step 1:
Any time cargo goes to the web, I need it to use MY URL not https://crates.io
This does not seem to work, and I need to understand why so I can fix it.

I am using: cargo 1.88.0 (873a06493 2025-05-10)

Documentation I am following is this:

 https://doc.rust-lang.org/cargo/reference/config.html

This states that I can create two entries in ${CARGO_HOME}/config.toml
that should be sufficient to make cargo use my server instead, below is the output of:

bash$ cat $CARGO_HOME/config.toml

Output:

[registry]
default="local-registry"

[registries]
local-registry={ index="http://localhost:8080" }

It is my understanding that this should override default: 'https://crates.io" with my replacement server URL and have cargo use my-registry for all things.

However.. cargo ignores this. Thus I am stuck at square 1.

cargo download -v ahash

Note the: -v option which means verbose... What I see in the debug output is this:

D2025-08-11T04:40:28.0104Z main#160] Fetching latest matching version of crate `ahash=*` from https://crates.io/api/v1/crates/ahash/versions

Which tells me that Cargo is NOT honoring the default setting and not going to my server.

How do I make cargo use MY URL instead?

1 post - 1 participant

Read full topic

🏷️ Rust_feed