{"record":{"id":"7b6b71446542939b","repo":"rust-lang/cargo","slug":"glob-patterns-on-package-selection-are-not-support","errorCode":null,"errorMessage":"glob patterns on package selection are not supported.","messagePattern":"glob patterns on package selection are not supported\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/util/command_prelude.rs","lineNumber":893,"sourceCode":"    fn cli_features(&self) -> CargoResult<CliFeatures> {\n        CliFeatures::from_command_line(\n            &self._values_of(\"features\"),\n            self.flag(\"all-features\"),\n            !self.flag(\"no-default-features\"),\n        )\n    }\n\n    fn compile_options_for_single_package(\n        &self,\n        gctx: &GlobalContext,\n        intent: UserIntent,\n        workspace: Option<&Workspace<'_>>,\n        profile_checking: ProfileChecking,\n    ) -> CargoResult<CompileOptions> {\n        let mut compile_opts = self.compile_options(gctx, intent, workspace, profile_checking)?;\n        let spec = self._values_of(\"package\");\n        if spec.iter().any(restricted_names::is_glob_pattern) {\n            anyhow::bail!(\"glob patterns on package selection are not supported.\")\n        }\n        compile_opts.spec = Packages::Packages(spec);\n        Ok(compile_opts)\n    }\n\n    fn new_options(&self, gctx: &GlobalContext) -> CargoResult<NewOptions> {\n        let vcs = self._value_of(\"vcs\").map(|vcs| {\n            vcs.parse::<VersionControl>()\n                .expect(\"clap ensures only valid values are present\")\n        });\n        NewOptions::new(\n            vcs,\n            self.flag(\"bin\"),\n            self.flag(\"lib\"),\n            self.value_of_path(\"path\", gctx).unwrap(),\n            self._value_of(\"name\").map(|s| s.to_string()),\n            self._value_of(\"edition\").map(|s| s.to_string()),\n            self.registry(gctx)?,","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/rust-lang/cargo/blob/98a09e7e7d62850f14e5b6132101fc1edd19a16f/src/util/command_prelude.rs#L875-L911","documentation":"compile_options_for_single_package explicitly rejects glob metacharacters in --package values via restricted_names::is_glob_pattern. Cargo's -p selection requires concrete package names or pkgid SPECs; wildcards are not part of the selection model.","triggerScenarios":"Calling `cargo <cmd> -p 'my-*'`, `-p '*crate'`, or any value containing `*`, `?`, `[`, or `]`.","commonSituations":"Expecting shell-glob or wildcard package selection in a monorepo; aliasing `-p` to a glob expansion that fails to match.","solutions":["List each package explicitly: `cargo build -p foo -p bar`.","Use workspace.default-members or `--workspace` to select groups.","Drive selection through a script that enumerates packages via `cargo metadata`."],"exampleFix":"# before\n# cargo build -p 'my-*'\n\n# after\n# cargo build -p my-a -p my-b\n# or: cargo build --workspace","handlingStrategy":"validation","validationCode":"use cargo::util::restricted_names;\n\nfn assert_no_glob(specs: &[String]) -> Result<(), String> {\n    let bad: Vec<_> = specs.iter().filter(|s| restricted_names::is_glob_pattern(s)).collect();\n    if bad.is_empty() { Ok(()) } else { Err(format!(\"glob chars not allowed in -p: {bad:?}\")) }\n}","typeGuard":"fn is_concrete_package_name(s: &str) -> bool {\n    !cargo::util::restricted_names::is_glob_pattern(s)\n}","tryCatchPattern":null,"preventionTips":["Never use wildcards in --package values; enumerate names.","For group builds use --workspace or workspace.default-members.","Enumerate packages dynamically via `cargo metadata` if needed."],"tags":["cli","package-selection","glob","validation"],"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"}