hashicorp/packer · error
failed to open zip: %w
Error message
failed to open zip: %w
What it means
Runtime error from extractBinaryFromZip in the hcp-sbom provisioner: the downloaded Packer release zip could not be opened as an archive (zip.OpenReader failed) — a corrupted or truncated download, or an unreadable file path.
Source
Thrown at provisioner/hcp-sbom/provisioner.go:562
if err := p.runRemoteCmd(ctx, comm, chmodCmd, "chmod scanner binary"); err != nil {
return "", err
}
// Final verify: confirm binary is executable.
verifyCmd := fmt.Sprintf(`test -x "%s"`, remotePath)
if err := p.runRemoteCmd(ctx, comm, verifyCmd, "verify scanner is executable"); err != nil {
return "", fmt.Errorf("scanner binary is not executable at %s after chmod; "+
"check that /tmp is not mounted noexec on the remote host", remotePath)
}
}
return remotePath, nil
}
func extractBinaryFromZip(zipPath, binaryName string) ([]byte, error) {
zr, err := zip.OpenReader(zipPath)
if err != nil {
return nil, fmt.Errorf("failed to open zip: %w", err)
}
defer func() { _ = zr.Close() }()
for _, f := range zr.File {
if f.Name != binaryName {
continue
}
rc, err := f.Open()
if err != nil {
return nil, fmt.Errorf("failed to open %s from zip: %w", binaryName, err)
}
data, readErr := io.ReadAll(rc)
closeErr := rc.Close()
if readErr != nil {
return nil, fmt.Errorf("failed to read %s from zip: %w", binaryName, readErr)
}View on GitHub (pinned to eb36e3c3e4)
Solutions
- Retry the build to re-download the release zip
- Check disk space and network reliability; verify the zip opens with `unzip -t`
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at provisioner/hcp-sbom/provisioner.go:562 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/8f7f5dc9e7adb2e1.
Report an issue: GitHub.