{"record":{"id":"55edabc06fa81449","repo":"heygen-com/hyperframes","slug":"build-zip-label-at-path-is-not-a-linux-x86","errorCode":null,"errorMessage":"[build-zip] ${label} at ${path} is not a Linux x86-64 ELF executable (magic=0x${magicHex}, ei_class=${head[4]}, e_machine=0x${machine.toString(16)}). This usually means the deploy host's postinstall fetched a host-platform binary (e.g. macOS arm64 ffmpeg) instead of the linux/x64 binary Lambda needs. Re-run the build inside a linux/amd64 container, or pre-install with `npm_config_platform=linux npm_config_arch=x64` so the package fetches the right binary.","messagePattern":"\\[build-zip\\] (.+?) at (.+?) is not a Linux x86-64 ELF executable \\(magic=0x(.+?), ei_class=(.+?), e_machine=0x(.+?)\\)\\. This usually means the deploy host's postinstall fetched a host-platform binary \\(e\\.g\\. macOS arm64 ffmpeg\\) instead of the linux/x64 binary Lambda needs\\. Re-run the build inside a linux/amd64 container, or pre-install with `npm_config_platform=linux npm_config_arch=x64` so the package fetches the right binary\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/aws-lambda/scripts/build-zip.ts","lineNumber":369,"sourceCode":"const ELF_MACHINE_X86_64 = 0x3e;\nconst ELF_HEADER_BYTES = 20;\n\n/**\n * Verify the binary at `path` is a Linux x86-64 ELF executable, the only\n * shape the Lambda runtime can exec. Throws with the canonical workaround\n * (Docker `--platform=linux/amd64` or `npm_config_platform` /\n * `npm_config_arch` overrides) so the build doesn't ship a silently\n * broken zip when a non-Linux host's postinstall fetched the wrong arch.\n */\nfunction assertLinuxX86_64Elf(path: string, label: string): void {\n  const head = readFileHead(path, ELF_HEADER_BYTES, label);\n  const isElf = head.subarray(0, 4).equals(ELF_MAGIC);\n  const isElf64 = head[4] === ELF_CLASS_64;\n  const machine = head.readUInt16LE(18);\n  if (isElf && isElf64 && machine === ELF_MACHINE_X86_64) return;\n\n  const magicHex = head.subarray(0, 4).toString(\"hex\");\n  throw new Error(\n    `[build-zip] ${label} at ${path} is not a Linux x86-64 ELF executable ` +\n      `(magic=0x${magicHex}, ei_class=${head[4]}, e_machine=0x${machine.toString(16)}). ` +\n      `This usually means the deploy host's postinstall fetched a host-platform binary ` +\n      `(e.g. macOS arm64 ffmpeg) instead of the linux/x64 binary Lambda needs. ` +\n      `Re-run the build inside a linux/amd64 container, or pre-install with ` +\n      `\\`npm_config_platform=linux npm_config_arch=x64\\` so the package fetches the right binary.`,\n  );\n}\n\nfunction readFileHead(path: string, byteCount: number, label: string): Buffer {\n  const fd = openSync(path, \"r\");\n  try {\n    const buf = Buffer.alloc(byteCount);\n    const bytesRead = readSync(fd, buf, 0, byteCount, 0);\n    if (bytesRead < byteCount) {\n      throw new Error(\n        `[build-zip] ${label} at ${path} is too short — read ${bytesRead} of ${byteCount} bytes.`,\n      );","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/aws-lambda/scripts/build-zip.ts#L351-L387","documentation":"assertLinuxX86_64Elf reads the first bytes of a binary and verifies the ELF magic (7f 45 4c 46), ELFCLASS64 (byte 4 equals 2), and e_machine equals EM_X86_64 (0x3E at offset 18). If any check fails it throws, because Lambda runs Linux x86-64 and a host-platform binary (e.g., macOS arm64 Mach-O) would deploy but crash at runtime with 'cannot execute binary file'.","triggerScenarios":"Building the Lambda zip on a non-Linux-x64 host (macOS, Windows, or Linux arm64). The ffmpeg-static, ffprobe-static, or chrome-headless-shell postinstall fetched a binary for the build host's platform instead of the linux/x64 binary Lambda needs.","commonSituations":"Developer building directly on macOS (Apple Silicon or Intel); CI runner that is not linux/amd64; building on a Linux arm64 machine.","solutions":["Build inside a linux/amd64 Docker container: docker run --platform=linux/amd64.","Set npm_config_platform=linux and npm_config_arch=x64 before installing so packages fetch linux/x64 binaries.","Use CI runners with linux/amd64 architecture."],"exampleFix":"// before (on macOS)\ntsx packages/aws-lambda/scripts/build-zip.ts\n\n// after\ndocker run --platform=linux/amd64 --rm -v \"$PWD\":/work -w /work node:20 \\\n  tsx packages/aws-lambda/scripts/build-zip.ts","handlingStrategy":"validation","validationCode":"import { platform, arch } from \"node:os\";\nif (platform() !== \"linux\" || arch() !== \"x64\") {\n  console.error(\n    `Build host is ${platform()}/${arch()}, but Lambda needs linux/x64 binaries. ` +\n    `Build inside a linux/amd64 container or set npm_config_platform=linux npm_config_arch=x64.`,\n  );\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the Lambda zip exclusively in a linux/amd64 environment.","Set npm_config_platform=linux and npm_config_arch=x64 before install if building on another platform.","Add a platform check at the start of the CI build job."],"tags":["cross-platform","elf","binary-architecture","aws-lambda","build"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}