{"record":{"id":"59eff00716d0e072","repo":"Morganamilo/paru","slug":"duplicate-packages","errorCode":null,"errorMessage":"duplicate packages: {}","messagePattern":"duplicate packages: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/install.rs","lineNumber":1347,"sourceCode":"\n    warnings.all(config.color, config.cols);\n}\n\nfn fmt_stack(want: &DepMissing) -> String {\n    match &want.dep {\n        Some(dep) => format!(\"{} ({})\", want.pkg, dep),\n        None => want.pkg.to_string(),\n    }\n}\n\nfn check_actions(\n    config: &Config,\n    actions: &mut Actions,\n    install_targets: bool,\n) -> Result<(Vec<Conflict>, Vec<Conflict>)> {\n    let c = config.color;\n    let dups = actions.duplicate_targets();\n    ensure!(\n        dups.is_empty(),\n        tr!(\"duplicate packages: {}\", dups.join(\" \"))\n    );\n\n    if !actions.missing.is_empty() {\n        let mut err = tr!(\"could not find all required packages:\");\n        for missing in &actions.missing {\n            if missing.stack.is_empty() {\n                write!(err, \"\\n    {} (target)\", c.error.paint(&missing.dep))?;\n            } else {\n                let stack = missing\n                    .stack\n                    .iter()\n                    .map(fmt_stack)\n                    .collect::<Vec<_>>()\n                    .join(\" -> \");\n                err.push_str(&tr!(\n                    \"\\n    {missing} (wanted by: {stack})\",","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/Morganamilo/paru/blob/9ac3578807a87858651e81a02586ceb947686e7c/src/install.rs#L1329-L1365","documentation":"check_actions (called from prepare_build) computes duplicate_targets() from the Actions struct; if the same package name appears more than once among install targets, it fails listing the duplicates. This prevents pacman/makepkg from receiving conflicting repeated targets.","triggerScenarios":"Installing a command line like `paru -S pkg pkg` or a package both explicitly and as part of a group/PKGBUILD target set so duplicate_targets() returns non-empty.","commonSituations":"Shell loops or aliases appending a package already listed; combining -S targets with a PKGBUILD whose pkgname list overlaps the CLI targets.","solutions":["Remove the repeated package name from the command line or target list","Deduplicate targets before invoking paru: paru -S $(echo pkg pkg | tr ' ' '\\n' | sort -u)","If triggered by a PKGBUILD, rename conflicting split-package entries so pkgname values are unique"],"exampleFix":"// before\nparu -S linux linux\n// after\nparu -S linux","handlingStrategy":"validation","validationCode":"// dedupe targets before invoking paru\nlet targets: Vec<String> = args.targets.clone();\nlet unique: std::collections::HashSet<_> = targets.iter().collect();\nassert_eq!(unique.len(), targets.len(), \"duplicate targets: remove repeats\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate CLI target lists with sort -u in shell wrappers","Ensure PKGBUILD pkgname entries are unique across split packages","Avoid aliases/loops that append already-present package names"],"tags":["packages","installation","validation"],"backgroundTag":"conflicting-config-options","analyzedSha":"9ac3578807a87858651e81a02586ceb947686e7c","analyzedAt":"2026-09-12T04:57:59.861Z","contentChangedAt":"2026-09-12T04:57:59.861Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}