{"record":{"id":"c2eda30361e07427","repo":"golang/go","slug":"v-matches-packages-in-v-but-not-v-specify-a-di","errorCode":null,"errorMessage":"%v matches packages in %v but not %v: specify a different version for module %s","messagePattern":"(.+?) matches packages in (.+?) but not (.+?): specify a different version for module (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modget/get.go","lineNumber":1018,"sourceCode":"\t\t\t\tcontinue // curM already matches q.\n\t\t\t}\n\n\t\t\tif !q.matchesPath(curM.Path) {\n\t\t\t\tm := module.Version{Path: curM.Path, Version: rev.Version}\n\t\t\t\tpackages, err := r.matchInModule(ld, ctx, q.pattern, m)\n\t\t\t\tif err != nil {\n\t\t\t\t\treportError(q, err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif len(packages) == 0 {\n\t\t\t\t\t// curM at its original version contains a path matching q.pattern,\n\t\t\t\t\t// but at rev.Version it does not, so (somewhat paradoxically) if\n\t\t\t\t\t// we changed the version of curM it would no longer match the query.\n\t\t\t\t\tvar version any = m\n\t\t\t\t\tif rev.Version != q.version {\n\t\t\t\t\t\tversion = fmt.Sprintf(\"%s@%s (%s)\", m.Path, q.version, m.Version)\n\t\t\t\t\t}\n\t\t\t\t\treportError(q, fmt.Errorf(\"%v matches packages in %v but not %v: specify a different version for module %s\", q, curM, version, m.Path))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Since queryModule succeeded and either curM or one of the packages it\n\t\t\t// contains matches q.pattern, we should have either selected the version\n\t\t\t// of curM matching q, or reported a conflict error (and exited).\n\t\t\t// If we're still here and the version doesn't match,\n\t\t\t// something has gone very wrong.\n\t\t\treportError(q, fmt.Errorf(\"internal error: selected %v instead of %v\", curM, rev.Version))\n\t\t}\n\t}\n}\n\n// performPathQueries populates the candidates for each query whose pattern is\n// a path literal.\n//\n// The candidate packages and modules for path literals depend only on the","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modget/get.go#L1000-L1036","documentation":"This error occurs during module version resolution when a query pattern matches packages in a module at its currently-selected version (curM), but after querying a different version (rev.Version), the pattern no longer matches any packages. This typically happens when a module reorganizes its package structure between versions — packages are moved, renamed, or deleted. The error suggests specifying a different version of the module to resolve the conflict.","triggerScenarios":"During go get with a query that requires upgrading/downgrading a dependency. queryModule succeeds at the new version, but matchInModule at rev.Version finds zero packages matching the query pattern. The code constructs a descriptive error showing: the query (q), the original module (curM), the version that was tried, and the module path, then tells the user to specify a different version.","commonSituations":"A module moved packages between versions (e.g., v1.0.0 had 'example.com/m/pkg/foo' but v2.0.0 moved it to 'example.com/m/v2/pkg/foo'). A module deleted a package in a new release. A major version bump changes the module path, making the old import path invalid. An upgrade pulls a version where the requested sub-package was refactored into a different path.","solutions":["Check the module's changelog or release notes for package relocations between versions.","Pin to a version that still contains the package: 'go get example.com/m@v1.5.0' (the last version before the reorganization).","Update your import paths to match the new module structure: if the module moved to /v2, update imports to 'example.com/m/v2/pkg/foo'.","Use 'go mod graph' and 'go list -m -versions example.com/m' to see available versions and find one that contains your package."],"exampleFix":"# before\n$ go get example.com/m/pkg/foo@latest\n# query \"example.com/m/pkg/foo@latest\" matches packages in\n# example.com/m@v1.5.0 but not v2.0.0: specify a different version for module example.com/m\n\n# after: pin to last compatible version\n$ go get example.com/m@v1.5.0\n# or update import path for v2\n$ sed -i 's|example.com/m/|example.com/m/v2/|g' *.go\n$ go get example.com/m/v2@latest","handlingStrategy":"try-catch","validationCode":"// Before upgrading a dependency, check if packages still exist at the target version\nfunc checkPackagesAtVersion(modPath, version, pkgPattern string) error {\n    // Download the version and list packages\n    cmd := exec.Command(\"go\", \"mod\", \"download\", fmt.Sprintf(\"%s@%s\", modPath, version))\n    if err := cmd.Run(); err != nil { return err }\n    cmd = exec.Command(\"go\", \"list\", fmt.Sprintf(\"-m=%s@%s\", modPath, version), pkgPattern)\n    out, err := cmd.Output()\n    if err != nil || len(strings.TrimSpace(string(out))) == 0 {\n        return fmt.Errorf(\"package %s not found in %s@%s\", pkgPattern, modPath, version)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(stderr, \"matches packages in\") && strings.Contains(stderr, \"but not\") {\n    // Package moved or removed between versions\n    // Extract module path and try listing available versions\n    // Suggest: go list -m -versions <module> to find compatible version\n    // Suggest: check module changelog for package relocation\n}","preventionTips":["Check a module's changelog before major version upgrades","Use 'go list -m -json -versions <module>' to see available versions","Pin critical dependencies to known-good versions in go.mod","Test upgrades in a branch before applying to main","Watch for major version path changes (v1 -> v2 requires import path updates)"],"tags":["go-get","go-modules","version-conflict","dependency-resolution","package-relocation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}