hyperledger/fabric · error

error reading chaincode install package at %s

Error message

error reading chaincode install package at %s

What it means

Store.Load successfully confirmed the package file exists but ReadWriter.ReadFile failed reading it; the error is wrapped with 'error reading chaincode install package at %s'. The launch/build of the chaincode fails.

Source

Thrown at core/chaincode/persistence/persistence.go:198

// Load loads a persisted chaincode install package bytes with
// the given packageID.
func (s *Store) Load(packageID string) ([]byte, error) {
	ccInstallPkgPath := filepath.Join(s.Path, CCFileName(packageID))

	exists, err := s.ReadWriter.Exists(ccInstallPkgPath)
	if err != nil {
		return nil, errors.Wrapf(err, "could not determine whether chaincode install package '%s' exists", packageID)
	}
	if !exists {
		return nil, &CodePackageNotFoundErr{
			PackageID: packageID,
		}
	}

	ccInstallPkg, err := s.ReadWriter.ReadFile(ccInstallPkgPath)
	if err != nil {
		err = errors.Wrapf(err, "error reading chaincode install package at %s", ccInstallPkgPath)
		return nil, err
	}

	return ccInstallPkg, nil
}

// Delete deletes a persisted chaincode.  Note, there is no locking,
// so this should only be performed if the chaincode has already
// been marked built.
func (s *Store) Delete(packageID string) error {
	ccInstallPkgPath := filepath.Join(s.Path, CCFileName(packageID))
	return s.ReadWriter.Remove(ccInstallPkgPath)
}

// CodePackageNotFoundErr is the error returned when a code package cannot
// be found in the persistence store
type CodePackageNotFoundErr struct {
	PackageID string

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Fix read permissions on the package file/dir for the peer user
  2. Re-install the chaincode package (peer lifecycle chaincode install) to rewrite a corrupt/truncated file
  3. Check storage health (disk errors, NFS state) in the wrapped cause
  4. Restore from backup if the package was damaged by admin tooling

Example fix

// before (corrupt file)
$ peer lifecycle chaincode queryinstalled  # works, but build fails
// after
$ peer lifecycle chaincode install repaired-pkg.tgz
Defensive patterns

Strategy: validation

Validate before calling

p := filepath.Join(storePath, persistence.CCFileName(packageID))
f, err := os.Open(p); if err != nil { return err }; defer f.Close()
if _, err := io.ReadFull(f, make([]byte, 1)); err != nil { return fmt.Errorf("unreadable: %w", err) }

Try / catch

pkg, err := store.Load(packageID)
if err != nil && strings.Contains(err.Error(), "error reading chaincode install package") {
  // repair by re-installing the package
}

Prevention

When it happens

Trigger: Calling Load(packageID) when the file exists per Exists() but open/read fails: permission change between check and read, corrupted storage, truncated file on a full disk.

Common situations: File perms altered by backup/restore tooling; partially written package after an earlier disk-full save; NFS stale handle on network storage.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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