jdx/mise · error
pacman -Q failed
Error message
pacman -Q failed: {} What it means
mise's pacman backend runs `pacman -Q` to query installed packages and only accepts exit 0, or exit 1 when the query was explicitly for possibly-missing packages. Any other combination (non-zero status with stderr output, or exit 1 outside the tolerated case) means the query itself failed rather than simply reporting a package as absent, so mise aborts with pacman's stderr text. This keeps silent pacman failures (corrupt local db, bad arguments, lock issues) from being misread as 'package not installed'.
Solutions
- Run `pacman -Q <package>` manually to see the underlying stderr and fix pacman itself (e.g. remove a stale /var/lib/pacman/db.lck, run `pacman -D --asdeps` repairs or re-init the db).
- Ensure no other pacman/pikaur/yay process is running when mise queries packages.
- Verify you are on an Arch-based system where /var/lib/pacman/local exists; mise's pacman backend is not meant for non-Arch hosts.
- If a package genuinely is not installed, this error should not appear — report it; the caller should have tolerated exit 1 for missing packages.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check pacman health before relying on mise package queries
const { code, stderr } = await sh("pacman -Q 2>&1; echo $?");
if (code !== 0 && !/no targets specified|package .* was not found/.test(stderr)) {
throw new Error(`pacman unusable: ${stderr.trim()} (stale db.lck? corrupt local db?)`);
} Try / catch
try { await miseInstallPacman(pkgs) } catch (e) { if (String(e).includes('pacman -Q failed')) { const stderr = e.message.split(': ').slice(1).join(': '); console.error('Fix pacman first:', stderr); } else throw e; } Prevention
- Keep pacman healthy: no concurrent pacman processes and no stale /var/lib/pacman/db.lck.
- Use mise's pacman backend only on Arch-based systems with an initialized local database.
- Before scripted installs, run `pacman -Q <pkg>` once interactively to confirm the db is readable.
- Avoid wrappers/aliases named pacman that alter exit codes.
When it happens
Trigger: Calling the backend's `installed` (package status check) or `upgrade` path when `pacman -Q <pkg>` exits with a code other than 0, or exits 1 with stderr non-empty in a context where missing packages are not tolerated (only_missing == false). Also triggered from test_pacman_query_file_advisory scenarios where the file-based query returns an unexpected status.
Common situations: pacman's database lock is held by another pacman process; the local database is corrupt ('error: could not open local database'); a partial pacman upgrade left the db inconsistent; running inside a container/sandbox where /var/lib/pacman is missing or read-only; a wrapper or alias intercepts pacman and returns a non-standard exit code.
Related errors
- pacman -T failed
- pacman cannot install a pinned version
- pacman -Qi failed
- winget failed with
- winget list failed for
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/fddd60bd85f59aa4.
Report an issue: GitHub.
Appendix: 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 533346cc37)