{"record":{"id":"74b90959da6b1c8c","repo":"golang/go","slug":"s-loaded-from-v-but-go-s-would-fail-to-locate","errorCode":null,"errorMessage":"%s loaded from %v,\n\tbut go %s would fail to locate it in %s","messagePattern":"(.+?) loaded from (.+?),\n\tbut go (.+?) would fail to locate it in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/cmd/go/internal/modload/load.go","lineNumber":2203,"sourceCode":"\t\tswitch {\n\t\tcase mismatch.err != nil:\n\t\t\t// pkg resolved successfully, but errors out using the requirements in rs.\n\t\t\t//\n\t\t\t// This could occur because the import is provided by a single root (and\n\t\t\t// is thus unambiguous in a main module with a pruned module graph) and\n\t\t\t// also one or more transitive dependencies (and is ambiguous with an\n\t\t\t// unpruned graph).\n\t\t\t//\n\t\t\t// It could also occur because some transitive dependency upgrades the\n\t\t\t// module that previously provided the package to a version that no\n\t\t\t// longer does, or to a version for which the module source code (but\n\t\t\t// not the go.mod file in isolation) has a checksum error.\n\t\t\tif _, ok := errors.AsType[*ImportMissingError](mismatch.err); ok {\n\t\t\t\tselected := module.Version{\n\t\t\t\t\tPath:    pkg.mod.Path,\n\t\t\t\t\tVersion: mg.Selected(pkg.mod.Path),\n\t\t\t\t}\n\t\t\t\tpld.error(fmt.Errorf(\"%s loaded from %v,\\n\\tbut go %s would fail to locate it in %s\", pkg.stackText(), pkg.mod, compatVersion, selected))\n\t\t\t} else {\n\t\t\t\tif _, ok := errors.AsType[*AmbiguousImportError](mismatch.err); ok {\n\t\t\t\t\t// TODO: Is this check needed?\n\t\t\t\t}\n\t\t\t\tpld.error(fmt.Errorf(\"%s loaded from %v,\\n\\tbut go %s would fail to locate it:\\n\\t%v\", pkg.stackText(), pkg.mod, compatVersion, mismatch.err))\n\t\t\t}\n\n\t\t\tsuggestEFlag = true\n\n\t\t\t// Even if we press ahead with the '-e' flag, the older version will\n\t\t\t// error out in readonly mode if it thinks the go.mod file contains\n\t\t\t// any *explicit* dependency that is not at its selected version,\n\t\t\t// even if that dependency is not relevant to any package being loaded.\n\t\t\t//\n\t\t\t// We check for that condition here. If all of the roots are consistent\n\t\t\t// the '-e' flag suffices, but otherwise we need to suggest an upgrade.\n\t\t\tif !suggestUpgrade {\n\t\t\t\tfor _, m := range pld.requirements.rootModules {","sourceCodeStart":2185,"sourceCodeEnd":2221,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/load.go#L2185-L2221","documentation":"Thrown by checkTidyCompatibility (load.go:2203) when a package currently loads successfully from a module, but under the older compat Go version's module graph it would not be locatable (an ImportMissingError). The error reports the package's import stack, the module it loads from now, the compat version, and the module version the older Go would select instead. This warns that reproducibility with the older Go version would break. suggestEFlag is set to true so the fix hints recommend -e.","triggerScenarios":"During 'go mod tidy', a package is imported that resolves under the current (pruned) graph but would be unresolved under the compat version's (unpruned) graph. This happens when a transitive dependency upgraded a module to a version that drops the package, or when graph pruning hides ambiguity that the older unpruned graph would expose.","commonSituations":"Bumping the 'go' directive in go.mod to a newer version that uses graph pruning, while a dependency's version drift means older Go versions cannot find a package. After 'go get' upgrades that move packages between module versions.","solutions":["Run 'go mod tidy -e' to proceed despite the compat mismatch (as the error's fix hints suggest).","Alternatively, update the '-compat' flag to match the oldest Go version you actually need reproducibility with: 'go mod tidy -compat=1.23'.","If reproducibility with the old version is not needed, set '-compat' to the current go directive version."],"exampleFix":"# before — compat mismatch on tidy\ngo mod tidy\n# ... loaded from X, but go 1.22 would fail to locate it\n\n# after — proceed or adjust compat\ngo mod tidy -e\n# or:\ngo mod tidy -compat=1.23","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'go mod tidy -compat=<oldest-needed-version>' to limit compat checks to versions you actually support.","If you don't need backward reproducibility, set -compat to the current go directive version.","Use 'go mod tidy -e' to proceed despite non-fatal compat mismatches."],"tags":["go-mod-tidy","compat","graph-pruning","import-missing","reproducibility"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}