golang/go · error
%s: can not find version number in %q
Error message
%s: can not find version number in %q
What it means
gccToolIDPrefix parsed the -### output line-by-line looking for a token 'version' immediately followed by a digit. If no line matches, the compiler's output format is unrecognized and the tool ID cannot be derived. The raw output is included in the error.
Source
Thrown at src/cmd/go/internal/work/buildid.go:278
// Check that the next field is plausibly a version number.
// We require only that it begins with an ASCII digit,
// since we don't know what version numbering schemes a given
// C compiler may use. (Clang and GCC mostly seem to follow the scheme X.Y.Z,
// but in https://go.dev/issue/64619 we saw "8.3 [DragonFly]", and who knows
// what other C compilers like "zig cc" might report?)
next := fields[i+1]
if len(next) > 0 && next[0] >= '0' && next[0] <= '9' {
version = line
break
}
}
}
if version != "" {
break
}
}
if version == "" {
return "", "", fmt.Errorf("%s: can not find version number in %q", name, out)
}
if !strings.Contains(version, "experimental") {
// This is a release. Use this line as the tool ID.
id = version
} else {
// This is a development version. The first line with
// a leading space is the compiler proper.
compiler := ""
for _, line := range lines {
if strings.HasPrefix(line, " ") && !strings.HasPrefix(line, " (in-process)") {
compiler = line
break
}
}
if compiler == "" {
return "", "", fmt.Errorf("%s: can not find compilation command in %q", name, out)
}View on GitHub (pinned to b6b368adc5)
Solutions
- Use a mainstream gcc or gccgo release whose -### output is well-formed.
- If using clang, ensure it's a complete install (not a stub).
- File a bug / use a Go version with broader compiler-output parsing, or set -gcflags to bypass tool ID detection where supported.
- Inspect the raw output quoted in the error to see what the compiler actually emits.
Example fix
// before $ CC='zig cc' go build ./... // error: zig: can not find version number in "..." // after — use a standard gcc $ CC=gcc go build ./...
Defensive patterns
Strategy: validation
Validate before calling
// Check that a compiler emits a parseable 'version <digit>' line.
func checkCompilerVersionLine(name string) error {
cmd := exec.Command(name, "-###", "-x", "c", "-c", "-")
cmd.Env = append(os.Environ(), "LC_ALL=C")
out, _ := cmd.CombinedOutput()
re := regexp.MustCompile(`(?m)version\s+[0-9]`)
if !re.Match(out) {
return fmt.Errorf("%s emits no parseable version line; use a standard gcc/gccgo", name)
}
return nil
} Prevention
- Use mainstream gcc/gccgo releases for cgo/gccgo builds.
- Avoid 'zig cc' or stripped wrapper compilers for Go's tool-ID detection.
- Test the compiler's -### output in CI before relying on it.
When it happens
Trigger: A C/gccgo compiler whose -### output doesn't include a 'version <digit...>' field — e.g. some clang builds, zig cc, tinycc, or a wrapper script that strips version info. Localized output is forced to C via LC_ALL=C, so localization isn't the cause.
Common situations: Using 'zig cc' or a musl-cross wrapper; a stripped/embedded clang; a custom gcc wrapper that filters -v output; an exotic vendor gcc.
Related errors
- %s: %v; output: %q
- %s: can not find compilation command in %q
- %s: compilation command confusion %q
- C compiler %q not found: %v
- Fortran source files not allowed when not using cgo or SWIG:
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/3a7b2e68a5d8af70.
Report an issue: GitHub.