{"record":{"id":"0f36bd938493e129","repo":"rust-lang/cargo","slug":"found-a-virtual-manifest-at-instead-of-a-pack","errorCode":null,"errorMessage":"found a virtual manifest at `{}` instead of a package manifest","messagePattern":"found a virtual manifest at `(.+?)` instead of a package manifest","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ops/cargo_read_manifest.rs","lineNumber":22,"sourceCode":"use crate::util::errors::CargoResult;\nuse crate::workspace::parser::read_manifest;\nuse crate::workspace::{EitherManifest, Package, SourceId};\nuse tracing::trace;\n\npub fn read_package(\n    path: &Path,\n    source_id: SourceId,\n    gctx: &GlobalContext,\n) -> CargoResult<Package> {\n    trace!(\n        \"read_package; path={}; source-id={}\",\n        path.display(),\n        source_id\n    );\n    let manifest = read_manifest(path, source_id, gctx)?;\n    let manifest = match manifest {\n        EitherManifest::Real(manifest) => manifest,\n        EitherManifest::Virtual(..) => anyhow::bail!(\n            \"found a virtual manifest at `{}` instead of a package \\\n             manifest\",\n            path.display()\n        ),\n    };\n\n    Ok(Package::new(manifest, path))\n}\n","sourceCodeStart":4,"sourceCodeEnd":31,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/ops/cargo_read_manifest.rs#L4-L31","documentation":"Thrown by `read_package` when the manifest at the given path is a virtual manifest (a workspace root `[workspace]` with no `[package]` section) instead of a real package manifest. Cargo expects a `[package]` table when constructing a `Package` object; virtual manifests have no package metadata.","triggerScenarios":"Calling code that invokes `read_package` on a `Cargo.toml` that contains only a `[workspace]` section (no `[package]`). This happens internally when Cargo tries to load a workspace root as if it were a package.","commonSituations":"Pointing a dependency or tool at a workspace root `Cargo.toml` rather than a member crate's manifest; misconfiguring a path dependency to a workspace root; virtual manifest accidentally used where a package manifest is required.","solutions":["Point the tool or dependency at the member crate's `Cargo.toml` inside the workspace, not the root.","Add a `[package]` section to the manifest if it was intended to be a real package.","Use the correct subdirectory path for the member crate."],"exampleFix":"# Before — pointing at workspace root\ncargo read-manifest ./Cargo.toml\n\n# After — point at the member crate\ncargo read-manifest ./crates/my-crate/Cargo.toml","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn validate_manifest_is_package(path: &Path) -> Result<(), String> {\n    let content = std::fs::read_to_string(path).map_err(|e| e.to_string())?;\n    if !content.contains(\"[package]\") {\n        return Err(format!(\"`{}` is a virtual manifest, not a package manifest\", path.display()));\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When pointing tools or path dependencies at a crate, use the member's Cargo.toml, not the workspace root.","Check that the target manifest has a `[package]` section before loading."],"tags":["manifest","virtual-manifest","workspace","package"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}