{"id":"fb7e912881c6c0ad","repo":"rust-lang/cargo","slug":"config-json-not-found","errorCode":null,"errorMessage":"config.json not found","messagePattern":"config\\.json not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/sources/registry/http_remote.rs","lineNumber":102,"sourceCode":"        source_id: SourceId,\n        gctx: &'gctx GlobalContext,\n        name: &str,\n    ) -> CargoResult<HttpRegistry<'gctx>> {\n        Ok(HttpRegistry {\n            name: name.into(),\n            registry_config: Mutex::new(None),\n            inner: HttpBackend::new(source_id, gctx, name)?,\n        })\n    }\n\n    fn inner(&self) -> &HttpBackend<'gctx> {\n        &self.inner\n    }\n\n    /// Get the registry configuration from either cache or remote.\n    async fn config(&self) -> CargoResult<RegistryConfig> {\n        let Some(config) = self.config_opt().await? else {\n            return Err(anyhow::anyhow!(\"config.json not found\"));\n        };\n        Ok(config)\n    }\n\n    /// Get the registry configuration from either cache or remote.\n    /// Returns None if the config is not available.\n    async fn config_opt(&self) -> CargoResult<Option<RegistryConfig>> {\n        let mut config = self.registry_config.lock().await;\n        if let Some(config) = &*config\n            && self.inner().is_fresh(RegistryConfig::NAME)\n        {\n            Ok(Some(config.clone()))\n        } else {\n            let result = self.config_opt_inner().await?;\n            *config = result.clone();\n            Ok(result)\n        }\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/sources/registry/http_remote.rs#L84-L120","documentation":"The HTTP/sparse registry exposes a `config.json` at its index root describing protocol version, supported fields, and auth requirements. `HttpRegistry::config()` (src/sources/registry/http_remote.rs:100) calls `config_opt()` and, when it yields `None` (no config could be fetched or read from cache), returns this error. Without `config.json` the sparse registry cannot proceed.","triggerScenarios":"A sparse registry URL (`sparse+https://...`) whose server doesn't serve `config.json` (404/403/5xx); first contact with a sparse registry while offline so the file was never cached; a typo'd sparse index URL pointing at a non-registry host; TLS / proxy / DNS failure contacting the index root.","commonSituations":"Pointing a `[registries]` entry at a `sparse+https://` URL that isn't actually a sparse registry; a private registry server misconfigured to omit `config.json`; corporate proxy blocking the index host; offline build that never populated the cached config.","solutions":["Open the index URL in a browser/curl and confirm `config.json` is served with HTTP 200 and valid JSON.","If the registry is not sparse-capable, drop the `sparse+` prefix (use the git index protocol) or switch to a host that supports sparse.","Fix network/proxy/TLS issues so the index root is reachable; remove a stale/empty cached config under `~/.cargo/registry/index/` and retry online.","For a private registry, ensure auth credentials (`CARGO_REGISTRIES_<name>_TOKEN` / `[registries.<name>]`) are valid — a 401 can manifest as no config."],"exampleFix":"# before\n[registries.my-reg]\nindex = \"sparse+https://example.com/index/\"   # server returns 404 for config.json\n\n# after: use the real sparse-capable index (or drop sparse+)\n[registries.my-reg]\nindex = \"sparse+https://index.example.com/\"","handlingStrategy":"validation","validationCode":"# Verify the sparse registry actually serves config.json before configuring it.\ncurl -fsS \"<index-url>/config.json\" | head\n# (HTTP 200 + valid JSON => safe to use as sparse+<index-url>)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm `config.json` is reachable before pointing cargo at a `sparse+` URL.","Provide valid auth for private registries so 401 doesn't masquerade as missing config.","Populate the cached config online before attempting offline builds."],"tags":["cargo","registry","sparse","config","network"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}