hashicorp/packer · error

failed to download Packer release for %s/%s: %w

Error message

failed to download Packer release for %s/%s: %w

What it means

Runtime error from provisionWithNativeGeneration in the hcp-sbom provisioner: downloading the Packer release zip for the guest's GOOS/GOARCH (to use packer's SBOM scanner on the remote host) failed. The wrapped error is from the HTTP download.

Source

Thrown at provisioner/hcp-sbom/provisioner.go:631

func (p *Provisioner) provisionWithNativeGeneration(
	ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator,
	generatedData map[string]interface{}, osType, osArch string,
) error {
	ui.Say("Starting Automatic SBOM generation workflow...")

	// Step 1: Download Packer release binary on the host.
	targetGOOS := strings.ToLower(osType)
	archMap := map[string]string{
		"x86_64": "amd64", "aarch64": "arm64", "i386": "386", "i686": "386", "armv7l": "arm", "armv7": "arm",
	}
	targetGOARCH := strings.ToLower(osArch)
	if mapped, ok := archMap[targetGOARCH]; ok {
		targetGOARCH = mapped
	}
	ui.Say(fmt.Sprintf("Downloading latest Packer release for %s/%s from %s...", targetGOOS, targetGOARCH, getReleaseBaseURL()))
	scannerZipPath, err := downloadPackerRelease(ctx, targetGOOS, targetGOARCH)
	if err != nil {
		return fmt.Errorf("failed to download Packer release for %s/%s: %w", targetGOOS, targetGOARCH, err)
	}
	defer func() {
		if err := os.Remove(scannerZipPath); err != nil && !errors.Is(err, os.ErrNotExist) {
			log.Printf("[WARN] failed to remove temporary Packer release zip %s: %v", scannerZipPath, err)
		}
	}()

	// Step 2: Upload scanner to remote.
	log.Println("Uploading scanner to remote host...")
	remoteScannerPath, err := p.uploadScanner(ctx, ui, comm, scannerZipPath, osType)
	if err != nil {
		return fmt.Errorf("failed to upload scanner: %s", err)
	}
	defer p.cleanupRemoteFile(ctx, ui, comm, remoteScannerPath)

	// Step 3: Run scanner on remote
	ui.Say(fmt.Sprintf("Running scanner on remote host (scanning %s)...", p.config.ScanPath))
	remoteSBOMPath, err := p.runScanner(ctx, ui, comm, remoteScannerPath, osType)

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Check network/egress access to the Packer release host from the build machine and retry
  2. Verify the guest OS/arch maps to a published Packer release (e.g. linux/amd64)
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at provisioner/hcp-sbom/provisioner.go:631 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/30f5f9641fbc24e8. Report an issue: GitHub.