hashicorp/packer · error
no such build found: %s
Error message
no such build found: %s
What it means
Core.Build looks up the requested build (a named source in the template) in c.builds, which was populated when the config was loaded. If no build with that name exists, Packer returns this error naming the requested build name.
Source
Thrown at packer/core.go:452
if len(warnings) > 0 {
for _, warning := range warnings {
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagWarning,
Summary: fmt.Sprintf("Warning when preparing build: %q", n),
Detail: warning,
})
}
}
}
return builds, diags
}
// Build returns the Build object for the given name.
func (c *Core) Build(n string) (*CoreBuild, error) {
// Setup the builder
configBuilder, ok := c.builds[n]
if !ok {
return nil, fmt.Errorf("no such build found: %s", n)
}
// BuilderStore = config.Builders, gathered in loadConfig() in main.go
// For reference, the builtin BuilderStore is generated in
// packer/config.go in the Discover() func.
if !c.components.PluginConfig.Builders.Has(configBuilder.Type) {
err := fmt.Errorf(
"The builder %s is unknown by Packer, and is likely part of a plugin that is not installed.\n"+
"You may find the needed plugin along with installation instructions documented on the Packer integrations page.\n\n"+
"https://developer.hashicorp.com/packer/integrations?filter=%s",
configBuilder.Type,
strings.Split(configBuilder.Type, "-")[0],
)
if sugg := didyoumean.NameSuggestion(configBuilder.Type, c.components.PluginConfig.Builders.List()); sugg != "" {
err = fmt.Errorf("Did you mean to use %q?", sugg)
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Run `packer inspect <template>` to list valid build names and use one of them.
- Fix the -only/-except flag spelling to match the source name exactly (including the builder-type prefix).
- Add the missing source block to the template if it was intended to exist.
- In CI scripts, derive build names from `packer inspect` output rather than hardcoding them.
Example fix
// before $ packer build -only=ubuntu . // error: no such build found: ubuntu // after (source is amazon-ebs.ubuntu) $ packer build -only=amazon-ebs.ubuntu .
Defensive patterns
Strategy: validation
Validate before calling
// Discover valid build names before building:
core, _ := packer.NewCore(&packer.CoreConfig{...})
builds, _ := core.GetBuilds(nil) // returns available build names
if !slices.Contains(builds, wantedName) {
return fmt.Errorf("build %q not found; available: %v", wantedName, builds)
} Try / catch
if _, err := core.Build(n); err != nil {
if strings.HasPrefix(err.Error(), "no such build found") {
names, _ := core.GetBuilds(nil)
return fmt.Errorf("%w; available builds: %v", err, names)
}
return err
} Prevention
- Run `packer inspect` to confirm build names before scripted builds.
- Keep -only/-except flags in sync with source renames.
- Remember build names are '<builder-type>.<name>' in HCL2.
- Generate CI build lists from inspect output instead of hardcoding.
When it happens
Trigger: packer build/inspect with a build name that does not match any defined source: `packer build -only=foo` where no source is named foo; misspelled build name on the CLI; passing the file name instead of the source name; all sources filtered out by -only/-except combinations.
Common situations: Typo in -only/-except flags; referencing a source defined only in a different template file; source renamed in the template but old name used in scripts/CI; forgetting that build names include the source type (e.g. 'amazon-ebs.example').
Related errors
- signing_mode %q requires signer
- build keyless identity policy: %w
- signing_mode %q requires keyless_identity and keyless_oidc_i
- initialize KMS signer %q: %w%s
- initialize KMS signer %q: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/71c93a6cfe710575.
Report an issue: GitHub.