{"record":{"id":"6ad2ab7131cc15f7","repo":"rust-lang/cargo","slug":"no-target-desc-target-named-target-name-un","errorCode":null,"errorMessage":"no {target_desc} target {named} `{target_name}`{unmatched_packages}{suggestion}","messagePattern":"no (.+?) target (.+?) `(.+?)`(.+?)(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/ops/cargo_compile/unit_generator.rs","lineNumber":317,"sourceCode":"                msg,\n                \"no {target_desc} target {named} `{target_name}`{unmatched_packages}{suggestion}\",\n            )?;\n            if !targets_elsewhere.is_empty() {\n                append_targets_elsewhere(&mut msg)?;\n            } else if suggestion.is_empty() && !targets.is_empty() {\n                write!(msg, \"\\nhelp: available {} targets:\", target_desc)?;\n                for (target_name, pkgs) in targets {\n                    if pkgs.len() == 1 {\n                        write!(msg, \"\\n    {target_name}\")?;\n                    } else {\n                        for (pkg, _) in pkgs {\n                            let pkg_name = pkg.name();\n                            write!(msg, \"\\n    {target_name} in package {pkg_name}\")?;\n                        }\n                    }\n                }\n            }\n            anyhow::bail!(msg);\n        }\n        Ok(proposals)\n    }\n\n    fn get_targets_from_other_packages(\n        &self,\n        filter_fn: impl Fn(&Target) -> bool,\n    ) -> CargoResult<Vec<(&str, Vec<&str>)>> {\n        let packages = Packages::All(Vec::new()).get_packages(self.ws)?;\n        let targets = packages\n            .into_iter()\n            .filter_map(|pkg| {\n                let mut targets: Vec<_> = pkg\n                    .manifest()\n                    .targets()\n                    .iter()\n                    .filter_map(|target| filter_fn(target).then(|| target.name()))\n                    .collect();","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/ops/cargo_compile/unit_generator.rs#L299-L335","documentation":"Thrown by unit_generator when a requested named/glob target (bin, example, test, bench) does not exist in the matched packages. The message is composed dynamically: target_desc (bin/example/...), named ('named' or 'matches pattern'), target_name, an unmatched-packages qualifier, and a suggestion block that either lists targets found in OTHER packages or lists available targets in-package.","triggerScenarios":"Running `cargo build --bin nope`, `--example gone`, `--test removed`, or a `--bin 'app-*'` glob that matches no target. Also fires when the target exists in a different package than the one selected (the 'available targets elsewhere' branch).","commonSituations":"Renaming or deleting a target without updating scripts; typos in --bin/--example/--test; glob patterns that miss; selecting the wrong package with -p so the target is 'elsewhere'.","solutions":["Read the help/available-targets section appended to the message and copy the exact name.","If the target exists in another package, add `-p <that-pkg>` (or drop the wrong -p).","Verify the target is declared under [[bin]]/[[example]]/[[test]]/[[bench]] in Cargo.toml.","Correct typos or glob syntax for the target name."],"exampleFix":"# before\ncargo run --bin my-app\n# after (name from `help: available bin targets:`)\ncargo run --bin myapp","handlingStrategy":"validation","validationCode":"// Verify a target name exists in the package before selecting it.\n// cargo metadata -> packages[].targets[].name; check membership of requested --bin/--example/--test.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the `help: available ... targets:` block in the error for valid names.","Keep scripts in sync with target names after renames.","Prefer explicit names over globs for --bin/--example."],"tags":["cargo-compile","target-selection","user-input","manifest"],"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"}