{"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/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/pacman.rs#L350-L386","documentation":"pacman -T (deptest) is used to check which package dependencies are missing. It exits 0 when all requirements are satisfied and 127 when some are unsatisfied (printing them to stdout); both are treated as normal. Any other exit code means pacman itself failed (bad DB, locked db, missing capability), and this error surfaces pacman's stderr.","triggerScenarios":"Calling resolve_installed_provider or installed on a system where `pacman -T <deps>` exits with a code other than 0 or 127 — e.g. corrupted/missing local package database, pacman database lock, or pacman not functioning on a non-Arch system.","commonSituations":"Running mise's pacman package provider on a non-Arch system or in a container where /var/lib/pacman is absent or uninitialized; another process holding the pacman db lock; partial pacman upgrade leaving the db inconsistent.","solutions":["Run `pacman -T bash` manually and read the stderr shown in the error to see the underlying pacman failure","Reinitialize or repair the pacman database (e.g. `pacman -Sy` after fixing any lock: remove /var/lib/pacman/db.lck if no pacman is running)","Confirm you are on an Arch-based system with pacman installed and in PATH; otherwise configure a different package provider","If running in a minimal container, install/initialize pacman (e.g. via the base pacman package) before using this provider"],"exampleFix":"// before (container without pacman db)\nmise packages install --provider pacman curl\n// error: pacman -T failed: error: failed to init transaction (unable to lock database)\n// after\npacman-key --init && pacman -Sy && mise packages install --provider pacman curl","handlingStrategy":"try-catch","validationCode":"if !command_exists(\"pacman\") { /* configure another provider */ }\nlet ok = Command::new(\"pacman\").args([\"-T\",\"bash\"]).status().map(|s| [0,127].contains(&s.code().unwrap_or(-1))).unwrap_or(false);","typeGuard":"fn pacman_usable(out: &Output) -> bool { matches!(out.status.code(), Some(0 | 127)) }","tryCatchPattern":"match provider.installed(&req).await {\n    Ok(status) => use(status),\n    Err(e) if e.to_string().contains(\"pacman -T failed\") => fallback_to_other_provider(),\n    Err(e) => return Err(e),\n}","preventionTips":["Verify pacman exists and the pacman db is initialized before selecting the pacman provider","Avoid running pacman operations concurrently with other pacman processes (db.lck)","In containers, run `pacman -Sy` once at setup before package queries"],"tags":["pacman","package-manager","subprocess","arch-linux"],"backgroundTag":"command-not-found","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}