{"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/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/dnf.rs#L117-L153","documentation":"The dnf/rpm system package manager runs `rpm -q` to check installed packages. rpm normally reports not-installed packages on stderr (\"package X is not installed\", \"no package X provided\"); the library tolerates those lines but treats any other non-empty stderr as a real query failure and bails with this error containing the stderr text.","triggerScenarios":"`rpm -q` exits non-status-success AND stderr is non-empty AND at least one stderr line is neither blank nor contains \"is not installed\" / \"no packages\" — e.g. rpm database errors, permission problems, malformed package arguments, or rpm not functioning.","commonSituations":"Corrupt or locked RPM database (/var/lib/rpm) on a minimal container; running without root where the rpm db is unreadable; a requested package name with invalid characters that rpm rejects; SELinux or dbenv failures; partially installed rpm/dnf on non-RHEL systems.","solutions":["Read the stderr in the message to see the actual rpm failure and fix that underlying issue.","Run with appropriate privileges (root/sudo) if the rpm database is unreadable.","Rebuild the rpm database (rpm --rebuilddb) if it is corrupt or locked.","Verify rpm is correctly installed and the package names passed are valid rpm identifiers."],"exampleFix":"// before: failing due to unreadable rpm db\nrpm -q curl  # error: cannot open Packages database in /var/lib/rpm\n// after\nsudo rpm --rebuilddb && rpm -q curl","handlingStrategy":"try-catch","validationCode":"// Pre-check rpm availability and db readability before querying\nif !Path::new(\"/usr/bin/rpm\").exists() { return Err(anyhow!(\"rpm not available\")); }\nlet db_ok = std::process::Command::new(\"rpm\").args([\"-q\", \"rpm\"]).output()\n    .map(|o| o.status.success()).unwrap_or(false);","typeGuard":null,"tryCatchPattern":"match dnf_manager.installed(&pkgs).await {\n    Err(e) if e.to_string().starts_with(\"rpm -q failed\") => {\n        eprintln!(\"rpm query failed: {e}; falling back to dnf list installed\");\n        dnf_list_installed(&pkgs).await\n    }\n    other => other,\n}","preventionTips":["Run package queries with sufficient privileges (root or readable /var/lib/rpm)","Keep the rpm database healthy; run rpm --rebuilddb after db corruption","Use valid rpm package identifiers (no version constraints in -q names)","Verify dnf/rpm is functional on the host before using this manager"],"tags":["system-packages","rpm","dnf","linux","subprocess"],"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-14T05:17:10.506Z"}