{"record":{"id":"fddd60bd85f59aa4","repo":"jdx/mise","slug":"pacman-q-failed","errorCode":null,"errorMessage":"pacman -Q failed: {}","messagePattern":"pacman -Q failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/pacman.rs","lineNumber":344,"sourceCode":"                .strip_suffix(\"' was not found\")\n        })\n        .filter(|name| names.iter().any(|requested| requested == name))\n        .collect::<HashSet<_>>();\n    let only_missing = !missing.is_empty()\n        && stderr.lines().all(|line| {\n            line.trim().is_empty()\n                || missing.iter().any(|name| {\n                    line == format!(\"error: package '{name}' was not found\")\n                        || line\n                            == format!(\n                                \"warning: '{name}' is a file, you might want to use -p/--file.\"\n                            )\n                })\n        });\n    let valid_result = (output.status.success() && stderr.is_empty())\n        || (output.status.code() == Some(1) && only_missing);\n    if !valid_result {\n        bail!(\"pacman -Q failed: {}\", stderr.trim());\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\nasync fn pacman_deptest(names: &[String]) -> Result<String> {\n    if names.is_empty() {\n        return Ok(String::new());\n    }\n    let mut args = vec![\"-T\", \"--\"];\n    args.extend(names.iter().map(String::as_str));\n    debug!(\"$ pacman {}\", args.join(\" \"));\n    let output = tokio::process::Command::new(\"pacman\")\n        .args(&args)\n        .env(\"LC_ALL\", \"C\")\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .output()","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/pacman.rs#L326-L362","documentation":"pacman_query runs `pacman -Q` (optionally with groups/queries files) and validates the result: success with no stderr, or exit code 1 when the only problem is missing packages (`only_missing`). Any other combination bails with the trimmed stderr, signaling a real pacman failure rather than a benign 'not installed'.","triggerScenarios":"`pacman -Q` exits with a status other than 0, or exits 1 with stderr that includes errors beyond merely missing packages (e.g. unknown group, corrupt local DB, invalid argument), or stderr is non-empty even on success.","commonSituations":"Querying a group name that doesn't exist locally; corrupted /var/lib/pacman/local database; running on non-Arch systems with a leftover pacman; malformed query file input producing argument errors.","solutions":["Run the exact `pacman -Q ...` command manually and read the stderr in the error","Fix or rebuild the pacman local database if corruption is reported (e.g. remove /var/lib/pacman/local.lock, run `pacman -D --asdeps` repairs as appropriate)","Correct package/group names in the config; nonexistent groups are not treated as 'missing'","Ensure the system actually uses pacman (Arch/derivatives) before enabling the pacman provider"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"pacman -Q >/dev/null 2>&1 || echo \"pacman local DB unhealthy\"","typeGuard":null,"tryCatchPattern":"match pacman_query(&args).await {\n    Err(e) if e.to_string().contains(\"pacman -Q failed\") => {\n        eprintln!(\"pacman query failed beyond missing packages: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Validate group names exist before querying","Keep the pacman local DB healthy (no stale locks; periodic -Sy)","Only enable the pacman provider on Arch derivatives"],"tags":["linux","arch","pacman","subprocess"],"backgroundTag":"command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}