{"record":{"id":"21dd6d99eb0471bd","repo":"jdx/mise","slug":"pacman-qm-failed","errorCode":null,"errorMessage":"pacman -Qm failed: {}","messagePattern":"pacman -Qm failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/aur.rs","lineNumber":136,"sourceCode":"}\n\nasync fn foreign_packages() -> Result<String> {\n    let args = [\"-Qm\"];\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    let stdout = String::from_utf8_lossy(&output.stdout);\n    let stderr = String::from_utf8_lossy(&output.stderr);\n    let no_foreign_packages =\n        output.status.code() == Some(1) && stdout.trim().is_empty() && stderr.trim().is_empty();\n    if !output.status.success() && !no_foreign_packages {\n        bail!(\"pacman -Qm failed: {}\", stderr.trim());\n    }\n    Ok(stdout.into_owned())\n}\n\n#[async_trait(?Send)]\nimpl SystemPackageManager for AurManager {\n    fn name(&self) -> &str {\n        \"aur\"\n    }\n\n    fn is_available(&self) -> bool {\n        cfg!(target_os = \"linux\")\n            && crate::file::which(\"pacman\").is_some()\n            && self.helper().is_some()\n    }\n\n    fn unavailable_reason(&self) -> String {\n        if !cfg!(target_os = \"linux\") {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/aur.rs#L118-L154","documentation":"The AUR backend enumerates foreign (AUR) packages with `pacman -Qm`. pacman exits 1 with empty output when there are simply no foreign packages — that case is accepted — but any other failure raises pacman's stderr as this error.","triggerScenarios":"`pacman -Qm` exits nonzero other than the empty-result exit 1 — pacman database locked, missing/corrupt local db, or pacman not functional.","commonSituations":"Another pacman operation holding the db lock; Arch container where pacman's local database is uninitialized; Arch keyring issues making pacman fail.","solutions":["Read the stderr embedded in the message","Wait for concurrent pacman operations and remove stale /var/lib/pacman/db.lck if safe","Run `pacman -Qm` manually to reproduce","Initialize/repair pacman databases (pacman-key --init, pacstrap as appropriate)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"pacman -Qm >/dev/null 2>&1 || echo 'pacman local db unusable'","typeGuard":null,"tryCatchPattern":"match foreign_packages().await {\n    Err(e) if e.to_string().contains(\"pacman -Qm failed\") => {\n        clear_stale_db_lock();\n        retry().await?;\n    }\n    r => r?,\n}","preventionTips":["Don't run pacman concurrently with mise bootstrap","Remove stale /var/lib/pacman/db.lck only when no pacman runs","Initialize pacman keyring/db in fresh Arch containers"],"tags":["arch","pacman","aur","command-failed"],"backgroundTag":"http-error-response","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"}