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: can't find git tag for non-root module #24840

Closed
nicksnyder opened this issue Apr 13, 2018 · 6 comments
Closed

x/vgo: can't find git tag for non-root module #24840

nicksnyder opened this issue Apr 13, 2018 · 6 comments
Milestone

Comments

@nicksnyder
Copy link

nicksnyder commented Apr 13, 2018

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

$ vgo version
go version go1.10.1 darwin/amd64 vgo:2018-02-20.1

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

$ vgo env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/nick/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/nick/dev/gopath"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/l6/djg_zw1j5lgbwz4h5q92lnwr0000gn/T/go-build082459775=/tmp/go-build -gno-record-gcc-switches -fno-common"
VGOMODROOT=""

What did you do?

git clone https://github.com/nicksnyder/app
cd app/hello
vgo build

What did you expect to see?

I expected go.mod to look like this:

module "github.com/nicksnyder/app"

require (
        "github.com/nicksnyder/hello/hello" v1.2.0
        "github.com/nicksnyder/hello/v2" v2.0.0
)

What did you see instead?

module "github.com/nicksnyder/app"

require (
        "github.com/nicksnyder/hello/hello" v0.0.0-20180413114503-788687e5d6fa
        "github.com/nicksnyder/hello/v2" v2.0.0
)

Logs

$ vgo build
vgo: resolving import "github.com/nicksnyder/hello/hello"
vgo: finding github.com/nicksnyder/hello/hello (latest)
vgo: adding github.com/nicksnyder/hello/hello v0.0.0-20180413114503-788687e5d6fa
vgo: resolving import "github.com/nicksnyder/hello/v2/hello"
vgo: finding github.com/nicksnyder/hello/v2 (latest)
vgo: adding github.com/nicksnyder/hello/v2 v2.0.0

Attempted workarounds

If I manually edit the go.mod file to point to v1.2.0 and run vgo build, I see this:

$ vgo build
vgo: finding github.com/nicksnyder/hello/hello v1.2.0
vgo: github.com/nicksnyder/hello/hello v1.2.0: unexpected status (https://api.github.com/repos/nicksnyder/hello/git/refs/tags/hello/v1.2.0): 404 Not Found
vgo: finding github.com/nicksnyder/hello/hello v1.2.0
vgo: github.com/nicksnyder/hello/hello v1.2.0: unexpected status (https://api.github.com/repos/nicksnyder/hello/git/refs/tags/hello/v1.2.0): 404 Not Found
vgo: unexpected status (https://api.github.com/repos/nicksnyder/hello/git/refs/tags/hello/v1.2.0): 404 Not Found

Should be
https://api.github.com/repos/nicksnyder/hello/git/refs/tags/v1.2.0
not
https://api.github.com/repos/nicksnyder/hello/git/refs/tags/hello/v1.2.0

I also tried to add a go.mod to the root of github.com/nicksnyder/hello with just module = "github.com/nicksnyder/hello" and that didn't help.

More generally, what is the intended set of go.mod files for a project with a directory structure like this?

hello/ # v1
v2/hello/ # v2
@myitcv
Copy link
Member

myitcv commented Apr 13, 2018

You have a go.mod file in https://github.com/nicksnyder/hello/tree/master/hello but the v2 directory in https://github.com/nicksnyder/hello

Did you intend for that?

Untested, but I think you need the v2 directory in the same directory as the go.mod

@myitcv
Copy link
Member

myitcv commented Apr 13, 2018

(sorry that sent early)

You also need to have a go.mod in the root of the repo as far as I'm aware; the module in this case would be "github.com/nicksnyder/hello"

@andybons andybons added this to the vgo milestone Apr 13, 2018
@andybons andybons changed the title vgo: can't find git tag for non-root module x/vgo: can't find git tag for non-root module Apr 13, 2018
@nicksnyder
Copy link
Author

You also need to have a go.mod in the root of the repo as far as I'm aware; the module in this case would be "github.com/nicksnyder/hello"

I tried that and it didn't change anything.

From original issue:

I also tried to add a go.mod to the root of github.com/nicksnyder/hello with just module = "github.com/nicksnyder/hello" and that didn't help.

I also tried adding the root go.mod and removing the one in github.com/nicksnyder/hello but then I get a different error:

vgo: resolving import "github.com/nicksnyder/hola/hola"
vgo: finding github.com/nicksnyder/hola (latest)
vgo: adding github.com/nicksnyder/hola v1.0.0
vgo: import "github.com/nicksnyder/hola/v2/hola" [/Users/nick/dev/gopath/src/v/github.com/nicksnyder/[email protected]/v2/hola]: open /Users/nick/dev/gopath/src/v/github.com/nicksnyder/[email protected]/v2/hola: no such file or directory

I pushed a new lib github.com/nicksnyder/hola which demonstrates this other issue. It has a structure like this:

go.mod  # module "github.com/nicksnyder/hola"
hola/hola.go
v2/hola/hola.go
v2/go.mod # module "github.com/nicksnyder/hola/v2"

I pushed a commit to github.com/nicksnyder/app to create two test cases, one against hello and the other against hola. Neither work.

Can you tell me what is supposed to work?

@nicksnyder
Copy link
Author

My high level desire is to have a library with the following properties:

  • v1 is at the root
  • v2 is in a subfolder (because that is the only way that I know to be compatible with regular go command)
  • go.mod files such that vgo works

@myitcv
Copy link
Member

myitcv commented Apr 13, 2018

From original issue:

Apologies, I didn't read the original issue carefully enough.

Now I actually think this is a duplicate of #24687 (comment)

This horrendous script tries to recreate the scenario you described above. To recreate yourself:

  • tweak the root= setting
  • create three new repos (the names aren't very sensible):
    • vgomain
    • vgopkg - where hello is a submodule of the repo root module
    • vgohello - where hello is a package within the repo root module

See my versions of those three repos:

The end result is much the same:

cd `mktemp -d`
export GOPATH=$PWD
git clone https://github.com/myitcv/vgomain
cd vgomain
vgo test

gives

vgo: resolving import "github.com/myitcv/vgohello/hello"
vgo: finding github.com/myitcv/vgohello (latest)
vgo: adding github.com/myitcv/vgohello v1.2.0
vgo: resolving import "github.com/myitcv/vgopkg/hello"
vgo: finding github.com/myitcv/vgopkg/hello (latest)
vgo: adding github.com/myitcv/vgopkg/hello v1.2.0
vgo: finding github.com/myitcv/vgopkg/hello v1.2.0
vgo: finding github.com/myitcv/vgohello v1.2.0
vgo: downloading github.com/myitcv/vgohello v1.2.0
vgo: import "github.com/myitcv/vgomain" ->
        import "github.com/myitcv/vgohello/v2/hello" [/tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/[email protected]/v2/hello]: open /tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/[email protected]/v2/hello: no such file or directory
vgo: downloading github.com/myitcv/vgopkg/hello v1.2.0
vgo: import "github.com/myitcv/vgomain" ->
        import "github.com/myitcv/vgopkg/hello/v2" [/tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/vgopkg/[email protected]/v2]: open /tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/vgopkg/[email protected]/v2: no such file or directory

As you can see things are failing for github.com/myitcv/vgopkg/hello which is the scenario where github.com/myitcv/vgopkg/hello is itself a module within github.com/myitcv/vgopkg

And that's what's also going on in #24687 (comment)

@nicksnyder
Copy link
Author

After re-reading https://research.swtch.com/vgo-module I am basically just trying to setup the second scenario depicted here. This is how github.com/nicksnyder/hola is setup.

I updated github.com/nicksnyder/app because it has some unintended issues in it, and now I can reproduce the error that seems to be similar to the one you reported in the other issue:

$ vgo  build
vgo: resolving import "github.com/nicksnyder/hola/hola"
vgo: finding github.com/nicksnyder/hola (latest)
vgo: adding github.com/nicksnyder/hola v1.0.0
vgo: import "github.com/nicksnyder/app" ->
	import "github.com/nicksnyder/hola/v2/hola" [/Users/nick/dev/gopath/src/v/github.com/nicksnyder/[email protected]/v2/hola]: open /Users/nick/dev/gopath/src/v/github.com/nicksnyder/[email protected]/v2/hola: no such file or directory

If I then pin the module to 2.0.0 (e.g. require "github.com/nicksnyder/hola/v2" v2.0.0) then I get a different error:

$ vgo  build
vgo: resolving import "github.com/nicksnyder/hola/hola"
vgo: finding github.com/nicksnyder/hola (latest)
vgo: adding github.com/nicksnyder/hola v1.0.0
vgo: import "github.com/nicksnyder/app" ->
	import "github.com/nicksnyder/hola/v2/hola": found in both github.com/nicksnyder/hola v1.0.0 and github.com/nicksnyder/hola/v2 v2.0.0

I think we can close this issue since the original reproduction was for a setup that was not documented to work. Instead, I am going to open a new issue with fresh reproduction steps for a setup that is supposed to work. Completely fine if you want to immediately mark it as a duplicate, but it isn't obvious to me that it is.

@golang golang locked and limited conversation to collaborators Apr 13, 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

4 participants