{"record":{"id":"8e336845432c9a61","repo":"jdx/mise","slug":"mise-oci-needs-a-linux-host-to-install-apk-system","errorCode":null,"errorMessage":"mise oci needs a Linux host to install apk system packages into an image","messagePattern":"mise oci needs a Linux host to install apk system packages into an image","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/packages.rs","lineNumber":134,"sourceCode":"        \"oci: adding {} system packages: {}\",\n        manager.name(),\n        requests\n            .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() {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/packages.rs#L116-L152","documentation":"Installing apk packages into an image is done on the host by invoking apk against the image root filesystem (chroot-style). apk tooling only works on Linux, so mise validates the host OS first and refuses with this error when building on macOS, Windows, or other non-Linux systems.","triggerScenarios":"Running `mise oci build` with `[bootstrap.packages] apk = [...]` on a non-Linux host, causing `validate_host_requirements` (via `build_system_packages_layer`) to check `std::env::consts::OS != \"linux\"`.","commonSituations":"Developer building an Alpine-based image on a macOS laptop; CI runner on Windows; container-in-container where the host is not Linux.","solutions":["Run the build on a Linux machine or Linux CI runner","Use a Linux container/Docker to host the build (build inside `docker run --platform linux`)","Switch to a package manager that doesn't require a Linux host, or drop the apk packages"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before running the build\n[ \"$(uname -s)\" = \"Linux\" ] || echo \"apk package installs require a Linux host\"","typeGuard":null,"tryCatchPattern":"match build() {\n    Err(e) if e.to_string().contains(\"needs a Linux host\") => {\n        eprintln!(\"rerun inside a Linux container or on a Linux CI runner\");\n    }\n    r => r,\n}","preventionTips":["Run oci image builds on Linux runners in CI","Wrap builds in a Linux container on developer machines","Keep platform-dependent steps out of shared build scripts","Document host requirements next to the bootstrap config"],"tags":["oci","platform","apk"],"backgroundTag":"unsupported-platform","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"}