github/copilot-sdk · error
go list failed
Error message
go list failed: %s
What it means
getSDKVersion shells out to `go list -m -f {{.Version}} <sdkModule>`. If the command exits nonzero, the captured stderr is surfaced as 'go list failed: <stderr>'. This reports exactly why Go's module tooling refused to resolve the copilot-sdk module.
Solutions
- Read the stderr shown in the error and address the `go list` cause directly
- Run `go mod tidy` from the module root to restore go.mod/go.sum consistency
- Confirm copilot-sdk appears in go.mod's require block
- Retry from the directory containing go.mod
Example fix
// before: go list failed: no required module provides package ... // after: // $ cd /path/to/module // $ go get github.com/github/copilot-sdk@latest && go mod tidy
Defensive patterns
Strategy: validation
Validate before calling
if _, err := exec.LookPath("go"); err != nil {
return errors.New("go toolchain required")
}
out, err := exec.Command("go", "list", "-m", "all").Output()
if err != nil || !bytes.Contains(out, []byte("copilot-sdk")) {
return errors.New("copilot-sdk not in module graph")
} Try / catch
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
log.Fatalf("go list failed: %s", exitErr.Stderr) // surface stderr to the user
}
} Prevention
- Run `go mod tidy` and commit consistent go.mod/go.sum
- Verify with `go list -m <sdkModule>` before bundling
- Keep the Go toolchain at the version go.mod requires
When it happens
Trigger: copilot-sdk is not a requirement of the current module, the go.mod/go.sum are inconsistent, the module is replaced to an invalid path, or `go` itself errors (bad toolchain, corrupt cache).
Common situations: Running the bundler outside the module that requires copilot-sdk; a broken replace directive; go.sum mismatch ('missing go.sum entry'); wrong Go toolchain version.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- module not found in go.mod
- 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/abd7a5807d1a5ec0.
Report an issue: GitHub.
Appendix: source
Thrown at go/cmd/bundler/main.go:289
fmt.Printf("Found copilot-sdk %s in go.mod\n", sdkVersion)
// Fetch package.json from the SDK repo at that version
cliVersion, err := fetchCLIVersionFromRepo(sdkVersion)
if err != nil {
return "", fmt.Errorf("failed to fetch CLI version: %w", err)
}
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)View on GitHub (pinned to cd8cf15dc3)