-
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: improve error message for mismatched major versions #41512
Comments
Imho v3 denotes a v3 major module version. Seems your module in question is v1 (although it has a 3.xyz version number), so omit the /v3 suffix when requiring it. While this sounds confusing it is imho due to keeping backwards compatibility with modules what introduced versioning before go.mod came around in go 1.11. |
Imho you need to change the module path to the github-hosted one which declares itself as v3. |
As noted in #35732 (comment):
That said, I've been thinking about this particular error message some more. I think the error message we've written today assumes that the module path is correct and the version is wrong (because it doesn't match the module path), when really most users who encounter this error really have written the version they intend: we should suggest a fix to the path, not to the version. |
@glycerine, in this case, the problem is that the latest v3-tagged release of The |
@bcmills This has tripped me off several times already, so if we could make this more clear I would be delighted to create a CL with a clearer message. |
@bcmills I can appreciate that this situation puts the tooling into a dark room with little content to draw from to understand what's going on or how to inform the user. Go error messages are typically terse, but perhaps verbosity is called for here. Consider whether it would actually be easier to describe the error state if there wasn't an implicit assumption that error messages need be short. For example, include several examples, include a link to that paper you've previously linked to regarding module versions, include corrections for real-world variations of this problem, etc. A good technical writer might be helpful here. |
That would be @stevetraut. 🙂 |
Maybe something like this?
|
@icholy This advice is better but would not address the situation that happened to me (see "Getting the Major Version Fails" at comment #35732 (comment)). |
I checked http://github.com/golang-migrate/migrate and it doesn't have a branch or tag called |
Change https://golang.org/cl/378400 mentions this issue: |
Since at least CL 121857, the conversion logic in (*modfetch).codeRepo.Stat has had a short-circuit to use the version requested by the caller if it successfully resolves and is already canonical. However, we should not use that version if it refers to a branch instead of a tag, because branches (unlike tags) usually do not refer to a single, stable release: a branch named "v1.0.0" may be for the development of the v1.0.0 release, or for the development of patches based on v1.0.0, but only one commit (perhaps at the end of that branch — but possibly not even written yet!) can be that specific version. We already have some logic to prefer tags that are semver-equivalent to the version requested by the caller. That more general case suffices for exact equality too — so we can eliminate the special-case, fixing the bug and (happily!) also somewhat simplifying the code. Fixes #35671 Updates #41512 Change-Id: I2fd290190b8a99a580deec7e26d15659b58a50b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/378400 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
related to
#35732
which remains the top google hit for this error
what does one do to get this simple example to work?
if I change go.mod to
I get the equally mystifying
The text was updated successfully, but these errors were encountered: