jdx/mise · error
rpm -q failed: {}
Error message
rpm -q failed: {} What it means
The dnf/rpm system package manager runs `rpm -q` to check installed packages. rpm normally reports not-installed packages on stderr ("package X is not installed", "no package X provided"); the library tolerates those lines but treats any other non-empty stderr as a real query failure and bails with this error containing the stderr text.
Source
Thrown at src/system/packages/dnf.rs:135
let output = tokio::process::Command::new("rpm")
.args(&args)
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.output()
.await?;
// rpm -q exits nonzero when any package is not installed; "package X
// is not installed" goes to stdout or stderr depending on rpm version
// and won't match the \t format either way — absent packages parse as
// Missing. Only fail on rpm errors unrelated to missing packages.
let stderr = String::from_utf8_lossy(&output.stderr);
if !output.status.success()
&& !stderr.is_empty()
&& !stderr.lines().all(|l| {
l.trim().is_empty() || l.contains("is not installed") || l.contains("no packages")
})
{
bail!("rpm -q failed: {}", stderr.trim());
}
let stdout = String::from_utf8_lossy(&output.stdout);
Ok(parse_rpm_query(&stdout, pkgs))
}
async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {
let args = install_args(pkgs, opts);
if opts.dry_run {
miseprintln!("{}", sudo::argv("dnf", &args).join(" "));
return Ok(());
}
sudo::run("dnf", &args, &[])
}
async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {
let args = upgrade_args(pkgs);
if opts.dry_run {
miseprintln!("{}", sudo::argv("dnf", &args).join(" "));View on GitHub (pinned to afd2eddd3a)
Solutions
- Read the stderr in the message to see the actual rpm failure and fix that underlying issue.
- Run with appropriate privileges (root/sudo) if the rpm database is unreadable.
- Rebuild the rpm database (rpm --rebuilddb) if it is corrupt or locked.
- Verify rpm is correctly installed and the package names passed are valid rpm identifiers.
Example fix
// before: failing due to unreadable rpm db rpm -q curl # error: cannot open Packages database in /var/lib/rpm // after sudo rpm --rebuilddb && rpm -q curl
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check rpm availability and db readability before querying
if !Path::new("/usr/bin/rpm").exists() { return Err(anyhow!("rpm not available")); }
let db_ok = std::process::Command::new("rpm").args(["-q", "rpm"]).output()
.map(|o| o.status.success()).unwrap_or(false); Try / catch
match dnf_manager.installed(&pkgs).await {
Err(e) if e.to_string().starts_with("rpm -q failed") => {
eprintln!("rpm query failed: {e}; falling back to dnf list installed");
dnf_list_installed(&pkgs).await
}
other => other,
} Prevention
- Run package queries with sufficient privileges (root or readable /var/lib/rpm)
- Keep the rpm database healthy; run rpm --rebuilddb after db corruption
- Use valid rpm package identifiers (no version constraints in -q names)
- Verify dnf/rpm is functional on the host before using this manager
When it happens
Trigger: `rpm -q` exits non-status-success AND stderr is non-empty AND at least one stderr line is neither blank nor contains "is not installed" / "no packages" — e.g. rpm database errors, permission problems, malformed package arguments, or rpm not functioning.
Common situations: Corrupt or locked RPM database (/var/lib/rpm) on a minimal container; running without root where the rpm db is unreadable; a requested package name with invalid characters that rpm rejects; SELinux or dbenv failures; partially installed rpm/dnf on non-RHEL systems.
Related errors
- flatpak {action} failed: {}
- {program} failed with {status}
- pacman -Qi failed: {}
- pacman -Q failed: {}
- ditto failed copying {} to {}
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/7691e51d2c3eca59.
Report an issue: GitHub.