rust-lang/cargo · error
the `registry.index` config value is no longer…
Error message
the `registry.index` config value is no longer supported Use `[source]` replacement to alter the default index for crates.io.
What it means
Cargo no longer supports the `registry.index` configuration value; check_registry_index_not_set fails fast whenever it is present. Users must instead use a `[source]` replacement table to redirect the default crates.io index. This is an intentional deprecation error to migrate users to the source-replacement mechanism.
Solutions
- Delete the `registry.index` key from the config file named in the error.
- If you need a different index, add a source replacement: [source.crates-io] replace-with = "my-mirror" plus a [source.my-mirror] registry = "..." section.
- Re-run the cargo command to confirm the deprecation error is gone.
Example fix
// before: ~/.cargo/config.toml [registry] index = "https://my-mirror.example.com/registry" // after: ~/.cargo/config.toml [source.crates-io] replace-with = "my-mirror" [source.my-mirror] registry = "https://my-mirror.example.com/registry"
Defensive patterns
Strategy: validation
Validate before calling
// grep all config scopes before running cargo for f in /etc/cargo/config ~/.cargo/config.toml .cargo/config.toml; do grep -n 'index' "$f" 2>/dev/null | grep -i registry && echo "remove registry.index in $f" done
Try / catch
match config.check_registry_index_not_set() {
Err(e) if e.to_string().contains("registry.index") => {
// migrate to [source] replacement, then retry
}
other => other?,
} Prevention
- Audit old config files when upgrading Cargo; `registry.index` was removed long ago.
- Use [source.crates-io] replace-with for mirrors, never registry.index.
- Pin CI images to a config-audited state so stale global config never leaks in.
When it happens
Trigger: Calling check_registry_index_not_set (invoked during registry-dependent operations like cargo publish/login) when any config source defines `registry.index` — e.g. a `[registry]` section containing `index = "..."`, or the corresponding `CARGO_REGISTRY_INDEX`-style environment config.
Common situations: Older pre-2018 .cargo/config files written for legacy Cargo carrying over to modern Cargo; corporate mirror setups copied from outdated docs; CI images with stale global cargo config.
Understand the failure class
Background: "is deprecated and will be removed" — deprecation warnings for old API names, keywords, and options, and how to migrate before the removal release — this error's family across 29 libraries.
Related errors
- config.json not found
- found patches and a path override
- patch for ` ` in ` ` resolved to more than one…
- patch for ` ` points to the same source, but patches must…
- patch location ` ` does not contain packages matching `…
AI-assisted analysis of rust-lang/cargo@98a09e7e7d (2026-09-22).
Data as JSON: /api/errors/2d535d5f6a412a52.
Report an issue: GitHub.
Appendix: source
Thrown at src/context/mod.rs:1719
if let Some(index) = self.get_string(["registries", registry, "index"])? {
self.resolve_registry_index(&index).with_context(|| {
format!(
"invalid index URL for registry `{}` defined in {}",
registry, index.definition
)
})
} else {
bail!(
"registry index was not found in any configuration: `{}`",
registry
);
}
}
/// Returns an error if `registry.index` is set.
pub fn check_registry_index_not_set(&self) -> CargoResult<()> {
if self.get_string(["registry", "index"])?.is_some() {
bail!(
"the `registry.index` config value is no longer supported\n\
Use `[source]` replacement to alter the default index for crates.io."
);
}
Ok(())
}
fn resolve_registry_index(&self, index: &Value<String>) -> CargoResult<Url> {
// This handles relative file: URLs, relative to the config definition.
let base = index
.definition
.root(self.cwd())
.join("truncated-by-url_with_base");
// Parse val to check it is a URL, not a relative path without a protocol.
let _parsed = index.val.into_url()?;
let url = index.val.into_url_with_base(Some(&*base))?;
if url.password().is_some() {
bail!("registry URLs may not contain passwords");View on GitHub (pinned to 98a09e7e7d)