{"id":"31b33ab44f7e05a0","repo":"rust-lang/cargo","slug":"warnings-are-denied-by-build-warnings-configurat-31b33a","errorCode":null,"errorMessage":"warnings are denied by `build.warnings` configuration","messagePattern":"warnings are denied by `build\\.warnings` configuration","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_fetch.rs","lineNumber":91,"sourceCode":"    // If -Zbuild-std was passed, download dependencies for the standard library.\n    if let Some(crates) = &gctx.cli_unstable().build_std {\n        let (std_package_set, _, _) = standard_lib::resolve_std(\n            ws,\n            &mut data,\n            &build_config,\n            crates,\n            &build_config.requested_kinds,\n        )?;\n        packages.add_set(std_package_set);\n    }\n\n    packages.get_many(to_download)?;\n    crate::workspace::gc::auto_gc(gctx);\n\n    if ws.gctx().warning_handling()? == WarningHandling::Deny\n        && parse_pass_output.lint_warning_count > 0\n    {\n        anyhow::bail!(\"warnings are denied by `build.warnings` configuration\")\n    }\n\n    Ok((resolve, packages))\n}\n","sourceCodeStart":73,"sourceCodeEnd":96,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_fetch.rs#L73-L96","documentation":"Thrown in cargo_fetch::fetch (src/ops/cargo_fetch.rs:88-92) when the `build.warnings` config is set to `deny` (WarningHandling::Deny) AND the dependency parse pass emitted lint warnings (parse_pass_output.lint_warning_count > 0). Cargo treats warnings as hard failures in this deny mode, so fetch aborts.","triggerScenarios":"Configuring `[build] warnings = \"deny\"` (or equivalent env) and running `cargo fetch` when one or more resolved dependencies' manifests/parse produce warnings (e.g. deprecated manifest keys, yanked notices, unused fields).","commonSituations":"Strict CI that denies all warnings; a newly published dependency introduces a manifest warning. Upgrading cargo surfaces previously-suppressed warnings under deny mode. A `[build] warnings` setting copied from a template.","solutions":["Inspect the preceding warning lines (they are printed before the bail) and fix or pin the dependency causing them.","Temporarily relax to `warnings = \"warn\"` to fetch, then re-enable deny.","Pin the offending dependency to an older version whose manifest is clean.","Upgrade cargo/the dependency so the manifest warning is resolved upstream."],"exampleFix":"# before (.cargo/config.toml or Cargo.toml [build])\n[build]\nwarnings = \"deny\"\n\n# after\n[build]\nwarnings = \"warn\"","handlingStrategy":"validation","validationCode":"// If warnings are denied, expect fetch to fail when deps emit warnings.\nuse cargo::util::config::WarningHandling;\n\nfn fetch_will_strict(ws: &Workspace) -> bool {\n    ws.gctx().warning_handling().ok()\n        .map(|h| matches!(h, WarningHandling::Deny))\n        .unwrap_or(false)\n}","typeGuard":"fn warnings_denied(ws: &Workspace) -> bool {\n    matches!(ws.gctx().warning_handling(), Ok(WarningHandling::Deny))\n}","tryCatchPattern":"match ops::fetch(ws, &opts) {\n    Err(e) if e.to_string().contains(\"warnings are denied\") => {\n        eprintln!(\"a dependency emitted a warning; relax build.warnings or pin the dep\");\n        return Err(e);\n    }\n    r => r,\n}","preventionTips":["Use build.warnings = \"warn\" for fetch-heavy steps in CI.","Pin dependencies whose manifests are warning-clean."],"tags":["cargo","fetch","warnings","config","lint","dependencies"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}