{"record":{"id":"a83d7207b93ce84e","repo":"jdx/mise","slug":"apt-get-failed-while-installing-oci-system-package","errorCode":null,"errorMessage":"apt-get failed while installing OCI system packages: {}\n{}","messagePattern":"apt-get failed while installing OCI system packages: (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/oci/packages.rs","lineNumber":498,"sourceCode":"        \"APT::Sandbox::User=root\".to_string(),\n        \"-o\".to_string(),\n        format!(\"APT::Architecture={}\", apt_architecture(architecture)?),\n        \"-o\".to_string(),\n        format!(\"DPkg::Options::=--root={}\", rootfs.display()),\n        \"-o\".to_string(),\n        \"DPkg::Options::=--force-not-root\".to_string(),\n    ])\n}\n\nfn run_apt_get(args: Vec<String>) -> Result<()> {\n    info!(\"apt-get {}\", args.join(\" \"));\n    let output = Command::new(\"apt-get\")\n        .args(&args)\n        .env(\"DEBIAN_FRONTEND\", \"noninteractive\")\n        .output()\n        .wrap_err(\"running apt-get for OCI system packages\")?;\n    if !output.status.success() {\n        bail!(\n            \"apt-get failed while installing OCI system packages: {}\\n{}\",\n            output.status,\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(())\n}\n\n/// Normalize the non-reproducible state that apt/dpkg postinstall scripts\n/// leave behind, so re-running `mise oci build` with identical inputs yields a\n/// byte-identical package layer (the reproducibility guarantee mise documents).\n/// Everything cleared here is a regenerable cache, a timestamped log, or a\n/// first-boot sentinel, never real package content.\nfn clean_apt_transients(rootfs: &Path) -> Result<()> {\n    // apt's own download cache and package lists.\n    remove_dir_children(&rootfs.join(\"var/cache/apt/archives\"))?;\n    remove_path(&rootfs.join(\"var/cache/apt/pkgcache.bin\"))?;\n    remove_path(&rootfs.join(\"var/cache/apt/srcpkgcache.bin\"))?;","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/oci/packages.rs#L480-L516","documentation":"mise runs the host `apt-get` binary (with DEBIAN_FRONTEND=noninteractive) to install system packages into the OCI rootfs; a non-zero exit status produces this error carrying the status and trimmed stderr. It indicates an apt-level failure such as unresolvable dependencies or missing packages.","triggerScenarios":"`apt_install_into_rootfs` -> `run_apt_get` executes `apt-get install ...` against the rootfs and the process exits non-zero.","commonSituations":"Typo'd apt package names; apt lists not updated in the base image (run `apt-get update` first); unreachable Ubuntu/Debian mirrors from CI; architecture-unavailable packages.","solutions":["Read the stderr in the error message; fix or remove the offending package from `[bootstrap.packages]`.","Ensure apt lists are fresh (mise's prepare step usually updates; check the base image wasn't trimmed).","Check network access to Debian/Ubuntu mirrors in the build environment.","Verify the package exists for the mapped apt architecture (amd64/arm64)."],"exampleFix":"# before (mise.toml)\n[bootstrap.packages]\napt = [\"build-essental\"]  # typo\n\n# after\n[bootstrap.packages]\napt = [\"build-essential\"]","handlingStrategy":"try-catch","validationCode":"// pre-check that package names exist in Debian/Ubuntu repos\n// apt-cache policy <pkg> or rmadison <pkg> before adding to [bootstrap.packages]","typeGuard":null,"tryCatchPattern":"try { await miseOciBuild(cfg) } catch (e) { if (String(e).startsWith('apt-get failed while installing OCI system packages')) { console.error('apt-get stderr:', e.message.split('\\n').slice(1).join('\\n')); process.exit(1); } throw e; }","preventionTips":["Verify package names with `apt-cache`/`rmadison` before adding them to config.","Ensure CI can reach Debian/Ubuntu mirrors.","Use a base image whose apt lists are up to date.","Confirm package availability for the mapped apt arch (amd64/arm64)."],"tags":["apt","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"}