hashicorp/packer · error
failed to upload Packer release zip
Error message
failed to upload Packer release zip: %s
What it means
This error wraps a failure of comm.Upload when copying the Packer release zip from the host to C:\Windows\Temp\packer-sbom-runner.zip on the Windows guest. It is thrown at provisioner/hcp-sbom/provisioner.go:509 in uploadScanner (Windows path), called by provisionWithNativeGeneration. It indicates the communicator (typically WinRM) accepted the operation but the transfer failed, with the underlying transport error embedded.
Solutions
- Check PACKER_LOG=1 output for the wrapped communicator error and fix the root transport issue (connection, auth, timeout).
- Increase the communicator timeout (winrm_timeout) and retry the build — large uploads over slow networks often need more time.
- Confirm the Windows guest has free disk space in C:\Windows\Temp and that no antivirus/EDR blocks Packer writing there.
- Verify WinRM connectivity and credentials (winrm_username/winrm_password, port 5985/5986) before the build.
- Retry the build; transient network drops during upload are a common cause and a fresh run may succeed.
Example fix
// before
source "null" "win" {
communicator = "winrm"
winrm_timeout = "30m" // may be too short for big zips
}
// after
source "null" "win" {
communicator = "winrm"
winrm_timeout = "2h"
winrm_use_ntlm = true
} Defensive patterns
Strategy: retry
Validate before calling
// before build: confirm WinRM reachable
timeout := 10 * time.Second
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:5985", guestHost), timeout)
if err != nil {
return fmt.Errorf("WinRM not reachable on %s:5985: %w", guestHost, err)
}
conn.Close()
// confirm disk space on guest during provisioning
dfCmd := `powershell -Command "(Get-PSDrive C).Free"` Try / catch
err := comm.Upload(remoteZipPath, zipFile, nil)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// increase winrm_timeout and retry upload
}
return fmt.Errorf("failed to upload Packer release zip: %w", err)
} Prevention
- Set a generous winrm_timeout sized for your zip size and network bandwidth.
- Pre-check guest disk free space in C:\Windows\Temp in an early provisioner step.
- Validate WinRM credentials and firewall rules (5985/5986) before long builds.
- Retry transient upload failures with backoff rather than failing the whole build.
- Keep release zips small or host the binary on a local mirror to reduce transfer time.
When it happens
Trigger: comm.Upload(remoteZipPath, zipFile, nil) returns an error during the Windows branch of uploadScanner — e.g. WinRM/SSH connection dropped mid-transfer, authentication failure, guest disk full in C:\Windows\Temp, or a timeout uploading a large zip.
Common situations: Unstable or slow WinRM connectivity to the Windows VM; the guest ran out of disk space in C:\Windows\Temp; wrong WinRM credentials/ports in the communicator block; security software on the guest blocking writes to Windows\Temp; transfer timeouts on large release zips over high-latency networks.
Related errors
- Error uploading envVarFile
- Error uploading script
- failed to upload Packer binary
- clean up script failed to upload
- Error uploading ps script containing env vars
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/72d983b1d47c8f28.
Report an issue: GitHub.
Appendix: source
Thrown at provisioner/hcp-sbom/provisioner.go:509
} else {
binaryName = "packer"
remotePath = "/tmp/packer-sbom-runner"
}
if isWindows {
remoteDir := "C:\\Windows\\Temp"
remoteZipPath := remoteDir + "\\packer-sbom-runner.zip"
// Step 1: upload zip to remote.
zipFile, err := os.Open(localZipPath)
if err != nil {
return "", fmt.Errorf("failed to open Packer release zip: %s", err)
}
defer func() { _ = zipFile.Close() }()
log.Printf("[INFO] Uploading Packer release zip to %s...", remoteZipPath)
if err := comm.Upload(remoteZipPath, zipFile, nil); err != nil {
return "", fmt.Errorf("failed to upload Packer release zip: %s", err)
}
// Single PowerShell command: extract, move binary, remove zip.
psCmd := fmt.Sprintf(
`powershell -NoProfile -ExecutionPolicy Bypass -Command `+
`"$ErrorActionPreference='Stop'; `+
`Expand-Archive -Path '%s' -DestinationPath '%s' -Force; `+
`if (!(Test-Path '%s\%s')) { throw 'packer.exe not found after extraction' }; `+
`Move-Item -Force '%s\%s' '%s'; `+
`Remove-Item -Force '%s'"`,
remoteZipPath, remoteDir,
remoteDir, binaryName,
remoteDir, binaryName, remotePath,
remoteZipPath,
)
if err := p.runRemoteCmd(ctx, comm, psCmd, "extract scanner (Windows)"); err != nil {
return "", err
}View on GitHub (pinned to eb36e3c3e4)