{"record":{"id":"1c6c8d90aca685e2","repo":"hashicorp/packer","slug":"failed-to-start-scanner-s","errorCode":null,"errorMessage":"failed to start scanner: %s","messagePattern":"failed to start scanner: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"provisioner/hcp-sbom/provisioner.go","lineNumber":738,"sourceCode":"\t\televatedCmd, err := guestexec.GenerateElevatedRunner(cmdStr, p)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to generate elevated runner: %s\", err)\n\t\t}\n\t\tcmdStr = elevatedCmd\n\t}\n\n\tlog.Printf(\"Executing: %s\", cmdStr)\n\n\t// Execute scanner\n\tvar stdout, stderr bytes.Buffer\n\tcmd := &packersdk.RemoteCmd{\n\t\tCommand: cmdStr,\n\t\tStdout:  &stdout,\n\t\tStderr:  &stderr,\n\t}\n\n\tif err := comm.Start(ctx, cmd); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to start scanner: %s\", err)\n\t}\n\n\tcmd.Wait()\n\n\t// Log output\n\tif stdout.Len() > 0 {\n\t\tui.Say(fmt.Sprintf(\"Scanner stdout: %s\", stdout.String()))\n\t}\n\tif stderr.Len() > 0 {\n\t\tui.Say(fmt.Sprintf(\"Scanner stderr: %s\", stderr.String()))\n\t}\n\n\tif cmd.ExitStatus() != 0 {\n\t\treturn \"\", fmt.Errorf(\"scanner exited with status %d\", cmd.ExitStatus())\n\t}\n\n\treturn outputPath, nil\n}","sourceCodeStart":720,"sourceCodeEnd":756,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/provisioner/hcp-sbom/provisioner.go#L720-L756","documentation":"Returned by runScanner (provisioner/hcp-sbom/provisioner.go:738) when comm.Start fails to launch the rendered scanner command on the remote host. This is a transport/session-level failure — the command never ran, so no exit status exists. It wraps the underlying communicator error describing why Start failed.","triggerScenarios":"Calling `packer build` when the SSH/WinRM session cannot spawn the command: connection dropped before Start, SSH channel could not be opened, the guest rejected the session, or the shell specified by the communicator is unavailable.","commonSituations":"SSH keepalive/timeouts killing the session mid-build (long downloads before this step); WinRM session limits on concurrent shells; guest sshd restarted or MaxSessions exhausted; communicator misconfiguration (wrong port/user) surfacing only at this command.","solutions":["Inspect the wrapped communicator error to distinguish connection loss from shell spawn failure.","Re-run the build; transient SSH drops are the most common cause and often succeed on retry.","Check guest sshd/WinRM limits (MaxSessions, MaxStartups; WinRM MaxShellsPerUser) and raise if you run many provisioners concurrently.","Verify communicator settings (host, port, user, key/password, use_sftp vs scp) and network/firewall stability between Packer host and guest.","Run with PACKER_LOG=1 to see the exact communicator-level failure before Start."],"exampleFix":"// before: flaky SSH drops mid-build\nssh_handshake_attempts = 10\n// after: keep the session alive and allow more handshake time\nssh_handshake_attempts = 30\nssh_keep_alive_interval = \"5s\"","handlingStrategy":"retry","validationCode":"// Pre-flight: confirm the guest accepts a command session before the build step\n// e.g. ssh -o BatchMode=yes user@host 'echo ok' must succeed","typeGuard":null,"tryCatchPattern":"if err := comm.Start(ctx, cmd); err != nil {\n    // transient session loss is common: retry once after backoff\n    return \"\", fmt.Errorf(\"failed to start scanner: %w\", err)\n}","preventionTips":["Raise ssh_handshake_attempts and set ssh_keep_alive_interval.","Check guest sshd MaxSessions/MaxStartups and WinRM MaxShellsPerUser.","Stabilize network/firewall rules between Packer host and guest.","Retry the whole build once on transient communicator failures."],"tags":["packer","provisioner","communicator","ssh"],"backgroundTag":"remote-command-start-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}