github/copilot-sdk · error
module not found in go.mod
Error message
module %s not found in go.mod
What it means
After `go list -m` succeeds, getSDKVersion trims the output; if it is empty it concludes the copilot-sdk module is not recorded in go.mod and returns this error. `go list -m` printing an empty version means the module path cannot be resolved to a concrete version in this build.
Solutions
- Add the dependency: `go get <copilot-sdk-module>@latest`
- Verify the require line exists in go.mod and has a version
- Run `go mod tidy` and confirm `go list -m <sdkModule>` prints a version
- Re-run the bundler
Example fix
// before go.mod: (no copilot-sdk entry) // after go.mod: // require github.com/github/copilot-sdk v0.5.0
Defensive patterns
Strategy: validation
Validate before calling
out, _ := exec.Command("go", "list", "-m", "-f", "{{.Version}}", sdkModule).Output()
if len(bytes.TrimSpace(out)) == 0 {
return errors.New("add copilot-sdk with: go get " + sdkModule + "@latest")
} Try / catch
if _, err := getSDKVersion(); err != nil {
if strings.Contains(err.Error(), "not found in go.mod") {
exec.Command("go", "get", sdkModule+"@latest").Run()
}
} Prevention
- Add copilot-sdk as a direct requirement before bundling
- Check go.mod's require block during project setup
- Avoid bare replace directives without a resolvable version
When it happens
Trigger: sdkModule is not present in the require graph (never added, or only present as an indirect/local replace without a version), producing empty output from `go list -m -f {{.Version}}`.
Common situations: Fresh project where copilot-sdk was never `go get`-ed; a replace directive pointing at a path with no pseudo-version; vendored setups missing the module metadata.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- go list failed
- failed to get SDK version
- failed to add zstd dependency
- WebSocket forwarding requires the 'websockets' package…
- SessionFS.InitialWorkingDirectory is required
AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09).
Data as JSON: /api/errors/14207e98653f9958.
Report an issue: GitHub.
Appendix: source
Thrown at go/cmd/bundler/main.go:296
}
return cliVersion, nil
}
// getSDKVersion runs "go list -m" to get the copilot-sdk version from go.mod
func getSDKVersion() (string, error) {
cmd := exec.Command("go", "list", "-m", "-f", "{{.Version}}", sdkModule)
output, err := cmd.Output()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
return "", fmt.Errorf("go list failed: %s", string(exitErr.Stderr))
}
return "", err
}
version := strings.TrimSpace(string(output))
if version == "" {
return "", fmt.Errorf("module %s not found in go.mod", sdkModule)
}
return version, nil
}
// fetchCLIVersionFromRepo fetches package.json from GitHub and extracts the CLI version.
func fetchCLIVersionFromRepo(sdkVersion string) (string, error) {
// Convert Go module version to Git ref
// v0.1.0 -> v0.1.0
// v0.1.0-beta.1 -> v0.1.0-beta.1
// v0.0.0-20240101120000-abcdef123456 -> abcdef123456 (pseudo-version)
gitRef := sdkVersion
// Pseudo-versions end with a 12-character commit hash.
// Format: vX.Y.Z-yyyymmddhhmmss-abcdefabcdef
if idx := strings.LastIndex(sdkVersion, "-"); idx != -1 {
suffix := sdkVersion[idx+1:]
// Use the commit hash when present so we fetch the exact source snapshot.View on GitHub (pinned to cd8cf15dc3)