{"record":{"id":"156838765bbd8332","repo":"jdx/mise","slug":"pacman-t-failed","errorCode":null,"errorMessage":"pacman -T failed: {}","messagePattern":"pacman -T failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/pacman.rs","lineNumber":368,"sourceCode":"    if names.is_empty() {\n        return Ok(String::new());\n    }\n    let mut args = vec![\"-T\", \"--\"];\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        .env(\"LC_ALL\", \"C\")\n        .stdin(Stdio::null())\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped())\n        .output()\n        .await?;\n    // deptest returns 127 when at least one requirement is unsatisfied and\n    // prints those requirements to stdout. Both 0 and 127 are normal.\n    if !matches!(output.status.code(), Some(0 | 127)) {\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        bail!(\"pacman -T failed: {}\", stderr.trim());\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\npub(super) async fn resolve_installed_provider(\n    request: &PackageRequest,\n    eligible_names: &HashSet<String>,\n) -> Result<Option<(String, PackageState)>> {\n    let requirement = deptest_requirement(request);\n    let deptest = pacman_deptest(&[requirement]).await?;\n    let unsatisfied = parse_pacman_deptest(&deptest);\n    let constraint_satisfied = unsatisfied.is_empty();\n    if !constraint_satisfied {\n        if request.version.is_none() {\n            return Ok(None);\n        }\n        let bare_deptest = pacman_deptest(std::slice::from_ref(&request.name)).await?;\n        let bare_missing = parse_pacman_deptest(&bare_deptest);","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/pacman.rs#L350-L386","documentation":"The pacman dependency-test command `pacman -T` exits 0 when all requirements are satisfied and 127 when some are missing (printing them to stdout) — both are normal outcomes mise accepts. Any other exit code means `pacman -T` itself failed, and mise propagates pacman's stderr under this message. It is used by deptest, which backs `resolve_installed_provider` and `installed`.","triggerScenarios":"Calling the backend's `installed` status path or `resolve_installed_provider` when `pacman -T <deps>` terminates with a signal or an exit code other than 0/127, e.g. due to a database error or an unparseable argument list.","commonSituations":"Corrupt or locked pacman local database; package names containing characters pacman rejects; running on a non-Arch system where pacman is a stub or a different implementation returning non-standard codes; disk-full conditions during db access.","solutions":["Reproduce `pacman -T <dep names>` in a shell and read the stderr printed in the error message to fix the underlying pacman problem.","Clear a stale pacman lock (remove /var/lib/pacman/db.lck once no pacman process is running).","Repair the local database (e.g. `pacman -Syyu`, or restore /var/lib/pacman/local from backup).","Confirm the host is Arch-based; on other distros mise should use the native package backend instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm `pacman -T` behaves normally before dependency-testing via mise\nconst probe = await sh(\"pacman -T bash >/dev/null 2>&1; echo $?\");\nconst code = Number(probe.trim());\nif (![0, 127].includes(code)) throw new Error(`pacman -T returned unexpected code ${code}; repair pacman db first`);","typeGuard":null,"tryCatchPattern":"try { await miseCheckInstalled(pkg) } catch (e) { if (String(e).includes('pacman -T failed')) { console.error('pacman deptest broke:', e.message.split(': ').slice(1).join(': ')); } else throw e; }","preventionTips":["Repair a suspicious local db early (`pacman -Syyu`, restore /var/lib/pacman/local) before running mise package operations.","Only use the pacman backend on genuine Arch-based hosts.","Pass plain package names/dependency specifiers pacman can parse; avoid shell metacharacters.","Watch disk space — db access failures often stem from a full filesystem."],"tags":["pacman","package-manager","external-command","arch-linux"],"backgroundTag":"pacman-query-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"}