hashicorp/packer · error
Only a script file or an inline script can be specified, not
Error message
Only a script file or an inline script can be specified, not both.
What it means
Config validation error from the windows-shell provisioner's Prepare: the template sets both `script`/`scripts` (a script file) and `inline`, which are mutually exclusive ways to supply the shell commands. It fires only when at least one script path is present AND inline is non-empty.
Source
Thrown at provisioner/windows-shell/provisioner.go:117
p.config.Vars = make([]string, 0)
}
var errs error
if p.config.Script != "" && len(p.config.Scripts) > 0 {
errs = packersdk.MultiErrorAppend(errs,
errors.New("Only one of script or scripts can be specified."))
}
if p.config.Script != "" {
p.config.Scripts = []string{p.config.Script}
}
if len(p.config.Scripts) == 0 && p.config.Inline == nil {
errs = packersdk.MultiErrorAppend(errs,
errors.New("Either a script file or inline script must be specified."))
} else if len(p.config.Scripts) > 0 && p.config.Inline != nil {
errs = packersdk.MultiErrorAppend(errs,
errors.New("Only a script file or an inline script can be specified, not both."))
}
for _, path := range p.config.Scripts {
if _, err := os.Stat(path); err != nil {
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Bad script '%s': %s", path, err))
}
}
// Do a check for bad environment variables, such as '=foo', 'foobar'
for _, kv := range p.config.Vars {
vs := strings.SplitN(kv, "=", 2)
if len(vs) != 2 || vs[0] == "" {
errs = packersdk.MultiErrorAppend(errs,
fmt.Errorf("Environment variable not in format 'key=value': %s", kv))
}
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Remove either the script/scripts block or the inline array from the provisioner stanza so only one source of commands remains
- If you need multiple commands from files, list them in `scripts` and delete `inline`
- Move inline commands into a script file and reference it via `script`
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at provisioner/windows-shell/provisioner.go:117 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/e8850ece98c69007.
Report an issue: GitHub.