hashicorp/packer · error
no remoteFiles provided for cleanup
Error message
no remoteFiles provided for cleanup
What it means
createRemoteCleanUpCommand builds a PowerShell one-liner that deletes the uploaded remote files after execution. It refuses to generate that script when remoteFiles is empty, because there is nothing to clean up and uploading a cleanup script would itself leave a stray remote file. This is an internal invariant violation of the provisioner, not normally caused by user configuration.
Source
Thrown at provisioner/powershell/provisioner.go:446
return cmd.RunWithUi(ctx, comm, ui)
})
if err != nil {
log.Printf("remote cleanup script failed to upload; skipping the removal of temporary files: %s; ", strings.Join(uploadedScripts, ","))
}
if p.config.PauseAfter != 0 {
ui.Say(fmt.Sprintf("Pausing %s after this provisioner...", p.config.PauseAfter))
time.Sleep(p.config.PauseAfter)
}
return nil
}
// createRemoteCleanUpCommand will generated a powershell script that will remove remote files;
// returning a command that can be executed remotely to do the cleanup.
func (p *Provisioner) createRemoteCleanUpCommand(remoteFiles []string) (string, error) {
if len(remoteFiles) == 0 {
return "", fmt.Errorf("no remoteFiles provided for cleanup")
}
var b strings.Builder
// This script should self destruct.
remotePath := p.config.remoteCleanUpScriptPath
remoteFiles = append(remoteFiles, remotePath)
for _, filename := range remoteFiles {
fmt.Fprintf(&b, "if (Test-Path %[1]s) {Remove-Item %[1]s}\n", filename)
}
if err := p.communicator.Upload(remotePath, strings.NewReader(b.String()), nil); err != nil {
return "", fmt.Errorf("clean up script %q failed to upload: %s", remotePath, err)
}
data := p.generatedData
data["Path"] = remotePath
data["Vars"] = p.config.RemoteEnvVarPath
p.config.ctx.Data = dataView on GitHub (pinned to eb36e3c3e4)
Solutions
- If you hit this in a stock Packer build, report it as a bug with the full debug log (PACKER_LOG=1).
- If you maintain a fork, ensure every uploaded remote file (script and env-var file) is appended to the remoteFiles list before cleanup is generated.
- As a workaround, clean up leftover files manually on the guest; the error means nothing was deleted.
Defensive patterns
Strategy: fallback
Prevention
- Use stock Packer; if triggered, capture PACKER_LOG=1 output and file a bug.
- In forks, always register every uploaded remote file in the cleanup list.
- Manually remove leftover remote files after a failed cleanup.
When it happens
Trigger: The provisioner calls createRemoteCleanUpCommand with an empty remoteFiles slice — i.e. no script/env-var remote files were recorded for deletion, which would indicate an internal bug in how the provisioner tracked uploaded files.
Common situations: Practically only seen during development/patching of the powershell provisioner itself, or when a modified code path skips registering uploaded files; end users should never trigger it via template configuration.
Related errors
- Only one of script or scripts can be specified.
- Must supply an 'elevated_user' if 'elevated_password' provid
- Either a script file or inline script must be specified.
- Only a script file or an inline script can be specified, not
- Bad script '%s': %s
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/21f79bc1e31df82a.
Report an issue: GitHub.