hashicorp/packer · error

Packer could not read the fingerprint from git.

Error message

Packer could not read the fingerprint from git.

What it means

HCP registry error from getGitSHA: go-git could not open a git repository for the template directory (PlainOpenWithOptions with DetectDotGit failed). The build fingerprint cannot be derived from the HEAD commit because the directory is not under version control or git metadata is unreadable.

Source

Thrown at internal/hcp/registry/hcp.go:129

}

func withPackerEnvConfiguration(bucket *Bucket) hcl.Diagnostics {
	// Add default values for Packer settings configured via EnvVars.
	// TODO look to break this up to be more explicit on what is loaded here.
	bucket.LoadDefaultSettingsFromEnv()

	return nil
}

// getGitSHA returns the HEAD commit for some template dir defined in baseDir.
// If the base directory is not under version control an error is returned.
func getGitSHA(baseDir string) (string, error) {
	r, err := git.PlainOpenWithOptions(baseDir, &git.PlainOpenOptions{
		DetectDotGit: true,
	})

	if err != nil {
		return "", fmt.Errorf("Packer could not read the fingerprint from git.")
	}

	// The config can be used to retrieve user identity. for example,
	// c.User.Email. Leaving in but commented because I'm not sure we care
	// about this identity right now. - Megan
	//
	// c, err := r.ConfigScoped(config.GlobalScope)
	// if err != nil {
	//      return "", fmt.Errorf("Error setting git scope", err)
	// }
	ref, err := r.Head()
	if err != nil {
		// If we get there, we're in a Git dir, but HEAD cannot be read.
		//
		// This may happen when there's no commit in the git dir.
		return "", fmt.Errorf("Packer could not read a git SHA in directory %q: %s", baseDir, err)
	}

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Run `git init` and make an initial commit in the template directory
  2. Set HCP_PACKER_BUCKET_FINGERPRINT env var to supply the fingerprint manually
  3. Clone your templates from their repository instead of copying files without .git
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/hcp/registry/hcp.go:129 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/f498bab0111b9acc. Report an issue: GitHub.