{"record":{"id":"9c94552384104928","repo":"jdx/mise","slug":"mise-oci-needs-apk-on-path-to-install-apk-system","errorCode":null,"errorMessage":"mise oci needs `apk` on PATH to install apk system packages into the image","messagePattern":"mise oci needs `apk` on PATH to install apk system packages into the image","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/packages.rs","lineNumber":137,"sourceCode":"            .iter()\n            .map(ToString::to_string)\n            .collect::<Vec<_>>()\n            .join(\", \")\n    );\n    Ok(Some(SystemPackagesLayer {\n        blob: layer::build_layer_from_dir_preserve_metadata(&diff_dir, \"\")?,\n        manager: manager.name(),\n    }))\n}\n\nfn validate_host_requirements(manager: OciPackageManager) -> Result<()> {\n    match manager {\n        OciPackageManager::Apk => {\n            if std::env::consts::OS != \"linux\" {\n                bail!(\"mise oci needs a Linux host to install apk system packages into an image\");\n            }\n            if file::which(\"apk\").is_none() {\n                bail!(\"mise oci needs `apk` on PATH to install apk system packages into the image\");\n            }\n            if !crate::system::sudo::is_root() {\n                bail!(\n                    \"mise oci needs to run as root to install apk system packages because apk \\\n                     executes package scripts in a chroot\"\n                );\n            }\n        }\n        OciPackageManager::Apt => {\n            if file::which(\"apt-get\").is_none() {\n                bail!(\n                    \"mise oci needs `apt-get` on PATH to install apt system packages into the image\"\n                );\n            }\n            if file::which(\"dpkg\").is_none() {\n                bail!(\n                    \"mise oci needs `dpkg` on PATH to install apt system packages into the image\"\n                );","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/packages.rs#L119-L155","documentation":"mise installs apk packages into the image by invoking the host's `apk` binary against the image filesystem. If `apk` is not on PATH, the installation cannot proceed and mise fails with this error. Host OS (Linux) is validated first; this is the second check.","triggerScenarios":"Running `mise oci build` with `[bootstrap.packages] apk = [...]` on a Linux host where `apk` (e.g. from alpine's apk-tools) is not installed or not on PATH.","commonSituations":"Building an Alpine-based image on a Debian/Ubuntu host that lacks apk-tools; minimal CI containers without apk; PATH stripped by sudo or the CI environment.","solutions":["Install apk-tools on the host (`apt-get install apk-tools` on Debian/Ubuntu, or the equivalent package)","Fix PATH so the `apk` binary is visible to mise (check PATH under sudo/CI)","Run the build inside an Alpine-based container where apk is present"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"command -v apk >/dev/null || echo \"apk not on PATH; install apk-tools before building\"","typeGuard":null,"tryCatchPattern":"match build() {\n    Err(e) if e.to_string().contains(\"needs `apk` on PATH\") => {\n        eprintln!(\"install apk-tools or run the build in an Alpine container\");\n    }\n    r => r,\n}","preventionTips":["Preinstall required package-manager binaries in CI images","Sanity-check PATH in build scripts (command -v apk)","Prefer running Alpine builds inside Alpine containers","Pin build-environment docs listing required host binaries"],"tags":["oci","apk","missing-binary"],"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"}