jdx/mise · error

rpm -q failed

Error message

rpm -q failed: {}

What it means

The DNF system package manager runs `rpm -q` to check installed packages. rpm's non-zero exit is normally interpreted as 'not installed', but if stderr contains lines that are neither blank nor the known 'is not installed'/'no packages' notices, dnf.rs treats it as a genuine rpm failure and bails with the stderr text.

Solutions

  1. Run `rpm -q <pkg>` manually to see the underlying stderr error
  2. Fix the rpm database (e.g. rebuild via `rpm --rebuilddb`) if corrupted
  3. Set locale to C (LC_ALL=C) so rpm messages match the expected English patterns
  4. Ensure no concurrent package manager process holds the rpm db

Example fix

// before
$ LC_ALL=de_DE rpm -q curl   # localized stderr not recognized
// after
$ LC_ALL=C rpm -q curl
Defensive patterns

Strategy: fallback

Validate before calling

let out = std::process::Command::new("rpm").args(["-q", pkg]).output()?;
let ok = out.status.success()
    || String::from_utf8_lossy(&out.stderr).lines().all(|l| {
        l.trim().is_empty() || l.contains("is not installed") || l.contains("no packages")
    });

Try / catch

match result {
    Err(e) if e.to_string().starts_with("rpm -q failed") => {
        eprintln!("rpm query failed: {e}; check rpm db and locale");
    }
    other => { let _ = other; }
}

Prevention

When it happens

Trigger: installed() runs `rpm -q <pkgs>`; the command exits non-zero with stderr lines not matching the whitelisted patterns (e.g. real rpm errors, database lock messages, unrelated warnings).

Common situations: Corrupted rpm database; `rpm` not the expected version; concurrent package operations locking the db; localized (non-English) rpm messages that don't contain the English patterns.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/7691e51d2c3eca59. Report an issue: GitHub.

Appendix: 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 533346cc37)