hashicorp/packer · error
sbom generation is not supported on %s builds
Error message
sbom generation is not supported on %s builds
What it means
On operating systems where the Syft SDK cannot be compiled (build-tag constrained platforms), internal/sbom swaps in generator_unsupported.go whose Generator.Generate unconditionally fails with "sbom generation is not supported on %s builds", reporting runtime.GOOS. This is a compile-time capability limitation surfaced as a runtime error, not a user configuration mistake.
Source
Thrown at internal/sbom/generator_unsupported.go:17
// Copyright IBM Corp. 2013, 2025
// SPDX-License-Identifier: BUSL-1.1
//go:build netbsd || openbsd || solaris || mips || mipsle || mips64 || (freebsd && (386 || arm))
package sbom
import (
"context"
"fmt"
"runtime"
)
// Generate returns an error on platforms where the Syft SDK cannot be built.
func (g *Generator) Generate(ctx context.Context) ([]byte, error) {
_ = ctx
return nil, fmt.Errorf("sbom generation is not supported on %s builds", runtime.GOOS)
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Run Packer on a supported GOOS (linux/darwin/windows) where the syft-backed generator is compiled in
- Skip or guard the SBOM feature with a GOOS check before invoking Generate
- Generate the SBOM out-of-band with the syft CLI on a supported platform and feed the artifact in
- If support for the platform is needed, upstream syft build support or adjust the build tags
Example fix
// before
sbomBytes, err := gen.Generate(ctx)
// after
if runtime.GOOS == "plan9" {
log.Println("sbom generation unsupported on this platform; skipping")
} else {
sbomBytes, err = gen.Generate(ctx)
} Defensive patterns
Strategy: fallback
Validate before calling
// Compile-time note: use a build-tagged file to provide a no-op generator on unsupported GOOS //go:build plan9 || js // In code: check the platform before calling unsupported := runtime.GOOS == "plan9" || runtime.GOOS == "js"
Try / catch
sbomBytes, err := gen.Generate(ctx)
if err != nil && strings.Contains(err.Error(), "sbom generation is not supported") {
log.Printf("skipping SBOM on %s", runtime.GOOS)
return nil
} Prevention
- Guard SBOM features with runtime.GOOS checks or build tags in CI matrices
- Test cross-compilation targets before shipping platform builds
- Provide a documented fallback (external syft CLI) for unsupported platforms
When it happens
Trigger: Calling Generator.Generate on a GOOS for which the syft-based generator file is excluded by build tags (e.g. building Packer for an OS/arch the syft SDK does not support). The call always returns this error on such builds regardless of config.
Common situations: Cross-compiling Packer to an exotic platform; running a community build of packer for an OS without syft support and enabling an SBOM-generating feature; CI matrices that build for unsupported GOOS values.
Related errors
- failed to get source: %w
- unsupported scope: %s
- failed to create SBOM: %w
- failed to create CycloneDX encoder: %w
- failed to create SPDX encoder: %w
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/d1253581ae3d4bfd.
Report an issue: GitHub.