golang/go · error
%s: argument must be a package path, not a meta-package
Error message
%s: argument must be a package path, not a meta-package
What it means
Returned by PackagesAndErrorsOutsideModule (line 3409) when, after stripping @version, search.IsMetaPackage(p) is true. Meta-packages are the special wildcards `all`, `cmd`, `main`, and `std`. They expand to many packages across modules and cannot be pinned to a single module@version, so `go install <meta>@version` is rejected. The arg as written is echoed.
Source
Thrown at src/cmd/go/internal/load/pkg.go:3409
if version == "" {
return nil, fmt.Errorf("%s: version must not be empty", arg)
}
break
}
}
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.View on GitHub (pinned to b6b368adc5)
Solutions
- List each binary explicitly with its module path and version: `go install golang.org/x/tools/cmd/goimports@latest`.
- For a local `all`/`cmd` build (no @version), use `go install ./cmd/...` from the module root.
Example fix
# before go install cmd@latest # after go install golang.org/x/tools/cmd/goimports@latest github.com/user/proj/cmd/app@latest
Defensive patterns
Strategy: validation
Validate before calling
// Reject meta-packages ('all', 'cmd', 'main', 'std') in go install pkg@version.
package argcheck
import (
"errors"
"strings"
)
func NotMetaPackage(arg string) error {
p := arg
if i := strings.Index(arg, "@"); i >= 0 {
p = arg[:i]
}
switch p {
case "all", "cmd", "main", "std":
return errors.New("meta-package not allowed with @version: " + arg)
}
return nil
} Prevention
- Expand meta-packages into concrete import paths before pinning a version.
- Use `go install ./cmd/...` (no @version) for local wildcard installs.
When it happens
Trigger: Running `go install all@v1.0.0`, `go install cmd@latest`, `go install std@v1.2.0`, or `go install main@v1.0.0`. These expansions have no single owning module/version.
Common situations: Trying to reinstall every command via `go install cmd@latest`; confusing `go install ./cmd/...` (allowed) with `go install cmd@version` (rejected); tutorials suggesting `all@latest`.
Related errors
- %s: version must not be empty
- %s: all arguments must refer to packages in the same module
- %s: argument must be a package path, not a relative path
- %s: argument must be a package path, not an absolute path
- tool %q is ambiguous; choose one of:
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/cc61ed71847eecae.
Report an issue: GitHub.