jdx/mise · error

pacman -Qi failed

Error message

pacman -Qi failed: {}

What it means

mise queries the full installed-package table with `pacman -Qi` (run with `LC_ALL=C` for stable output). If pacman exits non-zero — e.g. no database, locked database, or a pacman error — mise surfaces pacman's own stderr verbatim under this message. Note pacman normally exits 0 for `-Qi` even with no output, so this error indicates pacman itself failed, not merely that packages are missing.

Solutions

  1. Read pacman's stderr in the error message; fix the specific pacman complaint.
  2. Ensure no other pacman transaction is running (`sudo fuser /var/lib/pacman/db/ldb` or check db.lck) and retry after it finishes.
  3. Repair the local database if corrupt (`pacman -D --asdeps` fixes are rare; often `rm /var/lib/pacman/db.lck` only if truly stale, or reinstall pacman).
  4. Initialize the pacman database in minimal containers: `pacman-key --init && pacman-key --populate archlinux`.
  5. Run mise's package check again once `sudo pacman -Qi` works interactively.

Example fix

# before: diagnosing
$ sudo pacman -Qi
error: could not open database ...

# after: clear stale lock (only when no pacman is running)
$ sudo rm /var/lib/pacman/db.lck
$ sudo pacman -Qi   # exits cleanly; mise will now succeed
Defensive patterns

Strategy: retry

Validate before calling

# verify pacman works before tooling runs
pacman -Qi >/dev/null || { echo "pacman -Qi failed; fix database/lock"; exit 1; }

Try / catch

let info = loop {
    match pacman_info().await {
        Ok(s) => break s,
        Err(e) if is_db_lock_error(&e) => tokio::time::sleep(Duration::from_secs(5)).await,
        Err(e) => return Err(e),
    }
};

Prevention

When it happens

Trigger: `pacman -Qi` invoked from `pacman_info()` (used by concrete_remove_names, resolve_installed_provider, and installed) exits non-zero: unreadable/missing local database, database lock from a concurrent pacman operation, disk errors, or pacman binary wrapper failure.

Common situations: Running while another pacman/yaourt transaction holds the db.lck lock; corrupt or partially synced local database; Arch container images without /var/lib/pacman initialized; running under a non-root user where pacman cannot read locked state in odd setups.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


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

Appendix: source

Thrown at src/system/packages/pacman.rs:295

            installed: provider.version.clone(),
        }
    };
    Ok(provider)
}

async fn pacman_info() -> Result<String> {
    let args = ["-Qi"];
    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?;
    if !output.status.success() {
        bail!(
            "pacman -Qi failed: {}",
            String::from_utf8_lossy(&output.stderr).trim()
        );
    }
    Ok(String::from_utf8_lossy(&output.stdout).into_owned())
}

async fn pacman_query(names: &[String]) -> Result<String> {
    if names.is_empty() {
        return Ok(String::new());
    }
    let mut args = vec!["-Q", "--"];
    args.extend(names.iter().map(String::as_str));
    debug!("$ pacman {}", args.join(" "));
    let output = tokio::process::Command::new("pacman")
        .args(&args)
        // pacman localizes diagnostics, so matching requires untranslated output
        .env("LC_ALL", "C")

View on GitHub (pinned to 533346cc37)