{"record":{"id":"0296cf9464c2b032","repo":"jdx/mise","slug":"pacman-qi-failed","errorCode":null,"errorMessage":"pacman -Qi failed: {}","messagePattern":"pacman -Qi failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/pacman.rs","lineNumber":295,"sourceCode":"            installed: provider.version.clone(),\n        }\n    };\n    Ok(provider)\n}\n\nasync fn pacman_info() -> Result<String> {\n    let args = [\"-Qi\"];\n    debug!(\"$ pacman {}\", args.join(\" \"));\n    let output = tokio::process::Command::new(\"pacman\")\n        .args(args)\n        .env(\"LC_ALL\", \"C\")\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .output()\n        .await?;\n    if !output.status.success() {\n        bail!(\n            \"pacman -Qi failed: {}\",\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\nasync fn pacman_query(names: &[String]) -> Result<String> {\n    if names.is_empty() {\n        return Ok(String::new());\n    }\n    let mut args = vec![\"-Q\", \"--\"];\n    args.extend(names.iter().map(String::as_str));\n    debug!(\"$ pacman {}\", args.join(\" \"));\n    let output = tokio::process::Command::new(\"pacman\")\n        .args(&args)\n        // pacman localizes diagnostics, so matching requires untranslated output\n        .env(\"LC_ALL\", \"C\")","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/pacman.rs#L277-L313","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Read pacman's stderr in the error message; fix the specific pacman complaint.","Ensure no other pacman transaction is running (`sudo fuser /var/lib/pacman/db/ldb` or check db.lck) and retry after it finishes.","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).","Initialize the pacman database in minimal containers: `pacman-key --init && pacman-key --populate archlinux`.","Run mise's package check again once `sudo pacman -Qi` works interactively."],"exampleFix":"# before: diagnosing\n$ sudo pacman -Qi\nerror: could not open database ...\n\n# after: clear stale lock (only when no pacman is running)\n$ sudo rm /var/lib/pacman/db.lck\n$ sudo pacman -Qi   # exits cleanly; mise will now succeed","handlingStrategy":"retry","validationCode":"# verify pacman works before tooling runs\npacman -Qi >/dev/null || { echo \"pacman -Qi failed; fix database/lock\"; exit 1; }","typeGuard":null,"tryCatchPattern":"let info = loop {\n    match pacman_info().await {\n        Ok(s) => break s,\n        Err(e) if is_db_lock_error(&e) => tokio::time::sleep(Duration::from_secs(5)).await,\n        Err(e) => return Err(e),\n    }\n};","preventionTips":["Avoid running mise package operations concurrently with pacman transactions","Keep /var/lib/pacman healthy; remove only genuinely stale db.lck","Initialize pacman keys/databases in minimal containers","Check `pacman -Qi` interactively first when the error appears"],"tags":["pacman","arch-linux","command-failed","package-database","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}