How to configure crates.io mirror through environment variables

Normally if you want use a mirror instead of crates.io, you configure it in .cargo/config.toml:

[source.crates-io]
replace-with = "mirror-local"

[registries.mirror-local]
index = "http://mirror.local/rust/crates.io-index"

I need to configure it through environment variables (I'm running renovate which doesn't allow me to set the .cargo/config.toml file).
I've tried to override the crates.io url with CARGO_REGISTRIES_CRATES_IO_INDEX=http://mirror.local/rust/crates.io-index but cargo still tries to use crates.io.

Is there another way I can configure this?

Are you sure? The docs state that the renovate bot can read Cargo configuration files:

That would work, but I'm trying to configure it globally.
Otherwise we would need to add the config file to every Rust repository we have.

You can define global configuration files:

1 Like

That works, thanks!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.