{"record":{"id":"affa47bda31c3ddb","repo":"nikivdev/code","slug":"failed-to-extract-tarball","errorCode":null,"errorMessage":"Failed to extract tarball","messagePattern":"Failed to extract tarball","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upgrade.rs","lineNumber":396,"sourceCode":"    Ok(hex::encode(hasher.finalize()))\n}\n\nfn extract_release_bundle(tarball: &Path) -> Result<(tempfile::TempDir, PathBuf)> {\n    let temp_dir = tempfile::tempdir().context(\"Failed to create temp directory\")?;\n    let temp_path = temp_dir.path();\n\n    let status = Command::new(\"tar\")\n        .args([\n            \"-xzf\",\n            tarball.to_str().unwrap(),\n            \"-C\",\n            temp_path.to_str().unwrap(),\n        ])\n        .status()\n        .context(\"Failed to run tar\")?;\n\n    if !status.success() {\n        bail!(\"Failed to extract tarball\");\n    }\n\n    let bundle_root = fs::read_dir(temp_path)\n        .ok()\n        .and_then(|mut entries| entries.find_map(|entry| entry.ok().map(|item| item.path())))\n        .filter(|path| path.is_dir())\n        .unwrap_or_else(|| temp_path.to_path_buf());\n\n    Ok((temp_dir, bundle_root))\n}\n\nfn find_bundle_binary(bundle_root: &Path, binary_name: &str) -> Result<PathBuf> {\n    let direct = bundle_root.join(binary_name);\n    if direct.exists() {\n        return Ok(direct);\n    }\n\n    let binary_path = fs::read_dir(bundle_root)","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/upgrade.rs#L378-L414","documentation":"`extract_release_bundle` (src/upgrade.rs:381+) shells out to the system `tar -xzf` to unpack the downloaded release tarball into a temp dir. If the `tar` process spawns but exits non-zero, the upgrade bails with this message. It is a wrapper around external-tool failure, not a Rust parse error.","triggerScenarios":"`tar -xzf <tarball> -C <tmp>` exits non-zero: the tarball is corrupt/truncated (bad download), not gzip, `tar` binary is missing a needed format, or the archive layout is unexpected.","commonSituations":"Interrupted download leaving a partial file; GitHub asset replaced mid-upgrade; minimal container images shipping bsdtar/GNU tar variants that reject the archive; downloaded an HTML error page saved as the tarball.","solutions":["Delete any cached/partial tarball and re-run `f upgrade` to get a fresh download.","Verify the archive manually: `tar -tzf <file>` — if it fails, the download is corrupt.","Check sha256 against the release's checksums.txt before extracting.","Ensure a working `tar` supporting gzip is on PATH (`tar --version`); install one if missing.","If GitHub serves an error page instead of the asset, check rate limits / auth token and retry later."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before installing, verify the archive is valid\ntar -tzf \"$TARBALL\" > /dev/null && echo ok || echo \"corrupt tarball, re-download\"\nsha256sum \"$TARBALL\"  # compare with checksums.txt","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify sha256 against the release checksums.txt before extraction.","Ensure a gzip-capable `tar` is installed in minimal images.","Re-download after any interrupted transfer instead of reusing partial files.","Confirm the downloaded file is gzip (`file <tarball>`), not an HTML error page."],"tags":["tar","extraction","corrupt-download","upgrade"],"backgroundTag":"archive-extraction-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}