hyperledger/fabric · error
chaincode '%s' was already built with builder '%s', but that
Error message
chaincode '%s' was already built with builder '%s', but that builder is no longer available
What it means
When a chaincode package has a cached build result recorded for a builder, CachedBuild tries to locate that builder among the currently configured builders. If the named builder is no longer in the peer's externalBuilders configuration, the cached result cannot be trusted or reused, so Fabric errors instead of silently rebuilding.
Source
Thrown at core/container/externalbuilder/externalbuilder.go:87
var buildInfo BuildInfo
if err := json.Unmarshal(buildInfoData, &buildInfo); err != nil {
return nil, errors.WithMessagef(err, "malformed build info at '%s'", buildInfoPath)
}
for _, builder := range d.Builders {
if builder.Name == buildInfo.BuilderName {
return &Instance{
PackageID: ccid,
Builder: builder,
BldDir: filepath.Join(durablePath, "bld"),
ReleaseDir: filepath.Join(durablePath, "release"),
TermTimeout: 5 * time.Second,
}, nil
}
}
return nil, errors.Errorf("chaincode '%s' was already built with builder '%s', but that builder is no longer available", ccid, buildInfo.BuilderName)
}
// Build executes the external builder detect and build process.
//
// Before running the detect and build process, the detector first checks the
// durable path for the results of a previous build for the provided package.
// If found, the detect and build process is skipped and the existing instance
// is returned.
func (d *Detector) Build(ccid string, mdBytes []byte, codeStream io.Reader) (*Instance, error) {
// A small optimization: prevent exploding the build package out into the
// file system unless there are external builders defined.
if len(d.Builders) == 0 {
return nil, nil
}
// Look for a cached instance.
i, err := d.CachedBuild(ccid)
if err != nil {View on GitHub (pinned to 2736b63f8f)
Solutions
- Re-add the builder (with the same name) to the peer's externalBuilders configuration and restart the peer
- Remove the stale durable build directory for that chaincode so it is rebuilt with an available builder
- Rename the builder in config back to the name recorded in the cached build info
Example fix
// before (core.yaml)
externalBuilders: []
// after
externalBuilders:
- name: ccaas_builder
path: /opt/hyperledger/ccaas_builder
propagateEnvironment: [] Defensive patterns
Strategy: fallback
Validate before calling
var builders []string
for _, b := range peerConfig.ExternalBuilders { builders = append(builders, b.Name) }
if !slices.Contains(builders, cachedBuildInfo.BuilderName) {
os.RemoveAll(durablePath) // force rebuild with an available builder
} Type guard
func builderAvailable(name string, builders []Builder) bool {
return slices.ContainsFunc(builders, func(b Builder) bool { return b.Name == name })
} Try / catch
info, err := detector.CachedBuild(durablePath, packageID, ccid)
if err != nil && strings.Contains(err.Error(), "no longer available") {
os.RemoveAll(durablePath)
info, err = detector.Build(buildContext) // rebuild with current builders
} Prevention
- Keep external builder names stable across peer upgrades
- Use identical externalBuilders config on all peers in an organization
- Clear stale build directories under peer fileSystemPath when changing builder lists
When it happens
Trigger: Calling Build for a chaincode whose durable build metadata references builder X, but builder X was removed/renamed from the peer's externalBuilders list since the previous build.
Common situations: Peer config was updated and an external builder was deleted or renamed; rolling out a new peer version with a trimmed builders list; mismatched builders across peers in the same organization.
Related errors
- Unknown chaincodeType: %s
- could not get connection info
- timeout expired while starting chaincode %s for transaction
- cannot retrieve package for chaincode %ss, error %s
- no DockerBuilder, cannot build
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/a1a8f02afdcbd523.
Report an issue: GitHub.