hyperledger/fabric · error

error installing chaincode code %s:%s(%s)

Error message

error installing chaincode code %s:%s(%s)

What it means

PutChaincodeToLocalStorage wraps any failure from ccpack.PutChaincodeToFS() with the chaincode name, version, and underlying error. It occurs when the installed chaincode package cannot be written to the peer's local file system (the chaincode install path), so `peer chaincode install` fails on this peer.

Source

Thrown at core/scc/lscc/support.go:28

	pb "github.com/hyperledger/fabric-protos-go-apiv2/peer"
	"github.com/hyperledger/fabric/common/cauthdsl"
	"github.com/hyperledger/fabric/common/policydsl"
	"github.com/hyperledger/fabric/core/common/ccprovider"
	"github.com/hyperledger/fabric/msp"
	"github.com/hyperledger/fabric/protoutil"
	"github.com/pkg/errors"
)

type SupportImpl struct {
	GetMSPIDs               MSPIDsGetter
	GetIdentityDeserializer func(chainID string) msp.IdentityDeserializer
}

// PutChaincodeToLocalStorage stores the supplied chaincode
// package to local storage (i.e. the file system)
func (s *SupportImpl) PutChaincodeToLocalStorage(ccpack ccprovider.CCPackage) error {
	if err := ccpack.PutChaincodeToFS(); err != nil {
		return errors.Errorf("error installing chaincode code %s:%s(%s)", ccpack.GetChaincodeData().Name, ccpack.GetChaincodeData().Version, err)
	}

	return nil
}

// GetChaincodeFromLocalStorage retrieves the chaincode package
// for the requested chaincode, specified by name and version
func (s *SupportImpl) GetChaincodeFromLocalStorage(ccNameVersion string) (ccprovider.CCPackage, error) {
	return ccprovider.GetChaincodeFromFS(ccNameVersion)
}

// GetChaincodesFromLocalStorage returns an array of all chaincode
// data that have previously been persisted to local storage
func (s *SupportImpl) GetChaincodesFromLocalStorage() (*pb.ChaincodeQueryResponse, error) {
	return ccprovider.GetInstalledChaincodes()
}

// GetInstantiationPolicy returns the instantiation policy for the

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Check and fix permissions on the peer's chaincode install directory (CORE_CHAINCODE_INSTALL_PATH, default /var/hyperledger/production/chaincodes) so the peer process user can write.
  2. Free disk space on the peer's volume (df -h) if the filesystem is full.
  3. Rebuild/repackage the chaincode and retry `peer chaincode install` to rule out a corrupt package.
  4. Inspect the wrapped cause in the message (the third %s) to address the specific filesystem or package error.

Example fix

// before: permission denied writing package
error installing chaincode code mycc:1.0(chmod /var/hyperledger/production/chaincodes/mycc.1.0: permission denied)
// after: fix ownership of the install dir
docker exec peer0 chown -R $(id -u):$(id -g) /var/hyperledger/production/chaincodes
# or set the volume fsGroup in the peer deployment
Defensive patterns

Strategy: validation

Validate before calling

// preflight: ensure the peer's install dir is writable and has space
path := "/var/hyperledger/production/chaincodes"
if fi, err := os.Stat(path); err != nil || !fi.IsDir() {
    return fmt.Errorf("install path %s missing: %w", path, err)
}
probe := filepath.Join(path, ".writecheck")
if err := os.WriteFile(probe, []byte("ok"), 0o600); err != nil {
    return fmt.Errorf("install path %s not writable: %w", path, err)
}
os.Remove(probe)

Try / catch

// Go: inspect the wrapped cause in the install error
if err := installChaincode(...); err != nil {
    var fsErr *os.PathError
    if errors.As(err, &fsErr) {
        return fmt.Errorf("fix filesystem/permissions for %s: %w", fsErr.Path, fsErr.Err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling SupportImpl.PutChaincodeToLocalStorage during `peer chaincode install` when PutChaincodeToFS fails: no write permission on the peer's chaincode directory, disk full, invalid/nil chaincode data in the package, or an unreadable/corrupt .tar.gz package.

Common situations: Peer running as a different user (Docker volume permission mismatch) so /var/hyperledger/production/chaincodes is unwritable; host disk full; installing a package built with mismatched metadata; Kubernetes/hostPath mounts with wrong fsGroup.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/38d574af70c843f3. Report an issue: GitHub.