hashicorp/packer · error
wrong version: %s does not match expected %s
Error message
wrong version: %s does not match expected %s
What it means
Validate cross-checks a parsed ChecksumFileEntry against the version constraint the installer expects. If the version embedded in the downloaded binary's filename (entry.BinVersion) differs from expectedVersion, the downloaded release is not the requested one and validation fails before the binary is trusted.
Source
Thrown at packer/plugin-getter/release/getter.go:161
res = strings.TrimSuffix(res, entry.Ext)
// res now looks like 0.2.12_freebsd_amd64
parts := strings.Split(res, "_")
// ["0.2.12", "freebsd", "amd64"]
if len(parts) < 3 {
return fmt.Errorf("malformed filename expected %s{version}_{os}_{arch}", req.FilenamePrefix())
}
entry.BinVersion, entry.Os, entry.Arch = parts[0], parts[1], parts[2]
entry.BinVersion = strings.TrimPrefix(entry.BinVersion, "v")
return nil
}
func (g *Getter) Validate(opt plugingetter.GetOptions, expectedVersion string, installOpts plugingetter.BinaryInstallationOptions, entry *plugingetter.ChecksumFileEntry) error {
if entry.BinVersion != expectedVersion {
return fmt.Errorf("wrong version: %s does not match expected %s", entry.BinVersion, expectedVersion)
}
if entry.Os != installOpts.OS || entry.Arch != installOpts.ARCH {
return fmt.Errorf("wrong system, expected %s_%s got %s_%s", installOpts.OS, installOpts.ARCH, entry.Os, entry.Arch)
}
manifest, err := g.Get("meta", opt)
if err != nil {
return err
}
var data plugingetter.ManifestMeta
body, err := io.ReadAll(manifest)
if err != nil {
log.Printf("Failed to unmarshal manifest json: %s", err)
return err
}
err = json.Unmarshal(body, &data)View on GitHub (pinned to eb36e3c3e4)
Solutions
- Re-run `packer plugins install` (or delete the plugin cache dir) so files matching the required version are fetched fresh.
- Verify the version constraint in the HCL2 required_plugins block matches the version of the binary actually downloaded.
- Check releases.hashicorp.com to confirm the expected version exists and its assets use the correct version string in filenames.
Example fix
// before (required_plugins block)
docker = {
version = "= 1.0.0"
}
// after
docker = {
version = "= 1.1.1"
} Defensive patterns
Strategy: validation
Validate before calling
if entry.BinVersion != expectedVersion {
// clear plugin cache and reinstall before proceeding
os.RemoveAll(pluginDir)
} Try / catch
if err := g.Validate(opt, expectedVersion, installOpts, entry); err != nil {
if strings.Contains(err.Error(), "wrong version") {
// purge cache, re-run `packer plugins install`, retry
}
} Prevention
- Pin plugin versions explicitly in required_plugins and keep them in sync with installed binaries.
- Clear PACKER_PLUGIN_PATH contents after upgrading version constraints.
- Never mix plugin binaries from different versions in one directory.
When it happens
Trigger: Getter.Validate called with an entry whose BinVersion (parsed from the filename) does not equal expectedVersion — e.g. expected "1.1.1" but the entry filename says "v1.1.1" handled elsewhere, or a cached/stale checksum file lists an older version like 1.0.0.
Common situations: Pinning a plugin version in required_plugins while a stale checksum/index cache still points at an old release; a plugin re-released under the same tag with rebuilt binaries; manually mixing plugin files of different versions in the plugin directory.
Related errors
- min_version is invalid: %s
- wrong version: %s does not match expected %s
- binary reported version (%q) is different from the expected
- %q not implemented
- malformed filename expected %s{version}_{os}_{arch}
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/f68523694d123700.
Report an issue: GitHub.