{"record":{"id":"d8625cd0a1776426","repo":"rust-lang/cargo","slug":"package-s-not-found-in-workspace","errorCode":null,"errorMessage":"{}package(s) `{}` not found in workspace `{}`","messagePattern":"(.+?)package\\(s\\) `(.+?)` not found in workspace `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_compile/packages.rs","lineNumber":184,"sourceCode":"    /// specific package in the workspace.\n    pub fn needs_spec_flag(&self, ws: &Workspace<'_>) -> bool {\n        match self {\n            Packages::Default => ws.default_members().count() > 1,\n            Packages::All(_) => ws.members().count() > 1,\n            Packages::Packages(_) => true,\n            Packages::OptOut(_) => true,\n        }\n    }\n}\n\n/// Emits \"package not found\" error.\nfn emit_package_not_found(\n    ws: &Workspace<'_>,\n    opt_names: BTreeSet<String>,\n    opt_out: bool,\n) -> CargoResult<()> {\n    if !opt_names.is_empty() {\n        anyhow::bail!(\n            \"{}package(s) `{}` not found in workspace `{}`\",\n            if opt_out { \"excluded \" } else { \"\" },\n            opt_names.into_iter().collect::<Vec<_>>().join(\", \"),\n            ws.root().display(),\n        )\n    }\n    Ok(())\n}\n\n/// Emits \"glob pattern not found\" error.\nfn emit_pattern_not_found(\n    ws: &Workspace<'_>,\n    opt_patterns: Vec<(glob::Pattern, bool)>,\n    opt_out: bool,\n) -> CargoResult<()> {\n    let not_matched = opt_patterns\n        .iter()\n        .filter(|(_, matched)| !*matched)","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/ops/cargo_compile/packages.rs#L166-L202","documentation":"Thrown by emit_package_not_found when one or more exact -p names / specs did not match any workspace member after iteration. The message prepends 'excluded ' when the unmatched names came from an OptOut (--exclude) flow and interpolates the workspace root for context.","triggerScenarios":"Running `cargo build -p typo` or `cargo build --workspace --exclude notamember`; a PackageIdSpec whose name/origin/version matches no member; programmatic Specs that drift after a rename.","commonSituations":"Typos in member names in scripts/CI; renaming a crate without updating -p references; removing a member but leaving it in build matrix commands.","solutions":["List workspace members: `cargo metadata --no-deps | jq '.packages[].name'` or `ls` the workspace members array.","Correct the -p / --exclude value to the real member name.","Update the root Cargo.toml `members` list if the package is supposed to exist."],"exampleFix":"# before\ncargo build -p mycrat\n# after\ncargo build -p mycrate","handlingStrategy":"validation","validationCode":"// Cross-check -p names against workspace members before building.\n// cargo metadata --no-deps -> JSON; collect member names, diff against requested specs.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate -p values from `cargo metadata` to avoid typos.","Update scripts when renaming or removing members.","Use the closest-match suggestion embedded in the error."],"tags":["cargo-compile","packages","workspace","package-spec","user-input"],"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"}