{"id":"fb3cda3ad4cf8426","repo":"rust-lang/cargo","slug":"all-versions-of-crate-dependency-are-too-new-p","errorCode":null,"errorMessage":"all versions of crate `{dependency}` are too new per `min-publish-age`","messagePattern":"all versions of crate `(.+?)` are too new per `min-publish-age`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_add/mod.rs","lineNumber":876,"sourceCode":"                        false\n                    }\n                    None => true,\n                });\n                if possibilities.is_empty() && has_candidates {\n                    too_new.sort_by(|(a, _), (b, _)| a.cmp(b));\n                    let mut msg = format!(\n                        \"all versions of crate `{dependency}` are too new per `min-publish-age`\"\n                    );\n                    for (version, violation) in &too_new {\n                        let note = violation.note();\n                        let _ = write!(&mut msg, \"\\n  version {version} is too new ({note})\",);\n                    }\n                    let _ = write!(\n                        &mut msg,\n                        \"\\nhelp: to add the latest version anyways, \\\n                         re-run with `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow`\"\n                    );\n                    anyhow::bail!(msg);\n                }\n            }\n\n            possibilities.sort_by_key(|s| {\n                // Fallback to a pre-release if no official release is available by sorting them as\n                // less.\n                let stable = s.version().pre.is_empty();\n                (stable, s.version().clone())\n            });\n\n            let mut latest = possibilities.last().ok_or_else(|| {\n                anyhow::format_err!(\n                    \"the crate `{dependency}` could not be found in registry index.\"\n                )\n            })?;\n\n            if honor_rust_version.unwrap_or(true) {\n                let (req_msrv, is_msrv) = spec","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_add/mod.rs#L858-L894","documentation":"When a `min-publish-age` resolver policy is configured (to avoid depending on crates published too recently, e.g. for supply-chain cooling-off), cargo-add filters candidate versions through `PublishAgePolicy::too_new`. If *every* candidate is filtered out as too new, the operation bails at mod.rs:876 with the offending versions listed. The message includes an escape hatch: set `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow`.","triggerScenarios":"A crate whose only published versions are all newer than the configured `min-publish-age` window, while running `cargo add <crate>`. The policy is read from config (`PublishAgePolicy::new(gctx)`).","commonSituations":"Supply-chain policies in regulated environments, or a brand-new crate that has no aged version yet. Also seen right after a security patch is published and the team policy requires a wait period.","solutions":["Re-run with `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo add <crate>` to override for this one add.","Pin to an older, aged version explicitly: `cargo add <crate>@<older-version>` if one exists outside the window.","Relax or disable the `min-publish-age` policy in `.cargo/config.toml` if the cooling-off is no longer required."],"exampleFix":"# before\ncargo add brand-new-crate\n\n# after (one-off override)\nCARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow cargo add brand-new-crate","handlingStrategy":"validation","validationCode":"// Before adding, check whether any candidate version is aged enough for the policy.\nfn has_aged_version(crate_name: &str, min_age_days: u32) -> bool {\n    let now = std::time::SystemTime::now();\n    crate_versions(crate_name).iter().any(|v| {\n        now.duration_since(v.published_at).map(|d| d.as_secs() / 86400 >= min_age_days as u64).unwrap_or(false)\n    })\n}\n// if !has_aged_version(name, policy_days) { decide: allow or skip }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document the `min-publish-age` policy so contributors know new crates need an override.","Automate the `CARGO_RESOLVER_INCOMPATIBLE_PUBLISH_AGE=allow` escape hatch in onboarding scripts.","Track supply-chain exceptions in a vetting log."],"tags":["cargo-add","supply-chain","policy","publish-age"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}