{"id":"8f898393034d2a2f","repo":"rust-lang/cargo","slug":"package-pattern-s-not-found-in-workspace","errorCode":null,"errorMessage":"{}package pattern(s) `{}` not found in workspace `{}`","messagePattern":"(.+?)package pattern\\(s\\) `(.+?)` not found in workspace `(.+?)`","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_compile/packages.rs","lineNumber":206,"sourceCode":"            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)\n        .map(|(pat, _)| pat.as_str())\n        .collect::<Vec<_>>();\n    if !not_matched.is_empty() {\n        anyhow::bail!(\n            \"{}package pattern(s) `{}` not found in workspace `{}`\",\n            if opt_out { \"excluded \" } else { \"\" },\n            not_matched.join(\", \"),\n            ws.root().display(),\n        )\n    }\n    Ok(())\n}\n\nfn emit_packages_not_found_within_workspace(\n    ws: &Workspace<'_>,\n    packages: &[String],\n) -> CargoResult<()> {\n    let (mut patterns, mut ids) = opt_patterns_and_ids(packages)?;\n    let _: Vec<_> = ws\n        .members()\n        .filter(|pkg| {\n            let id = ids.iter().find(|id| id.matches(pkg.package_id())).cloned();","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/ops/cargo_compile/packages.rs#L188-L224","documentation":"Thrown by emit_pattern_not_found (src/ops/cargo_compile/packages.rs:195-214) when one or more glob package patterns (e.g. `pkg-*`) passed via -p / --exclude matched no workspace member. Distinct from error 86: this is specifically for glob patterns that failed to match.","triggerScenarios":"`cargo build -p 'foo*'` where no member matches the glob; `cargo test --workspace --exclude 'x*'` with no excluded match (prefixed 'excluded '). Patterns are split into globs vs exact names; globs that never set their matched flag land in not_matched.","commonSituations":"Wildcard that no longer matches after a rename/reorg. Glob syntax mistakes (e.g. forgetting the `*`). Patterns authored for a different workspace layout.","solutions":["List members with `cargo metadata --no-deps` to see actual names and adjust the glob.","Quote the pattern so the shell does not expand it before cargo sees it: `cargo build -p 'foo*'`.","Replace the glob with explicit `-p a -p b` if the set is small.","Verify glob syntax: `*` matches within a path segment, `?` a single char, `[abc]` a set."],"exampleFix":"# before\ncargo build -p 'foo-*'     # no member matches\n\n# after\ncargo build -p 'foobar'    # use the real member name","handlingStrategy":"validation","validationCode":"// Test a glob against member names before passing it to cargo.\nfn glob_matches_any(ws: &Workspace, pat: &str) -> bool {\n    let Ok(p) = glob::Pattern::new(pat) else { return false };\n    ws.members().any(|m| p.matches(m.name().as_str()))\n}","typeGuard":"fn all_globs_match(ws: &Workspace, pats: &[String]) -> bool {\n    pats.iter().all(|p| glob_matches_any(ws, p))\n}","tryCatchPattern":"if let Err(e) = pkgs.get_packages(ws) {\n    if e.to_string().contains(\"pattern(s)\") {\n        eprintln!(\"glob matched no member; check syntax and quoting\");\n    }\n    return Err(e);\n}","preventionTips":["Quote globs so the shell does not pre-expand them.","Validate each glob with `cargo metadata`-derived member names."],"tags":["cargo","workspace","package-selection","glob","cli"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}