{"record":{"id":"0bf6d975a43502de","repo":"midudev/autoskills","slug":"tar-extract-failed-status-r-status","errorCode":null,"errorMessage":"tar extract failed (status ${r.status})","messagePattern":"tar extract failed \\(status (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/autoskills/scripts/sync-skills.mjs","lineNumber":319,"sourceCode":"    // pulling in unrelated repo content.\n    const filtered = pick === \"\" ? blobs.filter((t) => t.path === \"SKILL.md\") : blobs;\n    for (const blob of filtered) {\n      const rel = pick === \"\" ? blob.path : blob.path.slice(pick.length + 1);\n      if (shouldSkipSkillFile(rel)) continue;\n      const dest = join(destRoot, skillName, rel);\n      await downloadRawFile(repo, sha, blob.path, dest);\n    }\n    found.set(skillName, join(destRoot, skillName));\n  }\n  return found;\n}\n\nfunction extractTarball(tarFile, destDir) {\n  const r = spawnSync(\"tar\", [\"-xzf\", tarFile, \"-C\", destDir], {\n    stdio: FLAGS.verbose ? \"inherit\" : \"pipe\",\n  });\n  if (r.status !== 0) {\n    throw new Error(`tar extract failed (status ${r.status})`);\n  }\n  const entries = readdirSync(destDir);\n  const root = entries.find((e) => statSync(join(destDir, e)).isDirectory());\n  if (!root) throw new Error(`Empty tarball in ${destDir}`);\n  return join(destDir, root);\n}\n\nfunction runGit(args, label) {\n  const result = spawnSync(\"git\", args, {\n    encoding: \"utf-8\",\n    stdio: [\"ignore\", \"pipe\", \"pipe\"],\n  });\n  if (result.status !== 0) {\n    throw new Error(`${label} failed: ${result.stderr.trim() || \"unknown error\"}`);\n  }\n  return result.stdout;\n}\n","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/midudev/autoskills/blob/0ec725320d2137253ab2e68e7ba8a072148e741a/packages/autoskills/scripts/sync-skills.mjs#L301-L337","documentation":"extractTarball shells out to the system `tar -xzf` to unpack a downloaded repo tarball. If tar exits with a non-zero status, the script throws this error including the exit code. It indicates the archive is corrupt/incomplete or the destination is unusable — the script does not include tar's stderr unless --verbose is set.","triggerScenarios":"spawnSync(\"tar\", [\"-xzf\", tarFile, \"-C\", destDir]) returns status !== 0 — truncated/corrupt download, disk full, no write permission in destDir, or `tar` failing on the gzip stream.","commonSituations":"A previous sync was interrupted leaving a partial tarball; the download failed silently earlier and the file is 0 bytes; destDir sits on a full or read-only filesystem; unusual tarball format from a non-GitHub source.","solutions":["Delete the cached tarball and re-run so it is re-downloaded (fixes corrupt/truncated archives)","Re-run with --verbose to see tar's actual stderr","Check free disk space and write permissions on destDir","Test manually: `tar -xzf <tarball> -C <destDir>` to see the underlying error"],"exampleFix":"// before\nawait syncSkills({}); // stale corrupt tarball in cache\n// after\nrmSync(cacheDir, { recursive: true, force: true }); // clear cache, then\nawait syncSkills({});","handlingStrategy":"validation","validationCode":"// validate the tarball before extracting\nimport { statSync } from \"node:fs\";\nconst st = statSync(tarFile);\nif (st.size < 100) throw new Error(`tarball suspiciously small (${st.size}B); re-download`);\nexecSync(`tar -tzf ${tarFile} > /dev/null`); // integrity test; throws with real tar error","typeGuard":null,"tryCatchPattern":"try {\n  await syncSkills(opts);\n} catch (err) {\n  if (err.message.startsWith(\"tar extract failed\")) {\n    const status = err.message.match(/status (\\d+)/)?.[1];\n    console.error(`tar exited ${status}; clear cache and re-download, run with --verbose for tar stderr`);\n  } else throw err;\n}","preventionTips":["Clear the download cache when a previous run was interrupted","Always test downloads with `tar -tzf` before extracting","Ensure adequate disk space in the destination filesystem","Run with --verbose to capture tar's stderr for diagnosis"],"tags":["tar","filesystem","extraction"],"backgroundTag":"command-not-found","analyzedSha":"0ec725320d2137253ab2e68e7ba8a072148e741a","analyzedAt":"2026-09-15T14:12:31.090Z","contentChangedAt":"2026-09-15T14:12:31.090Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}