jdx/mise · error
pacman -Qm failed
Error message
pacman -Qm failed: {} What it means
The AUR backend enumerates foreign (AUR) packages with `pacman -Qm`. pacman exits 1 with empty output when there are simply no foreign packages — that case is accepted — but any other failure raises pacman's stderr as this error.
Solutions
- Read the stderr embedded in the message
- Wait for concurrent pacman operations and remove stale /var/lib/pacman/db.lck if safe
- Run `pacman -Qm` manually to reproduce
- Initialize/repair pacman databases (pacman-key --init, pacstrap as appropriate)
Defensive patterns
Strategy: try-catch
Validate before calling
pacman -Qm >/dev/null 2>&1 || echo 'pacman local db unusable'
Try / catch
match foreign_packages().await {
Err(e) if e.to_string().contains("pacman -Qm failed") => {
clear_stale_db_lock();
retry().await?;
}
r => r?,
} Prevention
- Don't run pacman concurrently with mise bootstrap
- Remove stale /var/lib/pacman/db.lck only when no pacman runs
- Initialize pacman keyring/db in fresh Arch containers
When it happens
Trigger: `pacman -Qm` exits nonzero other than the empty-result exit 1 — pacman database locked, missing/corrupt local db, or pacman not functional.
Common situations: Another pacman operation holding the db lock; Arch container where pacman's local database is uninitialized; Arch keyring issues making pacman fail.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- AUR helpers cannot install a pinned version
- AUR packages cannot be built as root; run mise as a…
- pacman -Q returned no package for satisfied requirement
- pacman -Qi failed
- apk info failed
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/21dd6d99eb0471bd.
Report an issue: GitHub.
Appendix: source
Thrown at src/system/packages/aur.rs:136
}
async fn foreign_packages() -> Result<String> {
let args = ["-Qm"];
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()
.await?;
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
let no_foreign_packages =
output.status.code() == Some(1) && stdout.trim().is_empty() && stderr.trim().is_empty();
if !output.status.success() && !no_foreign_packages {
bail!("pacman -Qm failed: {}", stderr.trim());
}
Ok(stdout.into_owned())
}
#[async_trait(?Send)]
impl SystemPackageManager for AurManager {
fn name(&self) -> &str {
"aur"
}
fn is_available(&self) -> bool {
cfg!(target_os = "linux")
&& crate::file::which("pacman").is_some()
&& self.helper().is_some()
}
fn unavailable_reason(&self) -> String {
if !cfg!(target_os = "linux") {View on GitHub (pinned to 533346cc37)