{"record":{"id":"7691e51d2c3eca59","repo":"jdx/mise","slug":"rpm-q-failed","errorCode":null,"errorMessage":"rpm -q failed: {}","messagePattern":"rpm -q failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/dnf.rs","lineNumber":135,"sourceCode":"        let output = tokio::process::Command::new(\"rpm\")\n            .args(&args)\n            .stdin(Stdio::null())\n            .stdout(Stdio::piped())\n            .stderr(Stdio::piped())\n            .output()\n            .await?;\n        // rpm -q exits nonzero when any package is not installed; \"package X\n        // is not installed\" goes to stdout or stderr depending on rpm version\n        // and won't match the \\t format either way — absent packages parse as\n        // Missing. Only fail on rpm errors unrelated to missing packages.\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        if !output.status.success()\n            && !stderr.is_empty()\n            && !stderr.lines().all(|l| {\n                l.trim().is_empty() || l.contains(\"is not installed\") || l.contains(\"no packages\")\n            })\n        {\n            bail!(\"rpm -q failed: {}\", stderr.trim());\n        }\n        let stdout = String::from_utf8_lossy(&output.stdout);\n        Ok(parse_rpm_query(&stdout, pkgs))\n    }\n\n    async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        let args = install_args(pkgs, opts);\n        if opts.dry_run {\n            miseprintln!(\"{}\", sudo::argv(\"dnf\", &args).join(\" \"));\n            return Ok(());\n        }\n        sudo::run(\"dnf\", &args, &[])\n    }\n\n    async fn upgrade(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        let args = upgrade_args(pkgs);\n        if opts.dry_run {\n            miseprintln!(\"{}\", sudo::argv(\"dnf\", &args).join(\" \"));","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/dnf.rs#L117-L153","documentation":"The DNF system package manager runs `rpm -q` to check installed packages. rpm's non-zero exit is normally interpreted as 'not installed', but if stderr contains lines that are neither blank nor the known 'is not installed'/'no packages' notices, dnf.rs treats it as a genuine rpm failure and bails with the stderr text.","triggerScenarios":"installed() runs `rpm -q <pkgs>`; the command exits non-zero with stderr lines not matching the whitelisted patterns (e.g. real rpm errors, database lock messages, unrelated warnings).","commonSituations":"Corrupted rpm database; `rpm` not the expected version; concurrent package operations locking the db; localized (non-English) rpm messages that don't contain the English patterns.","solutions":["Run `rpm -q <pkg>` manually to see the underlying stderr error","Fix the rpm database (e.g. rebuild via `rpm --rebuilddb`) if corrupted","Set locale to C (LC_ALL=C) so rpm messages match the expected English patterns","Ensure no concurrent package manager process holds the rpm db"],"exampleFix":"// before\n$ LC_ALL=de_DE rpm -q curl   # localized stderr not recognized\n// after\n$ LC_ALL=C rpm -q curl","handlingStrategy":"fallback","validationCode":"let out = std::process::Command::new(\"rpm\").args([\"-q\", pkg]).output()?;\nlet ok = out.status.success()\n    || String::from_utf8_lossy(&out.stderr).lines().all(|l| {\n        l.trim().is_empty() || l.contains(\"is not installed\") || l.contains(\"no packages\")\n    });","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"rpm -q failed\") => {\n        eprintln!(\"rpm query failed: {e}; check rpm db and locale\");\n    }\n    other => { let _ = other; }\n}","preventionTips":["Run with LC_ALL=C so rpm messages match expected patterns","Avoid concurrent rpm/dnf operations","Rebuild a corrupted rpm database promptly"],"tags":["dnf","rpm","system-packages"],"backgroundTag":"command-not-found","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"}