{"record":{"id":"2129f037e62f0f96","repo":"rust-lang/cargo","slug":"you-can-t-generate-a-lockfile-for-an-empty-workspa","errorCode":null,"errorMessage":"you can't generate a lockfile for an empty workspace.","messagePattern":"you can't generate a lockfile for an empty workspace\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_update.rs","lineNumber":58,"sourceCode":"        &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\n                // Precise option specified, so calculate a previous_resolve required\n                // by precise package update later.\n                Some(_) => {\n                    let mut registry = ws.package_registry()?;","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/ops/cargo_update.rs#L40-L76","documentation":"Thrown by `cargo update` when the workspace has zero members (`ws.members().count() == 0`). An empty workspace (only a virtual manifest with no member crates) has no dependencies to resolve, so Cargo cannot generate a meaningful lockfile.","triggerScenarios":"Running `cargo update` in a directory whose `Cargo.toml` is a virtual manifest with an empty or missing `members` list, or where all members have been removed.","commonSituations":"Setting up a new workspace and running `cargo update` before adding any member crates; temporarily removing all members during a refactor; a misconfigured `members` glob that matches nothing.","solutions":["Add at least one member crate to the workspace: list it under `members` in the root Cargo.toml.","Run `cargo update` from inside a member crate's directory instead.","Check that the `members` glob patterns actually match existing subdirectories."],"exampleFix":"# Cargo.toml (before — empty workspace)\n[workspace]\nmembers = []\n\n# After — add a member\n[workspace]\nmembers = [\"my-crate\"]","handlingStrategy":"validation","validationCode":"fn workspace_has_members(ws: &cargo::core::Workspace) -> bool {\n    ws.members().count() > 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the workspace `members` list is non-empty and globs match real directories.","Add at least one member crate before running `cargo update`.","Run `cargo update` from within a member crate directory."],"tags":["cargo-update","empty-workspace","workspace","lockfile"],"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"}