Skip to content

cmd/go: toolchain escape via PATH in covermode when GOTOOLCHAIN auto-switches #77820

Description

@zccold

Go version

go1.25.x linux/amd64 (but 1.26.0 in go.mod)

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/cold/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/cold/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build264210646=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/cold/projects/hello/go.mod'
GOMODCACHE='/home/cold/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/cold/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/cold/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.0.linux-amd64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/cold/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/cold/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.26.0.linux-amd64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.0'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

  1. Have a host system with an older Go version installed (e.g., go1.25.5).
  2. Have a project where go.mod specifies a newer version like go 1.26.0 (which triggers the GOTOOLCHAIN auto-switch mechanism).
  3. Run a test command that invokes the covdata tool, for example:
    go test -covermode=count -coverpkg=./... ./...

What did you see happen?

The build fails with a toolchain version mismatch error, looking something like this:
compile: version "go1.26.0" does not match go tool version "go1.25.5 (xxx)"

What did you expect to see?

The tests should run successfully, using the automatically downloaded 1.26.0 toolchain to handle the coverage data.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

Type

No type

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions