{"id":"c52c7c959b3cb509","repo":"rust-lang/cargo","slug":"could-not-find-in-registry","errorCode":null,"errorMessage":"could not find `{}` in registry `{}`","messagePattern":"could not find `(.+?)` in registry `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/registry/cargo_info/mod.rs","lineNumber":206,"sourceCode":"                .unwrap_or_else(|| false);\n            let s2_matches = s2\n                .rust_version()\n                .map(|v| v.is_compatible_with(rustc_version))\n                .unwrap_or_else(|| false);\n            // MSRV compatible version is preferred.\n            match (s1_matches, s2_matches) {\n                (true, false) => std::cmp::Ordering::Greater,\n                (false, true) => std::cmp::Ordering::Less,\n                // If both summaries match the current Rust version or neither do, try to\n                // pick the latest version.\n                _ => s1.package_id().version().cmp(s2.package_id().version()),\n            }\n        });\n\n    match summary {\n        Some(summary) => Ok(summary.package_id()),\n        None => {\n            anyhow::bail!(\n                \"could not find `{}` in registry `{}`\",\n                normalized_spec,\n                source_ids.original.url()\n            )\n        }\n    }\n}\n\nfn query_summaries(\n    spec: &PackageIdSpec,\n    registry: &mut PackageRegistry<'_>,\n    source_ids: &RegistrySourceIds,\n) -> CargoResult<(Vec<Summary>, Option<String>)> {\n    // Query without version requirement to get all index summaries.\n    let dep = Dependency::parse(spec.name(), None, source_ids.original)?;\n    // Use normalized crate name lookup for user-provided package names.\n    let results: Vec<_> = crate::util::block_on(registry.query_vec(&dep, QueryKind::Normalized))?\n        .into_iter()","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/registry/cargo_info/mod.rs#L188-L224","documentation":"Thrown by `find_pkgid_in_summaries` when resolving a package spec for `cargo info` (or registry info lookups): after filtering all summaries fetched from a registry, none matched the normalized `PackageIdSpec` (name/version/source). The function picks the MSRV-compatible, then highest-version candidate; if that set is empty it bails. It means the package identifier you supplied does not correspond to any published crate in the queried registry source.","triggerScenarios":"Calling `cargo info <spec>` where `<spec>` names a crate/version that does not exist in the configured registry, or specifying a version requirement that no published version satisfies (e.g. `cargo info serde@=>99.0.0`). Also reached when a `[dependencies]` entry references a crate name absent from crates.io or a private registry, during the info/lookup path rather than the build path.","commonSituations":"Typos in crate names; requesting a version newer than what's published; pointing at a private/alternate registry (via `.cargo/config.toml` source replacement) that does not mirror the crate; using `cargo info` against a sparse/local registry that hasn't been updated. Also seen after a crate was yanked or renamed.","solutions":["Verify the crate name spelling and that it exists: `cargo search <name>` or check https://crates.io/crates/<name>.","Loosen or correct the version requirement in the spec (e.g. drop an exact `@x.y.z` that doesn't exist).","Run `cargo update -p <name> --dry-run` or `cargo fetch` to refresh the local registry index, then retry.","If using a private registry, confirm it is configured in `.cargo/config.toml` under `[registries]`/`[source]` and that it actually mirrors the crate."],"exampleFix":"// before\ncargo info serde@999.0.0\n// after\ncargo info serde      // or a real published version","handlingStrategy":"validation","validationCode":"// Before calling cargo info, confirm the crate exists and pick a real version:\n// $ cargo search <name>   (or query the registry index)\n// In build scripts, validate the spec against crates.io before passing to cargo info:\nfn crate_exists(name: &str) -> bool {\n    // e.g. HEAD https://static.crates.io/crates/<name>/<name>-<version>.crate metadata\n    // or parse the sparse index response\n    std::process::Command::new(\"cargo\")\n        .args([\"search\", name]).status().map(|s| s.success()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `cargo search <name>` to confirm crate names before adding them.","Pin to published versions only — check crates.io for available versions.","In CI, validate `Cargo.toml` dependencies resolve with `cargo metadata --no-deps` before building."],"tags":["registry","package-resolution","cargo-info","lookup"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}