golang/go · error
can't query specific version (%q) of standard-library module
Error message
can't query specific version (%q) of standard-library module %q
What it means
Returned by queryProxy when the queried path is the standard-library module 'std' or 'cmd' and a specific version query is requested. The standard library is part of the toolchain and has no independent downloadable versions, so version queries against it are meaningless and rejected.
Source
Thrown at src/cmd/go/internal/modload/query.go:223
return nil, fmt.Errorf("invalid previous version %v@%v", path, current)
}
if cfg.BuildMod == "vendor" {
return nil, errQueryDisabled
}
if allowed == nil {
allowed = func(context.Context, module.Version) error { return nil }
}
if ld.MainModules.Contains(path) && (query == "upgrade" || query == "patch") {
m := module.Version{Path: path}
if err := allowed(ctx, m); err != nil {
return nil, fmt.Errorf("internal error: main module version is not allowed: %w", err)
}
return &modfetch.RevInfo{Version: m.Version}, nil
}
if path == "std" || path == "cmd" {
return nil, fmt.Errorf("can't query specific version (%q) of standard-library module %q", query, path)
}
repo, err := lookupRepo(ld, ctx, proxy, path)
if err != nil {
return nil, err
}
if old := reuse[module.Version{Path: path, Version: query}]; old != nil {
if err := checkReuseRepo(ctx, repo, path, query, old.Origin); err == nil {
info := &modfetch.RevInfo{
Version: old.Version,
Origin: old.Origin,
}
if old.Time != nil {
info.Time = *old.Time
}
return info, nil
}View on GitHub (pinned to b6b368adc5)
Solutions
- Remove the version query for std/cmd — these are provided by the Go toolchain itself, not fetched.
- If upgrading the standard library is the goal, upgrade the Go toolchain (e.g. via the 'toolchain' directive or installing a newer Go).
- Filter std/cmd out of any batch 'go get' loop over required modules.
Example fix
// before
$ go get std@latest
// error: can't query specific version ("latest") of standard-library module "std"
// after
$ go version // std comes from this; upgrade Go to change it
$ go get example.com/realdep@latest Defensive patterns
Strategy: validation
Validate before calling
// Skip version queries for standard-library modules:
// if path == "std" || path == "cmd" { /* do not call queryProxy with a version */ } Type guard
func isQueryableModule(path string) bool {
return path != "std" && path != "cmd"
} Prevention
- Filter std/cmd out of batch 'go get' loops.
- Remember the standard library ships with the toolchain — upgrade Go, not modules.
- Lint scripts that iterate over go.mod requires to skip std/cmd.
When it happens
Trigger: Running 'go get std@v1.2.3', 'go list -m -versions std', 'go get cmd@latest', or any version-specific query targeting the std or cmd module path.
Common situations: Scripts or Makefiles that indiscriminately 'go get' every module in go.mod including std/cmd; copy-pasting a 'go get <path>@latest' loop that hits the standard library; tooling that resolves dependencies generically.
Related errors
- invalid previous version %v@%v
- invalid semantic version %q in range %q
- revision is longer than canonical (expected %s)
- revision is shorter than canonical (expected %s)
- does not match version-control timestamp (expected %s)
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/1d14fbea368e35b6.
Report an issue: GitHub.