hashicorp/packer · error
failed to open temp file: %w
Error message
failed to open temp file: %w
What it means
Despite the message, this error is not about creating the temp file: it fires when opening an entry inside the already-downloaded plugin zip archive fails. In InstallLatest, after the plugin zip is written to a temp file and opened with zip.OpenReader, the entry matching the expected plugin binary filename is located and f.Open() is called to get a reader for that entry; if that per-entry open fails (corrupt or truncated download, unsupported compression method, CRC/layout problems within the archive), the wrapped error is appended to the multierror list and installation of the plugin is aborted.
Source
Thrown at packer/plugin-getter/plugins.go:861
if err := checksum.Checksummer.Checksum(checksum.Expected, tmpFile); err != nil {
err := fmt.Errorf("%w. Is the checksum file correct ? Is the binary file correct ?", err)
errs = multierror.Append(errs, err)
continue
}
zr, err := zip.OpenReader(tmpFile.Name())
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("zip : %v", err))
return nil, errs
}
var copyFrom io.ReadCloser
for _, f := range zr.File {
if f.Name != expectedBinaryFilename {
continue
}
copyFrom, err = f.Open()
if err != nil {
errs = multierror.Append(errs, fmt.Errorf("failed to open temp file: %w", err))
return nil, errs
}
break
}
if copyFrom == nil {
err := fmt.Errorf("could not find a %q file in zipfile", expectedBinaryFilename)
errs = multierror.Append(errs, err)
return nil, errs
}
var outputFileData bytes.Buffer
if _, err := io.Copy(&outputFileData, copyFrom); err != nil {
err := fmt.Errorf("extract file: %w", err)
errs = multierror.Append(errs, err)
return nil, errs
}
tmpBinFileName := filepath.Join(os.TempDir(), expectedBinaryFilename)
tmpOutputFile, err := os.OpenFile(tmpBinFileName, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)View on GitHub (pinned to eb36e3c3e4)
Solutions
- Check the full download/verification log above this error: a checksum mismatch that was skipped or a truncated network transfer usually precedes a corrupt zip entry
- Delete the cached plugin download and retry `packer init` so the plugin zip is fetched again
- Verify the plugin's released zip artifact on the origin server is valid (open it manually with `unzip -t`), and report it to the plugin maintainer if it is broken
- If running behind a proxy or cached mirror, bypass it and re-download, since proxies sometimes corrupt binary zip content
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at packer/plugin-getter/plugins.go:861 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/81b44975a43cf90a.
Report an issue: GitHub.