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

  1. Re-run `packer init` / the install so the plugin file is re-downloaded.
  2. Check the file exists at the reported path (ls) and that permissions allow reading.
  3. Clear the plugin cache directory (e.g. ~/.packer.d/plugins) and retry.
  4. 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

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


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/99174fd89339536b. Report an issue: GitHub.