hyperledger/fabric · error
not a module or not in module mode
Error message
not a module or not in module mode
What it means
gomodDevConfigDir ran 'go env GOMOD' and got an empty string, meaning the process is not inside a Go module (classic GOPATH mode or no go.mod). The module root is needed to locate the adjacent sampleconfig directory.
Source
Thrown at core/config/configtest/config.go:84
return devPath, nil
}
}
return "", errors.New("unable to find sampleconfig directory on GOPATH")
}
func gomodDevConfigDir() (string, error) {
buf := bytes.NewBuffer(nil)
cmd := exec.Command("go", "env", "GOMOD")
cmd.Stdout = buf
if err := cmd.Run(); err != nil {
return "", err
}
modFile := strings.TrimSpace(buf.String())
if modFile == "" {
return "", errors.New("not a module or not in module mode")
}
devPath := filepath.Join(filepath.Dir(modFile), "sampleconfig")
if !dirExists(devPath) {
return "", fmt.Errorf("%s does not exist", devPath)
}
return devPath, nil
}
// GetDevMspDir gets the path to the sampleconfig/msp tree that is maintained
// with the source tree. This should only be used in a test/development
// context.
func GetDevMspDir() string {
devDir := GetDevConfigDir()
return filepath.Join(devDir, "msp")
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Run from within the fabric module (ensure a go.mod is present)
- Set GO111MODULE=on in the environment
- Fall back to a GOPATH-based dev config dir
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at core/config/configtest/config.go:84 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/4254a6f31531c7a8.
Report an issue: GitHub.