hashicorp/packer · error
no Packer bucket name defined; either the environment variab
Error message
no Packer bucket name defined; either the environment variable %q is undefined or the HCL configuration has no build name
What it means
HCP registry validation error from Bucket.Validate: the bucket name is empty because neither HCP_PACKER_BUCKET_NAME is set nor a build name exists in the HCL configuration, so there is no registry image to publish to.
Source
Thrown at internal/hcp/registry/types.bucket.go:78
}
// NewBucketWithVersion initializes a simple Bucket that can be used for publishing Packer build artifacts
// to the HCP Packer registry.
func NewBucketWithVersion() *Bucket {
b := Bucket{
BucketLabels: make(map[string]string),
BuildLabels: make(map[string]string),
SourceExternalIdentifierToParentVersions: make(map[string]ParentVersion),
RunningBuilds: make(map[string]chan struct{}),
}
b.Version = NewVersion()
return &b
}
func (bucket *Bucket) Validate() error {
if bucket.Name == "" {
return fmt.Errorf(
"no Packer bucket name defined; either the environment variable %q is undefined or "+
"the HCL configuration has no build name",
env.HCPPackerBucket,
)
}
return nil
}
// ReadFromHCLBuildBlock reads the information for initialising a Bucket from a HCL2 build block
func (bucket *Bucket) ReadFromHCLBuildBlock(build *hcl2template.BuildBlock) {
registryBlock := build.HCPPackerRegistry
if registryBlock == nil {
return
}
bucket.ReadFromHCPPackerRegistryBlock(build.HCPPackerRegistry)
}
// ReadFromHCPPackerRegistryBlock reads the information for initialising a Bucket from a HCL2 Packer registry blockView on GitHub (pinned to eb36e3c3e4)
Solutions
- Add a bucket_name to the packer block in your HCL template
- Set the HCP_PACKER_BUCKET_NAME environment variable
- Name your build so a bucket slug can be derived from it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/hcp/registry/types.bucket.go:78 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/d933d8efd17b982a.
Report an issue: GitHub.