hashicorp/packer · warning

failed to checksum binary file: %s

Error message

failed to checksum binary file: %s

What it means

After writing the plugin binary, InstallLatest computes a checksum over the buffered data. If checksum.Checksummer.Sum fails, the error is appended but explicitly logged as a warning and installation continues. This means the .SHA256SUM-sidecar may be missing/stale for the installed binary.

Source

Thrown at packer/plugin-getter/plugins.go:927

						log.Printf("[TRACE] %s", err.Error())
						return nil, errs
					}
					outputFile, err := os.OpenFile(outputFileName, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
					if err != nil {
						err = fmt.Errorf("could not create final plugin binary file: %w", err)
						errs = multierror.Append(errs, err)
						return nil, errs
					}
					if _, err := outputFile.Write(outputFileData.Bytes()); err != nil {
						err = fmt.Errorf("could not write final plugin binary file: %w", err)
						errs = multierror.Append(errs, err)
						return nil, errs
					}
					outputFile.Close()

					cs, err = checksum.Checksummer.Sum(&outputFileData)
					if err != nil {
						err := fmt.Errorf("failed to checksum binary file: %s", err)
						errs = multierror.Append(errs, err)
						log.Printf("[WARNING] %v, ignoring", err)
					}
					if err := os.WriteFile(outputFileName+checksum.Checksummer.FileExt(), []byte(hex.EncodeToString(cs)), 0644); err != nil {
						err := fmt.Errorf("failed to write local binary checksum file: %s", err)
						errs = multierror.Append(errs, err)
						log.Printf("[WARNING] %v, ignoring", err)
						os.Remove(outputFileName)
						continue
					}

					// Success !!
					return &Installation{
						BinaryPath: strings.ReplaceAll(outputFileName, "\\", "/"),
						Version:    "v" + version.String(),
					}, nil
				}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Read the wrapped cause (%s) in the WARNING log line to identify the hashing failure
  2. Re-run `packer init` — if transient, the checksum file will be written correctly on a clean retry
  3. Delete the affected plugin binary from the plugins directory and reinstall from scratch
  4. If persistent, report the packer version and error, since this path is normally unreachable
Defensive patterns

Strategy: try-catch

Try / catch

// treat as non-fatal but verify afterwards
out, err := run("packer", "init", ".")
if strings.Contains(out, "failed to checksum binary file") {
    log.Println("checksum sidecar missing; re-running init")
    run("packer", "init", ".") // retry once
}

Prevention

When it happens

Trigger: checksum.Checksummer.Sum(&outputFileData) returns a non-nil error inside InstallLatest (hasher misconfiguration or hashing failure on the buffer).

Common situations: Rare in practice — usually indicates an internal inconsistency in the checksummer setup rather than user error; users see it as a WARNING line during `packer init` followed by continued install.

Related errors


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