-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: missing version diagnostic when a package in the main module imports a package from a newer release #48966
Comments
What kind of errors are your users reporting? When the build fails, they should be getting an explicit notice about the version mismatch already. |
(Also compare #46136.) |
From evcc-io/evcc#1303:
For an end user that tries to self-compile its impossible to relate this error in a mismatching go version. |
That report is from
That version of Go is way out of date: per the Go project's release policy, the current supported versions of the toolchain are 1.16.9 and 1.17.2. Any change we would make at this point would only affect 1.18 and later, and I posit that the supported versions of the toolchain already produce a much more useful diagnostic in this case. |
Hmm... It is the case that
It looks like the failure in module resolution is before the failure due to the Go version. And if we construct a similar situation with some new 1.18 package using Go 1.17.2, we still get a bad error message:
So there is a bug to be fixed here — but it's just a bug, it doesn't need to go through the proposal process. |
Note https://github.com/theckman/goconstraint/ for a go-only compile time solution. |
I'd like to look into this issue - @bcmills do you have some pointers on how to fix it? |
@zacho314, the error message that we see is from an Generally when we see an I suspect that the point where we're reporting the error today is here: What we need to propagate this error correctly is something like:
We already have a “for each package |
I plan on looking into this if @mzacho isn't actively working on it. |
Change https://go.dev/cl/432075 mentions this issue: |
…ewer releases An older version of go compiling a main module that references a standard library package from a newer release (e.g. net/netip added in go 1.18) currently produces a confusing error message. This changes adds a new error message including go version diagnostics. Fixes golang#48966 Change-Id: I1e8319dafcf1f67d1b1ca869fe84190c3b3f3c3e Reviewed-on: https://go-review.googlesource.com/c/go/+/432075 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Given
and using
embed
as part of that module, I'm experiencing a lot of user's questions where compilation fails due to go versions below 1.16. Having declared dependency on go1.16 syntax/libraries as part ofgo.mod
it would be nice if the compiler would fail if the module version of the main module or it's dependencies are not met during build. It could be optional behaviour behind a flag.I realise this might cause breakage for modules who's authors use the highes available go version as part of their
go.mod
to be "compatible", but that approach seems flawed anyway.The text was updated successfully, but these errors were encountered: