{"id":"617f9edef4b6b245","repo":"rust-lang/cargo","slug":"manifest-is-missing-either-a-package-or-a-wo","errorCode":null,"errorMessage":"manifest is missing either a `[package]` or a `[workspace]`","messagePattern":"manifest is missing either a `\\[package\\]` or a `\\[workspace\\]`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/workspace/parser/mod.rs","lineNumber":138,"sourceCode":"            .map(EitherManifest::Real)\n        } else if normalized_toml.workspace.is_some() {\n            assert!(!is_embedded);\n            to_virtual_manifest(\n                Some(contents),\n                Some(document),\n                original_toml,\n                normalized_toml,\n                features,\n                workspace_config,\n                source_id,\n                path,\n                gctx,\n                &mut warnings,\n                &mut errors,\n            )\n            .map(EitherManifest::Virtual)\n        } else {\n            anyhow::bail!(\"manifest is missing either a `[package]` or a `[workspace]`\")\n        }\n    })()\n    .map_err(|err| {\n        ManifestError::new(\n            err.context(format!(\"failed to parse manifest at `{}`\", path.display())),\n            path.into(),\n        )\n    })?;\n\n    for warning in warnings {\n        manifest.warnings_mut().add_warning(warning);\n    }\n    for error in errors {\n        manifest.warnings_mut().add_critical_warning(error);\n    }\n\n    Ok(manifest)\n}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/workspace/parser/mod.rs#L120-L156","documentation":"Thrown at the top of manifest parsing in src/workspace/parser/mod.rs:138. After deserialization, cargo dispatches on whether a `[package]` table (→ real manifest) or a `[workspace]` table (→ virtual manifest) exists. If neither is present the file is not a valid Cargo manifest and parsing aborts.","triggerScenarios":"An empty `Cargo.toml`, one containing only `[dependencies]`, or a TOML file that is valid TOML but has neither section. `normalized_toml.package.is_none() && normalized_toml.workspace.is_none()`.","commonSituations":"Pointing cargo at the wrong file (`Cargo.lock`, a `*.rs` script without frontmatter, a `config.toml`); a freshly created empty crate dir; a manifest accidentally truncated to comments only.","solutions":["Add a `[package]` section with at least `name` and `version`, or a `[workspace]` section if this is a virtual root.","Verify the file path you passed is a real `Cargo.toml`.","If editing, restore the deleted `[package]`/`[workspace]` header."],"exampleFix":"# before\n# (empty file, or only [dependencies])\n[dependencies]\nserde = \"1\"\n# after\n[package]\nname = \"mycrate\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[dependencies]\nserde = \"1\"","handlingStrategy":"validation","validationCode":"let has_pkg = doc.as_table().get(\"package\").and_then(|i| i.as_table_like()).is_some();\nlet has_ws  = doc.as_table().get(\"workspace\").and_then(|i| i.as_table_like()).is_some();\nif !has_pkg && !has_ws {\n    return Err(\"manifest needs [package] or [workspace]\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never point cargo at non-manifest files (Cargo.lock, *.rs, config.toml).","Keep a minimal `[package]` skeleton for new crates.","Add a pre-commit manifest sanity check."],"tags":["manifest","parser","validation"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}