-
Notifications
You must be signed in to change notification settings - Fork 18.1k
cmd/go: 'panic: mistake: chose version "v0.0.N" instead of target' when an argument to 'go get' requires a newer version of itself #31491
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
Comments
Thanks for reporting! Reproduced with 1.12.4 and tip. |
Thanks for the quick turnaround, @jayconrod! I tried setting the upstream version manually inside go.mod, but performing a build resets it back to v0.0.2. Curious to understand what’s special about this module, and if there’s a workaround I can try. Thanks! |
Sounds like we currently generate wrong pseudo version. For branch go/src/cmd/go/internal/mvs/mvs.go Line 147 in 2bdbc94
|
@raulk The issue is that your
If you try rebasing the branch, go get will works. @jayconrod should we returns the most recent tag of repo, instead of compare with current revision? |
@cuonglm Thanks for the diagnosis! Mystery solved. IMO go mod should not make assumptions about what commits/tags are present when using a branch reference. It's a valid use case to want to switch a required module to an entirely different branch that has diverged enough to not contain the latest repo semver tag. |
cc @bcmills How do you think about
|
We should certainly ensure that the pseudo-version of a commit on a branch sorts after any tag applied to any of the (transitive) parents of that commit. (That's #27171.) If two branches run parallel without periodically merging, then there is no well-defined ordering between them. We don't know whether the branch is, say, a release branch for ongoing maintenance of an older minor version, or a feature-development branch intended for release three more versions from now. So we stick to a simple rule: the pseudo-version is semantically after whatever comes before it, but only by a minimal degree. The problem here, I suspect, is that |
I tried to reproduce this again to figure out what the bug was, but it doesn't panic anymore. @raulk @cuonglm, what exactly did the To give some explanation of why the the pseudoversion
This would break the use case where different branches are used to maintain minor versions. For example, if you run
The version that appears in the go.mod file is a minimum version: you may get a later version if another module in the requirement graph requires a later version. In order for this to work, we need a total ordering on versions. Git commits are only partially ordered, which means we can't always produce correct semantic versions. It's up to you to tag these in a way that Go will understand. |
Here's the self-edge to the semantically-higher tag:
|
Got it to reproduce again: |
@jayconrod – glad you reproduced it. I've pushed the errored commit onto the debug-go-issue-31491 branch. This should allow you to continue reproducing even in the event of a future rebase. @bcmills, @jayconrod – Let me repeat the situation how I understood it. The repo contained a v0.0.2 tag which wasn't in the lineage of the branch. When issuing a ^^ is my narration correct? Maintain long-lived branches for feature development, hotfixing, testing, etc. is a legit situation in software development. It's improper for go to force rebasing those branches atop the freshest tag in the repo, as that defeats the purpose of branching in the first place. The way I see it, this is a scoping problem introduced by seeking linear, unambiguous total ordering atop of a VCS that's a DAG. |
Your summary of the situation is accurate. At this point,
If two modules require a common module at different versions, there must be a way to resolve the conflict to a single version. Without a total ordering, this cannot generally be done automatically. For development, testing, and hotfixing, |
Change https://golang.org/cl/177602 mentions this issue: |
Uh oh!
There was an error while loading. Please reload this page.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, using the latest release available at this time.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
With this go.mod file, I tried to upgrade
go-libp2p-peerstore
to the latest commit in theconsolidate-skeleton
branch:Note that this was part of a batch update, where all
go get
commands succeeded except for this one, which failed both inside the batch and in isolation:What did you expect to see?
go.mod successfully updated to reference the latest commit on the
consolidate-skeleton
branch ofgo-libp2p-peerstore
.What did you see instead?
The text was updated successfully, but these errors were encountered: