{"record":{"id":"30ec079c77e92de8","repo":"golang/go","slug":"package-s-not-provided-by-module-s","errorCode":null,"errorMessage":"package %s not provided by module %s","messagePattern":"package (.+?) not provided by module (.+?)","errorType":"exception","errorClass":"PackageError","httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/pkg.go","lineNumber":3481,"sourceCode":"\t}\n\n\t// Since we are in NoRoot mode, the build list initially contains only\n\t// the dummy command-line-arguments module. Add a requirement on the\n\t// module that provides the packages named on the command line.\n\tif _, err := modload.EditBuildList(ld, ctx, nil, []module.Version{rootMod}); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", args[0], err)\n\t}\n\n\t// Load packages for all arguments.\n\tpkgs := PackagesAndErrors(ld, ctx, opts, patterns)\n\n\t// Check that named packages are all provided by the same module.\n\tfor _, pkg := range pkgs {\n\t\tvar pkgErr error\n\t\tif pkg.Module == nil {\n\t\t\t// Packages in std, cmd, and their vendored dependencies\n\t\t\t// don't have this field set.\n\t\t\tpkgErr = fmt.Errorf(\"package %s not provided by module %s\", pkg.ImportPath, rootMod)\n\t\t} else if pkg.Module.Path != rootMod.Path || pkg.Module.Version != rootMod.Version {\n\t\t\tpkgErr = fmt.Errorf(\"package %s provided by module %s@%s\\n\\tAll packages must be provided by the same module (%s).\", pkg.ImportPath, pkg.Module.Path, pkg.Module.Version, rootMod)\n\t\t}\n\t\tif pkgErr != nil && pkg.Error == nil {\n\t\t\tpkg.Error = &PackageError{Err: pkgErr}\n\t\t\tpkg.Incomplete = true\n\t\t}\n\t}\n\n\tmatchers := make([]func(string) bool, len(patterns))\n\tfor i, p := range patterns {\n\t\tif strings.Contains(p, \"...\") {\n\t\t\tmatchers[i] = pkgpattern.MatchPattern(p)\n\t\t}\n\t}\n\treturn pkgs, nil\n}\n","sourceCodeStart":3463,"sourceCodeEnd":3499,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/pkg.go#L3463-L3499","documentation":"After loading all package arguments, a matched package has `pkg.Module == nil`, which happens for stdlib, cmd, and their vendored dependencies. The NoRoot install workflow requires every matched package to come from the resolved root module, so a nil-Module package is rejected.","triggerScenarios":"A wildcard pattern like `example.com/...@v1.0.0` matches a path that resolves to a stdlib or cmd package; the module re-exports a name that collides with stdlib; the pattern accidentally covers a vendored stdlib dependency.","commonSituations":"Pattern matching unexpectedly hits a stdlib package; module path collides with a stdlib name; misconfigured module that vendored stdlib deps.","solutions":["Replace wildcard patterns (`...`) with exact package import paths from the target module.","Verify module boundaries with `go list -m all` from a local checkout.","Check for stdlib name collisions in the module's package list."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Avoid wildcards; resolve exact package paths first.\nfunc expandPackages(mod, ver string) ([]string, error) {\n    out, err := exec.Command(\"go\", \"list\", \"-m\", \"-json\", mod+\"@\"+ver).Output()\n    if err != nil { return nil, err }\n    _ = out\n    // enumerate packages explicitly rather than passing '...'\n    return nil, nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer explicit package paths over `...` wildcards in install scripts.","Confirm each package's module with `go list -m -json <pkg>`.","Watch for module paths that collide with stdlib package names."],"tags":["go-toolchain","module","package-loading","install"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}