golang/go · error
%s: argument must not be a package in the standard library
Error message
%s: argument must not be a package in the standard library
What it means
The package@version install workflow (NoRoot mode) cannot target standard library packages, because stdlib packages are versioned with the Go toolchain itself rather than as modules. The path passes `search.IsStandardImportPath` and `modindex.IsStandardPackage`, so the command refuses it.
Source
Thrown at src/cmd/go/internal/load/pkg.go:3413
}
}
patterns := make([]string, len(args))
for i, arg := range args {
p, found := strings.CutSuffix(arg, "@"+version)
if !found {
return nil, fmt.Errorf("%s: all arguments must refer to packages in the same module at the same version (@%s)", arg, version)
}
switch {
case build.IsLocalImport(p):
return nil, fmt.Errorf("%s: argument must be a package path, not a relative path", arg)
case filepath.IsAbs(p):
return nil, fmt.Errorf("%s: argument must be a package path, not an absolute path", arg)
case search.IsMetaPackage(p):
return nil, fmt.Errorf("%s: argument must be a package path, not a meta-package", arg)
case pathpkg.Clean(p) != p:
return nil, fmt.Errorf("%s: argument must be a clean package path", arg)
case !strings.Contains(p, "...") && search.IsStandardImportPath(p) && modindex.IsStandardPackage(cfg.GOROOT, cfg.BuildContext.Compiler, p):
return nil, fmt.Errorf("%s: argument must not be a package in the standard library", arg)
default:
patterns[i] = p
}
}
patterns = search.CleanPatterns(patterns)
// Query the module providing the first argument, load its go.mod file, and
// check that it doesn't contain directives that would cause it to be
// interpreted differently if it were the main module.
//
// If multiple modules match the first argument, accept the longest match
// (first result). It's possible this module won't provide packages named by
// later arguments, and other modules would. Let's not try to be too
// magical though.
allowed := ld.CheckAllowed
if modload.IsRevisionQuery(firstPath, version) {
// Don't check for retractions if a specific revision is requested.
allowed = nilView on GitHub (pinned to b6b368adc5)
Solutions
- Drop the `@version` suffix — stdlib is already part of your toolchain (`go install fmt` is unnecessary).
- If you intended a third-party module, correct the import path to the real module path.
- For tooling that builds install commands, skip or special-case stdlib paths using `go list std` or `modindex.IsStandardPackage`.
Example fix
// before go install fmt@latest // after // fmt ships with Go; just import it in code. No install needed.
Defensive patterns
Strategy: validation
Validate before calling
// Before appending @version, exclude stdlib paths.
func isStdlib(p string) bool {
// mirrors search.IsStandardImportPath + modindex.IsStandardPackage heuristically
if !strings.Contains(p, ".") {
return true // crude but effective for most stdlib paths
}
return false
} Prevention
- In tooling that builds install commands, skip or special-case stdlib paths.
- Cross-reference candidate paths against `go list std` before appending @version.
- Treat any path without a dot in the first segment as potentially stdlib.
When it happens
Trigger: Running `go install fmt@v1.0.0`, `go install net/http@latest`, or any `pkg@version` where `pkg` resolves to a stdlib package (and the path has no `...` wildcard).
Common situations: Confusing a stdlib import path with a third-party module; automation that blindly appends `@version` to any import path; typos that collide with a stdlib package name.
Related errors
- %s: argument must be a clean package path
- %s: %w
- package %s not provided by module %s
- package %s provided by module %s@%s All packages must be pr
- module requires Go ${p.Module.GoVersion} or later
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/799b11e144d34a4f.
Report an issue: GitHub.