{"record":{"id":"4d2a7134d47f7ac0","repo":"denoland/deno","slug":"failed-to-unpack-archive","errorCode":null,"errorMessage":"Failed to unpack archive.","messagePattern":"Failed to unpack archive\\.","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"cli/util/archive.rs","lineNumber":55,"sourceCode":"    Command::new(\"unzip\")\n      .current_dir(dest_path)\n      .arg(archive_path)\n      .spawn()\n      .map_err(|err| {\n        if err.kind() == std::io::ErrorKind::NotFound {\n          std::io::Error::new(\n            std::io::ErrorKind::NotFound,\n            \"`unzip` was not found in your PATH, please install `unzip`\",\n          )\n        } else {\n          err\n        }\n      })?\n      .wait()?\n  };\n\n  if !unpack_status.success() {\n    bail!(\"Failed to unpack archive.\");\n  }\n\n  Ok(())\n}\n\nfn unzip(\n  archive_name: &str,\n  archive_data: &[u8],\n  dest_path: &Path,\n) -> Result<(), AnyError> {\n  let mut archive = zip::ZipArchive::new(std::io::Cursor::new(archive_data))?;\n  archive\n    .extract(dest_path)\n    .with_context(|| format!(\"failed to extract archive: {archive_name}\"))?;\n\n  Ok(())\n}\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/util/archive.rs#L37-L73","documentation":"`unpack_into_dir` extracts downloaded zips with the zip crate and, when that fails or produces no executable, falls back to shelling out to `unzip` (unix) or `tar.exe` (Windows) in `unzip_with_shell`. This error means the fallback child process ran to completion but exited non-zero: the external tool saw the archive bytes and still could not extract them. A missing `unzip` produces a different, explicit 'not found in your PATH' io error instead.","triggerScenarios":"The zip-crate path fails (corrupt/truncated download, disk full mid-extract, unwritable destination) and the shell fallback also exits non-zero. Typical during `deno upgrade` or first-run toolchain downloads when a proxy truncated the body, TMPDIR/DENO_DIR is full or read-only, or the cached zip is damaged and reused.","commonSituations":"Flaky corporate proxies corrupting downloaded zips; CI runners with tiny tmpfs filling up; sandboxed environments where unzip cannot write to the destination; a corrupted download cache that keeps serving the same bad archive across retries.","solutions":["Check free space and write permissions on TMPDIR and DENO_DIR (`df -h`, touch a file), then retry.","Delete the cached download so it is fetched fresh: remove the relevant folders under DENO_DIR (e.g. dl/deps caches) and re-run the command.","Verify the cached archive directly with `unzip -t <file>.zip`; if it reports errors, the download was corrupted — clear the cache and re-download.","In sandboxed setups, ensure the `unzip`/`tar.exe` child process has the same filesystem permissions as Deno itself."],"exampleFix":"# before: 'Failed to unpack archive.' during deno upgrade\ndf -h \"$TMPDIR\" \"${DENO_DIR:-$HOME/.cache/deno}\"      # rule out ENOSPC\nrm -rf \"${DENO_DIR:-$HOME/.cache/deno}/dl\"            # drop cached downloads\ndeno upgrade                                           # re-download and unpack","handlingStrategy":"retry","validationCode":"# validate the cached archive before extraction attempts\nunzip -t \"$archive\" >/dev/null 2>&1 || echo \"corrupt archive — delete and re-download\"","typeGuard":null,"tryCatchPattern":"// one clean retry after removing partial output\nlet exe = match unpack_into_dir(args.clone()) {\n  Ok(p) => p,\n  Err(e) if e.to_string().contains(\"Failed to unpack archive\") => {\n    let _ = std::fs::remove_dir_all(&dest); // clear partial extraction\n    unpack_into_dir(args)? // retry with clean state\n  }\n  Err(e) => return Err(e),\n};","preventionTips":["Keep TMPDIR and DENO_DIR on filesystems with adequate free space.","Verify checksums of manually supplied archives before unpacking.","In CI, cache the extracted toolchain rather than re-downloading zips every run."],"tags":["archive","zip","download","upgrade","disk-space"],"backgroundTag":"archive-extraction-failed","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}