{"record":{"id":"1b45143565310eb7","repo":"rust-lang/cargo","slug":"cannot-specify-both-recursive-and-precise-simultan","errorCode":null,"errorMessage":"cannot specify both recursive and precise simultaneously","messagePattern":"cannot specify both recursive and precise simultaneously","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_update.rs","lineNumber":54,"sourceCode":"    let previous_resolve = None;\n    let mut resolve = ops::resolve_with_previous(\n        &mut registry,\n        ws,\n        &CliFeatures::new_all(true),\n        HasDevUnits::Yes,\n        previous_resolve,\n        None,\n        &[],\n        true,\n    )?;\n    ops::write_pkg_lockfile(ws, &mut resolve)?;\n    print_lockfile_changes(ws, previous_resolve, &resolve, &mut registry)?;\n    Ok(())\n}\n\npub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> {\n    if opts.recursive && opts.precise.is_some() {\n        anyhow::bail!(\"cannot specify both recursive and precise simultaneously\")\n    }\n\n    if ws.members().count() == 0 {\n        anyhow::bail!(\"you can't generate a lockfile for an empty workspace.\")\n    }\n\n    // Updates often require a lot of modifications to the registry, so ensure\n    // that we're synchronized against other Cargos.\n    let _lock = ws\n        .gctx()\n        .acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;\n\n    let previous_resolve = match ops::load_pkg_lockfile(ws)? {\n        Some(resolve) => resolve,\n        None => {\n            match opts.precise {\n                None => return generate_lockfile(ws),\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/ops/cargo_update.rs#L36-L72","documentation":"Thrown by `cargo update` when both `--recursive` and `--precise <version>` are passed simultaneously. These flags are mutually exclusive: `--recursive` upgrades an entire dependency subtree, while `--precise` pins a single package to an exact version. Combining them is semantically contradictory.","triggerScenarios":"Running `cargo update --recursive --precise 1.2.3 <pkg>` or calling `update_lockfile` with `UpdateOptions` where both `recursive` is true and `precise` is `Some(...)`.","commonSituations":"Misunderstanding the flags; copy-pasting a command with both flags; scripting cargo update with incorrect option combinations.","solutions":["Use `--precise` alone to pin one package: `cargo update --precise 1.2.3 <pkg>`.","Use `--recursive` alone to upgrade a full subtree: `cargo update --recursive <pkg>`.","Remove one of the two conflicting flags from the command."],"exampleFix":"# Before\ncargo update --recursive --precise 1.2.3 serde\n\n# After — choose one\ncargo update --precise 1.2.3 serde\n# or\ncargo update --recursive serde","handlingStrategy":"validation","validationCode":"fn validate_update_opts(recursive: bool, precise: Option<&str>) -> Result<(), String> {\n    if recursive && precise.is_some() {\n        return Err(\"cannot use --recursive and --precise together\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `--recursive` OR `--precise`, never both.","Read `cargo update --help` to understand flag semantics.","In scripts, validate flags before invoking cargo."],"tags":["cargo-update","conflicting-flags","recursive","precise"],"backgroundTag":null,"analyzedSha":"98a09e7e7d62850f14e5b6132101fc1edd19a16f","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}