hashicorp/packer · error
Checksum: failed to open file for checksum: %s
Error message
Checksum: failed to open file for checksum: %s
What it means
Checksummer.ChecksumFile opens the downloaded plugin file to verify its checksum and returns this error when os.Open fails. It wraps the underlying OS error, so it almost always means the file does not exist, the path is wrong, or the process lacks read permission.
Source
Thrown at packer/plugin-getter/checksum.go:86
}
// ParseChecksum expects the checksum reader to only contain the checksum and
// nothing else.
func (c *Checksummer) ParseChecksum(f io.Reader) (Checksum, error) {
res := make([]byte, c.Hash.Size())
_, err := hex.NewDecoder(f).Read(res)
if err == io.EOF {
err = nil
}
return res, err
}
// ChecksumFile compares the expected checksum to the checksum of the file in
// filePath using the hash function.
func (c *Checksummer) ChecksumFile(expected []byte, filePath string) error {
f, err := os.Open(filePath)
if err != nil {
return fmt.Errorf("Checksum: failed to open file for checksum: %s", err)
}
defer f.Close()
err = c.Checksum(expected, f)
if cerr, ok := err.(*ChecksumError); ok {
cerr.File = filePath
}
return err
}
func (c *Checksummer) Sum(f io.Reader) ([]byte, error) {
c.Hash.Reset()
if _, err := io.Copy(c.Hash, f); err != nil {
return nil, fmt.Errorf("Failed to hash: %s", err)
}
return c.Hash.Sum(nil), nil
}
func (c *Checksummer) Checksum(expected []byte, f io.Reader) error {View on GitHub (pinned to eb36e3c3e4)
Solutions
- Re-run `packer init` / the install so the plugin file is re-downloaded.
- Check the file exists at the reported path (ls) and that permissions allow reading.
- Clear the plugin cache directory (e.g. ~/.packer.d/plugins) and retry.
- Check disk space and that no antivirus/EDR is removing downloaded binaries.
Defensive patterns
Strategy: validation
Validate before calling
if _, err := os.Stat(filePath); err != nil {
return fmt.Errorf("plugin file %s missing before checksum: %w", filePath, err)
}
err := cs.ChecksumFile(expected, filePath) Try / catch
if err != nil {
var pe *fs.PathError
if errors.As(err, &pe) && errors.Is(pe.Err, fs.ErrNotExist) { /* re-download the plugin */ }
} Prevention
- Ensure the download step completed and returned success before checksumming.
- Check disk space and permissions on the plugin cache directory.
- Clear a corrupt plugin cache and re-run installs rather than reusing stale files.
When it happens
Trigger: Called from InstallLatest (via Get) on the downloaded plugin binary path when the file wasn't actually downloaded, was moved/deleted between download and verification, or the path has wrong permissions/symlink issues.
Common situations: Plugin download partially failed leaving no file; disk full or antivirus quarantined the binary; running packer as a user without read access to the plugin cache directory; concurrent installs racing on the same file.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- failed to write local binary checksum file: %s
- ListInstallations: failed to list installed plugins: %s
- could not create plugin folder %q: %w
- could not create final plugin binary file: %w
- could not write final plugin binary file: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/99174fd89339536b.
Report an issue: GitHub.