{"record":{"id":"0d910f9b326ba1d8","repo":"golang/go","slug":"error-loading-go-s-module-graph-w","errorCode":null,"errorMessage":"error loading go %s module graph: %w","messagePattern":"error loading go (.+?) module graph: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/load.go","lineNumber":2100,"sourceCode":"\t\t\t\teFlag = \" -e\"\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, \"To upgrade to the versions selected by go %s%s:\\n\\tgo mod tidy%s -go=%s && go mod tidy%s -go=%s%s\\n\", compatVersion, eDesc, eFlag, compatVersion, eFlag, goVersion, compatFlag)\n\t\t} else if suggestEFlag {\n\t\t\t// If some packages are missing but no package is upgraded, then we\n\t\t\t// shouldn't suggest upgrading to the Go 1.16 versions explicitly — that\n\t\t\t// wouldn't actually fix anything for Go 1.16 users, and *would* break\n\t\t\t// something for Go 1.17 users.\n\t\t\tfmt.Fprintf(os.Stderr, \"To proceed despite packages unresolved in go %s:\\n\\tgo mod tidy -e%s%s\\n\", compatVersion, goFlag, compatFlag)\n\t\t}\n\n\t\tfmt.Fprintf(os.Stderr, \"If reproducibility with go %s is not needed:\\n\\tgo mod tidy%s -compat=%s\\n\", compatVersion, goFlag, goVersion)\n\n\t\tfmt.Fprintf(os.Stderr, \"For information about 'go mod tidy' compatibility, see:\\n\\thttps://go.dev/ref/mod#graph-pruning\\n\")\n\t}\n\n\tmg, err := rs.Graph(ld, ctx)\n\tif err != nil {\n\t\tpld.error(fmt.Errorf(\"error loading go %s module graph: %w\", compatVersion, err))\n\t\tpld.switchIfErrors(ctx)\n\t\tsuggestFixes()\n\t\tpld.exitIfErrors(ctx)\n\t\treturn\n\t}\n\n\t// Re-resolve packages in parallel.\n\t//\n\t// We re-resolve each package — rather than just checking versions — to ensure\n\t// that we have fetched module source code (and, importantly, checksums for\n\t// that source code) for all modules that are necessary to ensure that imports\n\t// are unambiguous. That also produces clearer diagnostics, since we can say\n\t// exactly what happened to the package if it became ambiguous or disappeared\n\t// entirely.\n\t//\n\t// We re-resolve the packages in parallel because this process involves disk\n\t// I/O to check for package sources, and because the process of checking for\n\t// ambiguous imports may require us to download additional modules that are","sourceCodeStart":2082,"sourceCodeEnd":2118,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/load.go#L2082-L2118","documentation":"Thrown by checkTidyCompatibility (load.go:2100) when rs.Graph(ld, ctx) fails while building the module graph for an older Go compat version. During 'go mod tidy', the loader verifies reproducibility with prior Go versions; if it cannot even load the graph for the compat version, it wraps the underlying graph error with the compat version string and suggests fixes (printed to stderr). The %w preserves the original error for unwrapping.","triggerScenarios":"Running 'go mod tidy' when the module graph cannot be loaded for the compat version (the Go version prior to the one in the go.mod 'go' directive). This happens if a required module is unreachable, has a bad go.mod, or fails checksum verification when loaded for the older compat version.","commonSituations":"Network or proxy issues fetching a module needed for the compat check. A transitive dependency whose go.mod is malformed. 'go mod tidy' after changing the 'go' directive version, where the older graph references unavailable modules.","solutions":["Check the wrapped error (the %w part) for the root cause — often a network or checksum issue.","Set GOPROXY correctly or verify module availability in your proxy/cache.","Use 'go mod tidy -compat=X' explicitly to target a specific compat version, or '-e' to proceed despite errors."],"exampleFix":"# before — compat graph fails due to unreachable module\ngo mod tidy\n# error loading go 1.22 module graph: ...\n\n# after — fix proxy or proceed with -e\ngo mod tidy -e\n# or set GOPROXY and retry:\nGOPROXY=https://proxy.golang.org,direct go mod tidy","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// When running go mod tidy, handle compat graph load failures.\nerr := runGoModTidy()\nif err != nil && strings.Contains(err.Error(), \"error loading go\") && strings.Contains(err.Error(), \"module graph\") {\n    // Retry with -e to proceed despite compat issues, or adjust -compat.\n    runGoModTidyWithFlags(\"-e\")\n}","preventionTips":["Ensure GOPROXY is set to a reachable proxy (e.g. https://proxy.golang.org,direct).","Keep go.sum consistent with go.mod to avoid checksum failures during graph loading.","Use 'go mod tidy -compat=<version>' to control which compat version is checked."],"tags":["go-mod-tidy","compat","module-graph","network","checksum"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}