heygen-com/hyperframes · error · Error

[build-zip] zip exited with status ${result.status}

Error message

[build-zip] zip exited with status ${result.status}

What it means

zipDirectory runs the system 'zip -rq <zipPath> .' inside the staging directory. If the zip utility exits non-zero, the build throws. This means zip is not installed, ran out of disk space, or encountered a filesystem error such as permissions or path-length issues.

Source

Thrown at packages/aws-lambda/scripts/build-zip.ts:498

function compareSemver(a: string, b: string): number {
  const partsA = a.split(".").map((s) => Number.parseInt(s, 10));
  const partsB = b.split(".").map((s) => Number.parseInt(s, 10));
  const len = Math.max(partsA.length, partsB.length);
  for (let i = 0; i < len; i++) {
    const ai = partsA[i] ?? 0;
    const bi = partsB[i] ?? 0;
    if (Number.isNaN(ai) && Number.isNaN(bi)) continue;
    if (Number.isNaN(ai)) return -1;
    if (Number.isNaN(bi)) return 1;
    if (ai !== bi) return ai - bi;
  }
  return 0;
}

function zipDirectory(sourceDir: string, zipPath: string): void {
  const result = spawnSync("zip", ["-rq", zipPath, "."], { cwd: sourceDir, stdio: "inherit" });
  if (result.status !== 0) {
    throw new Error(`[build-zip] zip exited with status ${result.status}`);
  }
}

function directorySizeBytes(dir: string): number {
  // Use spawnSync (no shell) instead of execSync so `dir` is passed as
  // an argv element rather than interpolated into a shell command —
  // CodeQL's `js/shell-command-injected-from-environment` rule fires
  // on the latter even with JSON-quoting. `du -sb` is Linux-only;
  // build-zip is CI-side where Linux coreutils is present.
  const result = spawnSync("du", ["-sb", dir], { encoding: "utf-8" });
  if (result.status === 0 && result.stdout) {
    const bytes = Number.parseInt(result.stdout.split(/\s+/)[0] ?? "0", 10);
    if (!Number.isNaN(bytes)) return bytes;
  }
  return walkSize(dir);
}

function walkSize(dir: string): number {

View on GitHub (pinned to c2996c8626)

Solutions

  1. Install zip: apt-get install -y zip (Debian/Ubuntu) or apk add zip (Alpine).
  2. Check available disk space: df -h.
  3. Check permissions on the staging directory and its contents.

Example fix

// before (Dockerfile)
FROM node:20-alpine
RUN npm install

// after
FROM node:20-alpine
RUN apk add --no-cache zip && npm install
Defensive patterns

Strategy: validation

Validate before calling

import { spawnSync } from "node:child_process";
const check = spawnSync("which", ["zip"], { encoding: "utf-8" });
if (check.status !== 0) {
  console.error("'zip' is not installed. Install it: apt-get install -y zip (or apk add zip on Alpine).");
  process.exit(1);
}

Prevention

When it happens

Trigger: The zip utility is not available on the build host; disk is full; permission errors on files in staging; a path too long for zip to handle.

Common situations: Minimal Docker image (e.g., node:20-alpine or node:20-slim) without zip installed; CI runner out of disk space.

Related errors


AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12). Data as JSON: /api/errors/786ba914130331c2. Report an issue: GitHub.