hashicorp/packer · error
min_version is invalid: %s
Error message
min_version is invalid: %s
What it means
Thrown by Core.validate() at packer/core.go:870 when the template declares a `min_version` that HashiCorp go-version cannot parse. Packer validates the declared minimum required Packer version, and an unparseable string (not a valid semver-like version) fails before any comparison happens.
Source
Thrown at packer/core.go:870
// richer semantic checks around variables and so on.
func (c *Core) validate() error {
// First validate the template in general, we can't do anything else
// unless the template itself is valid.
if err := c.Template.Validate(); err != nil {
return err
}
// Validate the minimum version is satisfied
if c.Template.MinVersion != "" {
versionActual, err := version.NewVersion(c.version)
if err != nil {
// This shouldn't happen since we set it via the compiler
panic(err)
}
versionMin, err := version.NewVersion(c.Template.MinVersion)
if err != nil {
return fmt.Errorf(
"min_version is invalid: %s", err)
}
if versionActual.LessThan(versionMin) {
return fmt.Errorf(
"This template requires Packer version %s or higher; using %s",
versionMin,
versionActual)
}
}
// Validate variables are set
var err error
for n, v := range c.Template.Variables {
if v.Required {
if _, ok := c.variables[n]; !ok {
err = multierror.Append(err, fmt.Errorf(
"required variable not set: %s", n))View on GitHub (pinned to eb36e3c3e4)
Solutions
- Set min_version to a plain version string, e.g. `min_version = "1.7.0"`
- Remove any leading 'v', comparators, ranges, or non-numeric suffixes from the value
- Remove the min_version attribute entirely if version pinning is not needed
Example fix
// before min_version = ">= 1.7.0" // after min_version = "1.7.0"
Defensive patterns
Strategy: validation
Validate before calling
# ensure min_version parses before invoking packer grep -oP 'min_version\s*=\s*"\K[^"]+' *.pkr.hcl | grep -vP '^\d+\.\d+\.\d+$' && echo 'invalid min_version found'
Prevention
- Use plain x.y.z strings for min_version (no 'v', no comparators, no ranges)
- Let CI run `packer validate` to catch malformed version constraints early
- Distinguish required_version (supports constraints) from min_version (plain version) when writing templates
When it happens
Trigger: Core.validate() (called from Core.initialize during GetBuilds) sees c.Template.MinVersion != "" and version.NewVersion(MinVersion) returns an error — the string is not a valid version like "1.7.0".
Common situations: Writing `min_version = "v1.7.0"` with a leading 'v' in contexts where it is unsupported; using ranges or comparators (">= 1.7") instead of a plain version; typos like "1..7" or "latest"; copying an HCL required_version constraint into the min_version field.
Related errors
- wrong version: %s does not match expected %s
- Error parsing target template: %s
- Error parsing target template: %s
- Bad source '%s': %s
- Error interpolating destination: %s
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/5e2a28b438a02871.
Report an issue: GitHub.