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

compile: invalid value "go1.21.7" for -lang: should be something like "go1.12" #20723

Closed
jasonwbarnett opened this issue Mar 25, 2024 · 7 comments · Fixed by #21523
Closed

compile: invalid value "go1.21.7" for -lang: should be something like "go1.12" #20723

jasonwbarnett opened this issue Mar 25, 2024 · 7 comments · Fixed by #21523
Assignees
Labels
backend: Go Go backend-related issues bug

Comments

@jasonwbarnett
Copy link
Contributor

Describe the bug
When I had the following go.mod

module domain.com/package/path

go 1.21.7

require github.com/pelletier/go-toml v1.9.5

compiling the program via pants failed with this error:

compile: invalid value "go1.21.7" for -lang: should be something like "go1.12"

After updating the go.mod to this it worked:

module domain.com/package/path

go 1.21

require github.com/pelletier/go-toml v1.9.5

Pants version
2.21.0.dev3

OS
Mac OS

@tgolsson
Copy link
Contributor

Looked like #20677 but I think this is different. Likely fall-out from that.

@tgolsson tgolsson self-assigned this Mar 25, 2024
@tgolsson tgolsson added the backend: Go Go backend-related issues label Mar 25, 2024
@tdyas
Copy link
Contributor

tdyas commented Mar 25, 2024

We probably need to make sure we only pass go1.X as a value to the -lang parameter.

@tdyas
Copy link
Contributor

tdyas commented Mar 25, 2024

The relevant part of the code is

# See https://github.com/golang/go/blob/f229e7031a6efb2f23241b5da000c3b3203081d6/src/cmd/go/internal/work/gc.go#L79-L100
# for where this logic comes from.
go_version = request.minimum_go_version or "1.16"
if go_root.is_compatible_version(go_version):
compile_args.extend(["-lang", f"go{go_version}"])
.

@jasonwbarnett
Copy link
Contributor Author

The relevant part of the code is

# See https://github.com/golang/go/blob/f229e7031a6efb2f23241b5da000c3b3203081d6/src/cmd/go/internal/work/gc.go#L79-L100
# for where this logic comes from.
go_version = request.minimum_go_version or "1.16"
if go_root.is_compatible_version(go_version):
compile_args.extend(["-lang", f"go{go_version}"])
.

Thanks. I'll try to post a fix in the next few days.

@bndabbs
Copy link

bndabbs commented Jun 12, 2024

This looks like the error reported in golang/go#66553.

Is it possible that Pants is caching golang.org/x/tools/gopls somewhere? If so then maybe the fix should be to install gopls using the resolved go_version?

@tdyas
Copy link
Contributor

tdyas commented Sep 26, 2024

This looks like the error reported in golang/go#66553.

Is it possible that Pants is caching golang.org/x/tools/gopls somewhere? If so then maybe the fix should be to install gopls using the resolved go_version?

Pants does not use gopls at all. The linked source files are the likely culprit since they generate the actual -lang parameter passed to the Go toolchain.

@11xor6
Copy link

11xor6 commented Nov 5, 2024

Does anyone have another work around in the meantime while we wait for the patch? Modifying my go.mod file doesn't fix this for me on both pants versions 2.21.0 and 2.22.0. Locally I'm running Go 1.23.2 and my go.mod file has go 1.22 (previously go 1.22.0) and I've tried [golang].minimum_expected_version of 1.22, 1.22.0, 1.23, and 1.23.0.

tdyas pushed a commit that referenced this issue Nov 6, 2024
Should hopefully fix #20723

---------

Co-authored-by: Huon Wilson <[email protected]>
tdyas added a commit that referenced this issue Nov 6, 2024
… (#21618)

Should hopefully fix #20723

---------

Co-authored-by: Sven Widén <[email protected]>
Co-authored-by: Huon Wilson <[email protected]>
Co-authored-by: Tom Dyas <[email protected]>
tdyas added a commit that referenced this issue Nov 6, 2024
… (#21617)

Should hopefully fix #20723

---------

Co-authored-by: Sven Widén <[email protected]>
Co-authored-by: Huon Wilson <[email protected]>
Co-authored-by: Tom Dyas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: Go Go backend-related issues bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants