{"record":{"id":"2d535d5f6a412a52","repo":"rust-lang/cargo","slug":"the-registry-index-config-value-is-no-longer-supported-use","errorCode":null,"errorMessage":"the `registry.index` config value is no longer supported\nUse `[source]` replacement to alter the default index for crates.io.","messagePattern":"the `registry\\.index` config value is no longer supported\nUse `\\[source\\]` replacement to alter the default index for crates\\.io\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/context/mod.rs","lineNumber":1719,"sourceCode":"        if let Some(index) = self.get_string([\"registries\", registry, \"index\"])? {\n            self.resolve_registry_index(&index).with_context(|| {\n                format!(\n                    \"invalid index URL for registry `{}` defined in {}\",\n                    registry, index.definition\n                )\n            })\n        } else {\n            bail!(\n                \"registry index was not found in any configuration: `{}`\",\n                registry\n            );\n        }\n    }\n\n    /// Returns an error if `registry.index` is set.\n    pub fn check_registry_index_not_set(&self) -> CargoResult<()> {\n        if self.get_string([\"registry\", \"index\"])?.is_some() {\n            bail!(\n                \"the `registry.index` config value is no longer supported\\n\\\n                Use `[source]` replacement to alter the default index for crates.io.\"\n            );\n        }\n        Ok(())\n    }\n\n    fn resolve_registry_index(&self, index: &Value<String>) -> CargoResult<Url> {\n        // This handles relative file: URLs, relative to the config definition.\n        let base = index\n            .definition\n            .root(self.cwd())\n            .join(\"truncated-by-url_with_base\");\n        // Parse val to check it is a URL, not a relative path without a protocol.\n        let _parsed = index.val.into_url()?;\n        let url = index.val.into_url_with_base(Some(&*base))?;\n        if url.password().is_some() {\n            bail!(\"registry URLs may not contain passwords\");","sourceCodeStart":1701,"sourceCodeEnd":1737,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/context/mod.rs#L1701-L1737","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: ~/.cargo/config.toml\n[registry]\nindex = \"https://my-mirror.example.com/registry\"\n\n// after: ~/.cargo/config.toml\n[source.crates-io]\nreplace-with = \"my-mirror\"\n\n[source.my-mirror]\nregistry = \"https://my-mirror.example.com/registry\"","handlingStrategy":"validation","validationCode":"// grep all config scopes before running cargo\nfor f in /etc/cargo/config ~/.cargo/config.toml .cargo/config.toml; do\n  grep -n 'index' \"$f\" 2>/dev/null | grep -i registry && echo \"remove registry.index in $f\"\ndone","typeGuard":null,"tryCatchPattern":"match config.check_registry_index_not_set() {\n    Err(e) if e.to_string().contains(\"registry.index\") => {\n        // migrate to [source] replacement, then retry\n    }\n    other => other?,\n}","preventionTips":["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."],"tags":["config","deprecation","registry","cargo"],"backgroundTag":"deprecated-api-usage","analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-09-22T13:55:30.201Z","contentChangedAt":"2026-09-22T13:55:30.201Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}