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

x/vgo: ignores the specified version and changes it to a random version #25375

Closed
OneOfOne opened this issue May 14, 2018 · 6 comments
Closed
Milestone

Comments

@OneOfOne
Copy link
Contributor

OneOfOne commented May 14, 2018

What version of Go are you using (go version)?

┏━ oneofone@Ava ❨☯/g/x/vgo❩ ❨master❩
┗━━➤ vgo version && git describe --always
go version devel +903f095c1a 2018-05-10 20:54:21 +0000 linux/amd64 vgo:2018-02-20.1
9271c4f

Bug repo: https://github.com/OneOfOne/vgo-bug

Steps to reproduce

Starting with just module github.com/OneOfOne/vgo-bug in go.mod:

  1. go get github.com/OneOfOne/vgo-bug (go not vgo).

  2. cd $GOROOT/src/go get github.com/OneOfOne/vgo-bug.

➤ vgo build
vgo: resolving import "github.com/alecthomas/kingpin"
vgo: finding github.com/alecthomas/kingpin (latest)
vgo: adding github.com/alecthomas/kingpin v1.3.7
vgo: resolving import "github.com/alecthomas/units"
vgo: finding github.com/alecthomas/units (latest)
vgo: adding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf

➤ cat go.mod
module github.com/OneOfOne/vgo-bug

require (
        github.com/alecthomas/kingpin v1.3.7 <<<
        github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
)
  1. edit go.mod and change v1.3.7 to v2.2.6 (latest on github).

➤ vgo build
vgo: resolving import "github.com/alecthomas/template"
vgo: finding github.com/alecthomas/template (latest)
vgo: adding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc

➤ cat go.mod
module github.com/OneOfOne/vgo-bug

require (
        github.com/alecthomas/kingpin v0.0.0-20171217180838-947dcec5ba9c
        github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
        github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
)

➤ vgo list -m
MODULE                          VERSION
github.com/OneOfOne/vgo-bug     -
github.com/alecthomas/kingpin   v0.0.0-20171217180838-947dcec5ba9c
github.com/alecthomas/template  v0.0.0-20160405071501-a0175ee3bccc
github.com/alecthomas/units     v0.0.0-20151022065526-2efee857e7cf

This isn't the same as #24585, however it might be a dup of #25007 based on the last comment in it.

@gopherbot gopherbot added this to the vgo milestone May 14, 2018
@bcmills
Copy link
Contributor

bcmills commented May 14, 2018

Here's what I think is going on:

If you change the major version in go.mod, you also need to change the major version in the import path (in the .go source files). Only v0 and v1 can have unversioned import paths (see https://research.swtch.com/vgo-import), which is why vgo accepts v1.3.7 initially.

When you change the version to v2.2.6, vgo checks for a corresponding tag or branch in the repo. It successfully finds a tag in the repository, but without a semantic import path it isn't willing to consider that to be an actual major version: it can't coexist with some other major version at the same import path. So instead, vgo resolves the tag to a commit (947dcec5ba9c) and records that commit itself as a “pseudo-version” (see https://research.swtch.com/vgo-module).

When version selection occurs, the pseudo-version commit will be used to resolve the v0 import path (that is, the import path without a major-version component), not the v2-suffixed import path (which will be resolved separately).

@OneOfOne
Copy link
Contributor Author

That makes sense, but IMHO this needs to be fixed in vgo, a lot of repos are already using v2+ tags, not adding a way to support them and assuming they will add vgo support on their own is really gonna be painful to deal with.

@bcmills
Copy link
Contributor

bcmills commented May 15, 2018

The pseudo-version in the updated go.mod file is the version tagged v2.2.6 in the repository: you got the commit you asked for, just by a different name. Is that causing an actual problem for you otherwise, or just confusing to see in the go.mod file?

@OneOfOne
Copy link
Contributor Author

It's rather confusing that vgo modifies the file on read-only operation (vgo list, vgo build, etc).

@OneOfOne
Copy link
Contributor Author

@bcmills #25412 explains it better than me, while it is a dup of this, his explanation is much better than mine so feel free to mark this as a dup of it.

@bcmills
Copy link
Contributor

bcmills commented May 16, 2018

Ok, will follow up on #25412.

@bcmills bcmills closed this as completed May 16, 2018
@golang golang locked and limited conversation to collaborators May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants