{"record":{"id":"c9c96370093c2b98","repo":"golang/go","slug":"s-all-arguments-must-refer-to-packages-in-the-sa","errorCode":null,"errorMessage":"%s: all arguments must refer to packages in the same module at the same version (@%s)","messagePattern":"(.+?): all arguments must refer to packages in the same module at the same version \\(@(.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/pkg.go","lineNumber":3401,"sourceCode":"\t}\n\n\t// Check that the arguments satisfy syntactic constraints.\n\tvar version string\n\tvar firstPath string\n\tfor _, arg := range args {\n\t\tif i := strings.Index(arg, \"@\"); i >= 0 {\n\t\t\tfirstPath, version = arg[:i], arg[i+1:]\n\t\t\tif version == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"%s: version must not be empty\", arg)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tpatterns := make([]string, len(args))\n\tfor i, arg := range args {\n\t\tp, found := strings.CutSuffix(arg, \"@\"+version)\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"%s: all arguments must refer to packages in the same module at the same version (@%s)\", arg, version)\n\t\t}\n\t\tswitch {\n\t\tcase build.IsLocalImport(p):\n\t\t\treturn nil, fmt.Errorf(\"%s: argument must be a package path, not a relative path\", arg)\n\t\tcase filepath.IsAbs(p):\n\t\t\treturn nil, fmt.Errorf(\"%s: argument must be a package path, not an absolute path\", arg)\n\t\tcase search.IsMetaPackage(p):\n\t\t\treturn nil, fmt.Errorf(\"%s: argument must be a package path, not a meta-package\", arg)\n\t\tcase pathpkg.Clean(p) != p:\n\t\t\treturn nil, fmt.Errorf(\"%s: argument must be a clean package path\", arg)\n\t\tcase !strings.Contains(p, \"...\") && search.IsStandardImportPath(p) && modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, p):\n\t\t\treturn nil, fmt.Errorf(\"%s: argument must not be a package in the standard library\", arg)\n\t\tdefault:\n\t\t\tpatterns[i] = p\n\t\t}\n\t}\n\tpatterns = search.CleanPatterns(patterns)\n","sourceCodeStart":3383,"sourceCodeEnd":3419,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/pkg.go#L3383-L3419","documentation":"Returned by PackagesAndErrorsOutsideModule (line 3401) during the second pass over args. Once a version is established from the first '@'-bearing arg, EVERY other arg must end with that exact `@<version>` suffix (strings.CutSuffix). If CutSuffix fails for any arg, that arg is not in the same module at the same version, which the function forbids to avoid ambiguity. The echoed @<version> is the canonical suffix expected.","triggerScenarios":"Mixing versions in one `go install` command: `go install example.com/a@v1.0.0 example.com/b@v2.0.0`; or forgetting the @version on a second arg: `go install mod/a@v1.0.0 mod/b`.","commonSituations":"Installing several binaries and assuming they share a version; CI matrix scripts concatenating differently-versioned args; refactoring a multi-binary install line.","solutions":["Give every argument the identical `@<version>` suffix.","If the packages genuinely live in different modules/versions, run separate `go install` invocations.","Verify with `go list -m` which module each package belongs to before combining them."],"exampleFix":"# before\ngo install example.com/app/cmd/a@v1.0.0 example.com/app/cmd/b\n# after\ngo install example.com/app/cmd/a@v1.0.0 example.com/app/cmd/b@v1.0.0","handlingStrategy":"validation","validationCode":"// Confirm every arg in a multi-arg `go install pkg@version` carries the\n// SAME @<version> suffix.\npackage argcheck\n\nimport (\n\t\"errors\"\n\t\"strings\"\n)\n\nfunc UniformVersion(args []string) error {\n\tvar version string\n\tfor _, a := range args {\n\t\tif i := strings.Index(a, \"@\"); i >= 0 {\n\t\t\tversion = a[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\tif version == \"\" {\n\t\treturn errors.New(\"no @version found on any arg\")\n\t}\n\tfor _, a := range args {\n\t\tif !strings.HasSuffix(a, version) {\n\t\t\treturn errors.New(\"arg \" + a + \" lacks shared version \" + version)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin all binaries in one `go install` line to the same module version, or split into multiple invocations.","Generate install lines from a lockfile so versions never drift."],"tags":["modules","go-install","cli","toolchain"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}