{"record":{"id":"71c93a6cfe710575","repo":"hashicorp/packer","slug":"no-such-build-found-s","errorCode":null,"errorMessage":"no such build found: %s","messagePattern":"no such build found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packer/core.go","lineNumber":452,"sourceCode":"\t\tif len(warnings) > 0 {\n\t\t\tfor _, warning := range warnings {\n\t\t\t\tdiags = append(diags, &hcl.Diagnostic{\n\t\t\t\t\tSeverity: hcl.DiagWarning,\n\t\t\t\t\tSummary:  fmt.Sprintf(\"Warning when preparing build: %q\", n),\n\t\t\t\t\tDetail:   warning,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\treturn builds, diags\n}\n\n// Build returns the Build object for the given name.\nfunc (c *Core) Build(n string) (*CoreBuild, error) {\n\t// Setup the builder\n\tconfigBuilder, ok := c.builds[n]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"no such build found: %s\", n)\n\t}\n\t// BuilderStore = config.Builders, gathered in loadConfig() in main.go\n\t// For reference, the builtin BuilderStore is generated in\n\t// packer/config.go in the Discover() func.\n\n\tif !c.components.PluginConfig.Builders.Has(configBuilder.Type) {\n\t\terr := fmt.Errorf(\n\t\t\t\"The builder %s is unknown by Packer, and is likely part of a plugin that is not installed.\\n\"+\n\t\t\t\t\"You may find the needed plugin along with installation instructions documented on the Packer integrations page.\\n\\n\"+\n\t\t\t\t\"https://developer.hashicorp.com/packer/integrations?filter=%s\",\n\t\t\tconfigBuilder.Type,\n\t\t\tstrings.Split(configBuilder.Type, \"-\")[0],\n\t\t)\n\n\t\tif sugg := didyoumean.NameSuggestion(configBuilder.Type, c.components.PluginConfig.Builders.List()); sugg != \"\" {\n\t\t\terr = fmt.Errorf(\"Did you mean to use %q?\", sugg)\n\t\t}\n","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/packer/core.go#L434-L470","documentation":"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.","triggerScenarios":"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.","commonSituations":"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').","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."],"exampleFix":"// before\n$ packer build -only=ubuntu .\n// error: no such build found: ubuntu\n// after (source is amazon-ebs.ubuntu)\n$ packer build -only=amazon-ebs.ubuntu .","handlingStrategy":"validation","validationCode":"// Discover valid build names before building:\ncore, _ := packer.NewCore(&packer.CoreConfig{...})\nbuilds, _ := core.GetBuilds(nil) // returns available build names\nif !slices.Contains(builds, wantedName) {\n    return fmt.Errorf(\"build %q not found; available: %v\", wantedName, builds)\n}","typeGuard":null,"tryCatchPattern":"if _, err := core.Build(n); err != nil {\n    if strings.HasPrefix(err.Error(), \"no such build found\") {\n        names, _ := core.GetBuilds(nil)\n        return fmt.Errorf(\"%w; available builds: %v\", err, names)\n    }\n    return err\n}","preventionTips":["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."],"tags":["build","naming","cli","configuration"],"backgroundTag":"unknown-build-name","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"}