{"record":{"id":"927c8b94615dfaeb","repo":"jdx/mise","slug":"apk-info-failed","errorCode":null,"errorMessage":"apk info failed: {}","messagePattern":"apk info failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/apk.rs","lineNumber":95,"sourceCode":"        debug!(\"$ apk {}\", args.join(\" \"));\n        let output = tokio::process::Command::new(\"apk\")\n            .args(&args)\n            .stdin(Stdio::null())\n            .stdout(Stdio::piped())\n            .stderr(Stdio::piped())\n            .output()\n            .await?;\n        // apk info exits nonzero when any named package is not installed, but\n        // still prints installed package versions. Treat unexpected stderr as\n        // real apk failure instead of silently reporting everything missing.\n        let stderr = String::from_utf8_lossy(&output.stderr);\n        if !output.status.success()\n            && !stderr.is_empty()\n            && !stderr\n                .lines()\n                .all(|l| l.trim().is_empty() || l.contains(\"not found\"))\n        {\n            bail!(\"apk info failed: {}\", stderr.trim());\n        }\n        let stdout = String::from_utf8_lossy(&output.stdout);\n        Ok(parse_apk_info(&stdout, pkgs))\n    }\n\n    async fn install(&self, pkgs: &[PackageRequest], opts: &InstallOpts) -> Result<()> {\n        let mut args = vec![\"add\".to_string()];\n        if opts.update {\n            args.push(\"--update-cache\".to_string());\n        }\n        args.push(\"--\".to_string());\n        args.extend(pkgs.iter().map(apk_name));\n        if opts.dry_run {\n            miseprintln!(\"{}\", sudo::argv(\"apk\", &args).join(\" \"));\n            return Ok(());\n        }\n        sudo::run(\"apk\", &args, &[])\n    }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/system/packages/apk.rs#L77-L113","documentation":"mise's Alpine package backend runs `apk info <pkgs>` to learn which requested packages are already installed. apk exits nonzero when a named package is missing but still prints installed versions, so mise only treats the run as failed when the exit is nonzero AND stderr contains something other than blank or 'not found' lines. This error means apk itself reported a genuine failure, so the installed/missing report cannot be trusted.","triggerScenarios":"Any mise flow that inspects apk-managed packages (bootstrap, prune, or config entries using the apk backend) while the underlying `apk info` invocation writes a real error to stderr: unreadable or corrupted /lib/apk/db/installed, an apk binary from a mismatched Alpine release, or broken cache/repo state.","commonSituations":"Minimal or flattened Alpine container images where the apk database was deleted; mixing Alpine edge/stable repos leaving apk half-upgraded; running mise inside chroot/proot where apk's paths don't resolve; CI images that strip /lib/apk.","solutions":["Reproduce manually: run `apk info <package>` and read the stderr echoed in the message","Repair the package database: `apk update && apk fix` (or `apk verify`)","If apk itself is stale or foreign, upgrade it: `apk add --upgrade apk`","If apk cannot be made healthy (stripped container image), stop declaring apk packages in mise and install them in the Dockerfile instead"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async fn apk_info_healthy() -> bool {\n    tokio::process::Command::new(\"apk\")\n        .args([\"info\", \"--installed\"])\n        .stdin(std::process::Stdio::null())\n        .stdout(std::process::Stdio::null())\n        .stderr(std::process::Stdio::piped())\n        .output()\n        .await\n        .map(|o| o.status.success() || o.stderr.is_empty())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"Match the error message prefix \"apk info failed\" and treat it as an environment failure: surface it to the user and stop — never fall back to reporting all requested packages as missing, because a broken apk database makes that classification a lie.","preventionTips":["Keep /lib/apk/db/installed intact in Alpine images (don't flatten or prune it)","Verify `apk info --installed` works in your base image before relying on mise's apk backend","Run `apk fix` after any interrupted apk operation"],"tags":["alpine","apk","mise","package-manager","system-packages"],"backgroundTag":"package-manager-query-failed","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}