Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go, x/mod: "invalid go version" message mentions old version format #61888

Closed
dominikh opened this issue Aug 9, 2023 · 21 comments
Closed
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dominikh
Copy link
Member

dominikh commented Aug 9, 2023

When parsing an invalid go line in a go.mod, the error message says

go: errors parsing go.mod:
go.mod:3: invalid go version '1.22foo': must match format 1.23

but that's not strictly true, it doesn't have to match the 1.23 format anymore.

@seankhliao seankhliao added NeedsFix The path to resolution is known, but the work has not been done. GoCommand cmd/go labels Aug 9, 2023
@seankhliao
Copy link
Member

cc @bcmills

@jamietanna
Copy link

jamietanna commented Sep 8, 2023

What version of the go CLI was this with? I've hit this this morning when using gopls that's been compiled with a pre-1.21 go. The solution was to upgrade go.

@vincenthsh
Copy link

just came across this, to update vscode go tooling:

  1. Press Ctrl+Shift+P
  2. Select Go: Install/Update tools

or just to update golang language server:

go install golang.org/x/tools/gopls@latest

and you may Ctrl+Shift+P to restart language server

@gopherbot
Copy link

Change https://go.dev/cl/527897 mentions this issue: modfile: use new go version string format in error message

gopherbot pushed a commit to golang/mod that referenced this issue Sep 14, 2023
For golang/go#61888

Change-Id: If4056623471edb6fd99d45dcd8a0751d6a54ce1c
Reviewed-on: https://go-review.googlesource.com/c/mod/+/527897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
@amrojjeh
Copy link

I just got this error message recently after I updated go. I updated gopls as well and that did not fix it. For now I've manually edited the version number to be 1.21 rather than 1.21.1

@optik-aper
Copy link

optik-aper commented Sep 27, 2023

I am also noticing this occurring in newly go mod init'd projects on fresh pull of gopls@latest. Manually editing the go version in go.mod allows the language server to restart without error. I'm using vim-go which utilizes YouCompleteMe for the LSP communication to gopls.

go version                                                                                             
go version go1.21.0 linux/amd64

gopls version                                                                                         
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=

@Seefooo
Copy link

Seefooo commented Oct 13, 2023

I am also running into this. Similar setup to @optik-aper:

go version go1.21.1 linux/amd64
golang.org/x/tools/gopls v0.13.2
    golang.org/x/tools/gopls@v0.13.2 h1:Pyvx6MKvatbX3zzZmdGiFRfQZl0ohPlt2sFxO/5j6Ro=

@andydotxyz
Copy link
Contributor

Possibly related to #63370?
There seems to be confusion to what version numbers the tools should support. Part of the challenge of introducing a new format and requiring it in the same release I think?

@let4be
Copy link

let4be commented Oct 27, 2023

For me fixing version in go.mod and go.work to 1.21 didn't resolve the issue :(
What am I missing?

@let4be
Copy link

let4be commented Oct 27, 2023

Hrm... should do this for all other modules in a workspace as well
Okay, changing all stuff to 1.21 resolved the issue

Is there currenlt no way to specify the version exactly, like 1.21.3?

simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Works around golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Oct 31, 2023
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 1, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel added a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
simondeziel pushed a commit to simondeziel/lxd that referenced this issue Nov 2, 2023
This is to workaround golang/go#61888

Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
@bcmills
Copy link
Contributor

bcmills commented Jan 31, 2024

Looks like this was partially fixed in x/mod in https://go.dev/cl/527897, but we missed the ones in WorkFile.add:
https://cs.opensource.google/go/x/mod/+/master:modfile/rule.go;l=633-649;drc=6e58e47c7bd6672665dc35cce7b1f325d2addd67

🤦‍♂️

@gopherbot
Copy link

Change https://go.dev/cl/560855 mentions this issue: use new go version string format in WorkFile.add error

@gopherbot
Copy link

Change https://go.dev/cl/560855 mentions this issue: use new go version string format in WorkFile.add error message

@gopherbot
Copy link

Change https://go.dev/cl/560875 mentions this issue: use new go version string format in WorkFile.add error

gopherbot pushed a commit to golang/mod that referenced this issue Feb 7, 2024
For golang/go#61888

Tested: Ran go test ./modfile
Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b
Reviewed-on: https://go-review.googlesource.com/c/mod/+/560875
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Sam Thanawalla <samthanawalla@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopherbot pushed a commit that referenced this issue Feb 8, 2024
For #61888

Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560855
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
@bcmills
Copy link
Contributor

bcmills commented Feb 8, 2024

I think this is fixed as of https://go.dev/cl/560855.

@bcmills bcmills closed this as completed Feb 8, 2024
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
For golang#61888

Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560855
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
@maxmeng-hw
Copy link

@bcmills can we backport this CL to 1.21 and 1.22?

https://github.com/hashicorp/terraform using go1.21.5

@bcmills
Copy link
Contributor

bcmills commented Feb 22, 2024

@maxmeng-hw, the only change for this issue was to an error message. That does not seem worth backporting, especially given that the changes are in the vendored x/mod packages (which makes them more complicated to backport).

Flapperoo pushed a commit to Flapperoo/BeatmapPacker that referenced this issue Mar 4, 2024
piercefreeman added a commit to piercefreeman/mountaineer that referenced this issue Mar 14, 2024
piercefreeman added a commit to piercefreeman/mountaineer that referenced this issue Mar 14, 2024
piercefreeman added a commit to piercefreeman/mountaineer that referenced this issue Mar 14, 2024
piercefreeman added a commit to piercefreeman/mountaineer that referenced this issue Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

16 participants