hashicorp/packer · error

remote step %q failed (exit %d): %s

Error message

remote step %q failed (exit %d): %s

What it means

Runtime error from runRemoteCmd: the remote command started but exited non-zero; the message includes the step label, exit code, and captured stderr from the remote host, so the actual failure text comes from the remote command itself.

Source

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

	}

	return nil, fmt.Errorf("%s not found in zip %s", binaryName, zipPath)
}

// runRemoteCmd runs a single shell command on the remote host and returns a
// descriptive error if it fails.
func (p *Provisioner) runRemoteCmd(ctx context.Context, comm packersdk.Communicator, cmdStr, step string) error {
	var stderr bytes.Buffer
	cmd := &packersdk.RemoteCmd{
		Command: cmdStr,
		Stderr:  &stderr,
	}
	if err := comm.Start(ctx, cmd); err != nil {
		return fmt.Errorf("failed to start remote step %q: %s", step, err)
	}
	cmd.Wait()
	if cmd.ExitStatus() != 0 {
		return fmt.Errorf("remote step %q failed (exit %d): %s",
			step, cmd.ExitStatus(), strings.TrimSpace(stderr.String()))
	}
	return nil
}

// provisionWithNativeGeneration handles the native SBOM generation flow.
// The Packer release binary is downloaded on the host (works in air-gapped
// environments where the VM has no internet access), verified, then uploaded
// to the remote host via the communicator before running `packer sbom-generate`.
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{

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Read the stderr in the message — it is the remote command's own error output
  2. For chmod/exec failures, check that /tmp on the remote host is not mounted noexec
  3. Verify the scanner binary matches the remote OS/architecture
Defensive patterns

Strategy: retry

When it happens

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