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: improve error message for unparsable, too-new, go.mod #70979

Open
prattmic opened this issue Dec 24, 2024 · 3 comments
Open

cmd/go: improve error message for unparsable, too-new, go.mod #70979

prattmic opened this issue Dec 24, 2024 · 3 comments
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@prattmic
Copy link
Member

prattmic commented Dec 24, 2024

Split from #70949.

The tl;dr of that issue is:

  1. Set GOTOOLCHAIN=local to prevent automatic toolchain upgrade
  2. Use Go 1.23 toolchain
  3. go.mod says 1.24rc1 and contains a tool block

The 1.23 toolchain does not upgrade because of GOTOOLCHAIN=local, so it attempts to parse the go.mod itself. It does not understand tool blocks, so it reports a parse error:

go: errors parsing go.mod:
go.mod:206: unknown block type: tool

We could have a better error message in this case. Perhaps one of:

  1. Add a hint to the above error that GOTOOLCHAIN=local prevented an upgrade
  2. Or (my preference), stop immediately after determining the module Go version without fully parsing the go.mod, since we won't build such a module anyway.
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Dec 24, 2024
@prattmic
Copy link
Member Author

prattmic commented Dec 26, 2024

Upon further thought, if there is no tool block, GOTOOLCHAIN=local go build says "go: go.mod requires go >= 1.24rc1 (running go 1.23.4; GOTOOLCHAIN=local)". IMO the error should be identical with the addition of a tool block.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/639115 mentions this issue: cmd/go: check go version when parsing go.mod fails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants