{"record":{"id":"2898919833ae0ccf","repo":"jdx/mise","slug":"apk-failed-while-installing-oci-system-packages","errorCode":null,"errorMessage":"apk failed while installing OCI system packages: {}\n{}","messagePattern":"apk failed while installing OCI system packages: (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/packages.rs","lineNumber":376,"sourceCode":"        \"--root\".to_string(),\n        rootfs.display().to_string(),\n        \"--arch\".to_string(),\n        apk_architecture(architecture)?.to_string(),\n        \"--no-cache\".to_string(),\n        \"add\".to_string(),\n        \"--\".to_string(),\n    ];\n    args.extend(requests.iter().map(|request| match &request.version {\n        Some(version) => format!(\"{}={version}\", request.name),\n        None => request.name.clone(),\n    }));\n    info!(\"apk {}\", args.join(\" \"));\n    let output = Command::new(\"apk\")\n        .args(&args)\n        .output()\n        .wrap_err(\"running apk for OCI system packages\")?;\n    if !output.status.success() {\n        bail!(\n            \"apk failed while installing OCI system packages: {}\\n{}\",\n            output.status,\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(())\n}\n\nfn apt_install_into_rootfs(\n    rootfs: &Path,\n    requests: &[PackageRequest],\n    architecture: &str,\n) -> Result<()> {\n    let status = rootfs.join(\"var/lib/dpkg/status\");\n    if let Some(parent) = status.parent() {\n        file::create_dir_all(parent)?;\n    }\n    if !status.exists() {","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/packages.rs#L358-L394","documentation":"mise runs the host `apk` binary to install system packages into the OCI rootfs; if apk exits non-zero, mise bails with the exit status and trimmed stderr. The error surfaces an apk-level failure (bad package name, missing repo, network error, arch mismatch).","triggerScenarios":"`build_system_packages_layer` -> `apk_install_into_rootfs` runs `apk add --root <rootfs> ...` and the child process returns a non-zero status.","commonSituations":"Typo'd or nonexistent apk package names; apk repositories unreachable (offline CI, DNS failure); package unavailable for the target architecture; stale apk index in the base image.","solutions":["Read the stderr in the error message; fix the named package (typo, wrong repo) or remove it from `[bootstrap.packages]`.","Run `apk update`-equivalent by ensuring the base image's apk index is fresh, or add the needed repository to the image.","Check network/DNS access in the build environment (CI runners often lack it).","Verify the package supports the target architecture (see `apk_architecture` mapping)."],"exampleFix":"# before (mise.toml)\n[bootstrap.packages]\napk = [\"cur1\"]  # typo\n\n# after\n[bootstrap.packages]\napk = [\"curl\"]","handlingStrategy":"try-catch","validationCode":"// pre-check that package names exist in the Alpine repo\n// apk search -e '^curl$' inside an alpine container before adding to [bootstrap.packages]","typeGuard":null,"tryCatchPattern":"try { await miseOciBuild(cfg) } catch (e) { if (String(e).startsWith('apk failed while installing OCI system packages')) { console.error('apk stderr:', e.message.split('\\n').slice(1).join('\\n')); process.exit(1); } throw e; }","preventionTips":["Verify package names with `apk search` before adding them to config.","Ensure CI has network access to Alpine/Wolfi repositories.","Keep the base image's apk index fresh (recent base image build).","Confirm package availability for your target architecture."],"tags":["apk","subprocess","oci","package-install"],"backgroundTag":"command-failed","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"}