{"id":"10cc32d1fc5c22ed","repo":"rust-lang/cargo","slug":"remote-registries-must-have-config","errorCode":null,"errorMessage":"remote registries must have config","messagePattern":"remote registries must have config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/registry/mod.rs","lineNumber":147,"sourceCode":") -> CargoResult<(Registry<RegistryClient<'gctx>>, RegistrySource<'gctx>)> {\n    let is_index = reg_or_index.map(|v| v.is_index()).unwrap_or_default();\n    if is_index && token_required.is_some() && token_from_cmdline.is_none() {\n        bail!(\"command-line argument --index requires --token to be specified\");\n    }\n    if let Some(token) = token_from_cmdline {\n        auth::cache_token_from_commandline(gctx, &source_ids.original, token);\n    }\n\n    let src = RegistrySource::remote(source_ids.replacement, gctx)?;\n    let cfg = {\n        let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;\n        // Only update the index if `force_update` is set.\n        if force_update {\n            src.invalidate_cache()\n        }\n        crate::util::block_on(src.config())\n            .with_context(|| format!(\"failed to update {}\", source_ids.replacement))?\n            .expect(\"remote registries must have config\")\n    };\n    let api_host = cfg\n        .api\n        .ok_or_else(|| format_err!(\"{} does not support API commands\", source_ids.replacement))?;\n    let token = if token_required.is_some() || cfg.auth_required {\n        let operation = token_required.unwrap_or(Operation::Read);\n        Some(auth::auth_token(\n            gctx,\n            &source_ids.original,\n            None,\n            operation,\n            vec![],\n            false,\n        )?)\n    } else {\n        None\n    };\n    let handle = RegistryClient(gctx.http_async()?);","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/registry/mod.rs#L129-L165","documentation":"Invariant in registry operations: `block_on(src.config())...expect(\"remote registries must have config\")`. For a remote registry, cargo expects the registry source to always produce a `RegistryConfig` after fetching. The expect fires if `config()` returns `Ok(None)` — the registry provided no config payload.","triggerScenarios":"Running a registry-API command (`cargo publish`, `cargo yank`, `cargo owner`, `cargo login`, `cargo search`) against a remote registry whose index returned no config (no `config.json` in the index). Typically indicates an empty/misconfigured private registry or a source-replacement pointing at a non-registry.","commonSituations":"Private registry not fully initialized (index exists but `config.json` missing); a `sparse+` registry whose host returns 404 for `config.json`; a `[source]` replacement accidentally pointing at a git index when a sparse index is expected; network/proxy returning an empty body that parses as no-config.","solutions":["Verify the registry URL is reachable: `curl -i <registry-index>/config.json`.","Confirm the registry is correctly declared in `.cargo/config.toml` (`registries.<name> = { index = \"...\" }`).","For private registries, ensure the server actually serves a `config.json` (e.g. ship it via the registry tooling).","Retry after `cargo login` / clearing the index cache (`cargo cache` or removing `~/.cargo/registry/index`)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before a registry API command, probe config.json existence.\nlet cfg_url = format!(\"{}/config.json\", registry_index_url.trim_end_matches('/'));\nlet resp = reqwest::blocking::head(&cfg_url)?;\nif !resp.status().is_success() {\n    return Err(anyhow!(\"registry {} has no config.json (HTTP {})\", registry_index_url, resp.status()));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm private registries serve `config.json` at the index root.","Keep `.cargo/config.toml` registry `index` URLs correct (sparse vs git).","Re-`cargo login` and clear the index cache when registry behavior changes."],"tags":["cargo","panic","invariant","registry","network","config","rust"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}