hyperledger/fabric · error

listing deps for package %s failed

Error message

listing deps for package %s failed

What it means

gopathDependencyPackageInfo wraps the exit error of the spawned 'go list' command with 'listing deps for package %s failed'. The go toolchain itself exited non-zero while computing the dependency list, so dependency walking for the package fails.

Source

Thrown at core/chaincode/platforms/golang/list.go:90

	for {
		var packageInfo PackageInfo
		if err := decoder.Decode(&packageInfo); errors.Is(err, io.EOF) {
			break
		} else if err != nil {
			return nil, err
		}

		if packageInfo.Incomplete {
			return nil, fmt.Errorf("failed to calculate dependencies: incomplete package: %s", packageInfo.ImportPath)
		}
		if !packageInfo.Goroot {
			list = append(list, packageInfo)
		}
	}

	err = cmd.Wait()
	if err != nil {
		return nil, errors.Wrapf(err, "listing deps for package %s failed", pkg)
	}

	return list, nil
}

func wrapExitErr(err error, message string) error {
	if ee, ok := err.(*exec.ExitError); ok {
		return errors.Wrapf(err, message+" with: %s", strings.TrimRight(string(ee.Stderr), "\n\r\t"))
	}
	return errors.Wrap(err, message)
}

type ModuleInfo struct {
	Dir        string
	GoMod      string
	ImportPath string
	ModulePath string
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Read the wrapped go stderr in the error to see go's own message
  2. Fix compile/import errors in the chaincode package ('go build ./...')
  3. Align the Go toolchain version used by the peer builder with the chaincode requirements
  4. Ensure the package directory is a valid Go package with a .go file at the expected path

Example fix

// chaincode with broken import
import "github.com/me/lib"  // not in go.mod
// after
$ go get github.com/me/lib && go mod vendor
Defensive patterns

Strategy: validation

Validate before calling

cmd := exec.Command("go", "list", "./...")
if out, err := cmd.CombinedOutput(); err != nil {
  return fmt.Errorf("go list failed: %v: %s", err, out)
}

Prevention

When it happens

Trigger: cmd.Wait() returns non-zero after 'go list -deps -json ...' runs on the chaincode package — compile errors in scanned deps, bad GOFLAGS/GO111MODULE env, or go binary issues in the peer environment.

Common situations: Chaincode source does not compile (syntax/type errors) causing go list to fail; incompatible Go version in the peer vs chaincode; GO111MODULE/go env conflicts in the builder container.

Related errors


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