jdx/mise · error
pacman -Q failed: {}
Error message
pacman -Q failed: {} What it means
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'.
Source
Thrown at src/system/packages/pacman.rs:344
.strip_suffix("' was not found")
})
.filter(|name| names.iter().any(|requested| requested == name))
.collect::<HashSet<_>>();
let only_missing = !missing.is_empty()
&& stderr.lines().all(|line| {
line.trim().is_empty()
|| missing.iter().any(|name| {
line == format!("error: package '{name}' was not found")
|| line
== format!(
"warning: '{name}' is a file, you might want to use -p/--file."
)
})
});
let valid_result = (output.status.success() && stderr.is_empty())
|| (output.status.code() == Some(1) && only_missing);
if !valid_result {
bail!("pacman -Q failed: {}", stderr.trim());
}
Ok(String::from_utf8_lossy(&output.stdout).into_owned())
}
async fn pacman_deptest(names: &[String]) -> Result<String> {
if names.is_empty() {
return Ok(String::new());
}
let mut args = vec!["-T", "--"];
args.extend(names.iter().map(String::as_str));
debug!("$ pacman {}", args.join(" "));
let output = tokio::process::Command::new("pacman")
.args(&args)
.env("LC_ALL", "C")
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()View on GitHub (pinned to afd2eddd3a)
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
Defensive patterns
Strategy: try-catch
Validate before calling
pacman -Q >/dev/null 2>&1 || echo "pacman local DB unhealthy"
Try / catch
match pacman_query(&args).await {
Err(e) if e.to_string().contains("pacman -Q failed") => {
eprintln!("pacman query failed beyond missing packages: {e}");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- pacman -Qi failed: {}
- pacman -Q returned no package for satisfied requirement '{}'
- {program} failed with {status}
- rpm -q failed: {}
- flatpak {action} failed: {}
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/fddd60bd85f59aa4.
Report an issue: GitHub.