TafT
TafT

Reputation: 3085

How do I resolve the warning "compile: version "go1.21.10" does not match go tool version "go1.22.5" shown when I try to debug Go tests in VS Code

When I click the "debug benchmark" or "debug test" options that Microsoft Visual Studio Code adds above my func Test_ and func Benchmark_ line, I get taken to the debug consle which is displaying messages like the following:

Build Error: go test -c -o /home/.../dirwithtestin/__debug_bin1879621140 -gcflags all=-N -l -race .
# internal/godebugs
compile: version "go1.21.10" does not match go tool version "go1.22.5"
# internal/unsafeheader
compile: version "go1.21.10" does not match go tool version "go1.22.5"

How do I resolve the "compile: version "go1.21.10" does not match go tool version "go1.22.5" warnings?


My regular runs of the tests and generation of the main application work fine. I attempted to set "dlvFlags": ["--check-go-version=false"] as suggested under Go dlv: Failed to launch Version of go is too old for this verion of delve. VSCode Golang dlv debug error for version mismatch looks similar but I could not figure out what "Had a stale go bin reference in VSCode User settings." meant.

Upvotes: -2

Views: 1266

Answers (1)

TafT
TafT

Reputation: 3085

I found my specific problem while working through the answers on this question and it was that I had incorrectly set gobrew to use the version of Go I wanted, but my system was falling back to a version of go that would download missing versions based on the go.mod contents. To fix my problem I had to run gobrew use 1.22.5.


I had run gobrew use go1.22.5 which presently looks like it works with just green info messages. You would think this would give me 'go tool version "go1.22.5"' as in the error output of the question but it does not.

$ gobrew install go1.22.5
==> [Info] Downloading version: go1.22.5
==> [Info] Downloading from: https://go.dev/dl/gogo1.22.5.linux-amd64.tar.gz
==> [Info] Downloading to: /home/thomasth/.gobrew/downloads
==> [Info] Extracting from: /home/thomasth/.gobrew/downloads/gogo1.22.5.linux-amd64.tar.gz
==> [Info] Extracting to: /home/thomasth/.gobrew/versions/go1.22.5
==> [Info] Extract failed: open /home/thomasth/.gobrew/downloads/gogo1.22.5.linux-amd64.tar.gz: no such file or directory

Note there are no Error or Failure messages when using gobrew 1.10.8. I have raised an issue with that tool as I think the Extract fail message should be an error message so it is not in a wall of green [Info] text.

The correct command is gobrew use 1.22.5.

The problem was being partially masked as I had been using go1.21.10 before this which was reading my go.mod files go 1.22.5 and then installing the correct version of go itself. So when I eventually found a problem everything was responding to go version with go version go1.22.5 linux/amd64 as I would expect. The clue was that which go returned a path in my GOPATH mod directory, not under .gobew/current/bi/go.

Upvotes: 0

Related Questions