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

Comments

@nicksnyder
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Apr 13, 2018

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/hola@v1.0.0/v2/hola]: open /Users/nick/dev/gopath/src/v/github.com/nicksnyder/hola@v1.0.0/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

This comment has been minimized.

Copy link
Author

commented Apr 13, 2018

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

This comment has been minimized.

Copy link
Member

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/vgohello@v1.2.0/v2/hello]: open /tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/vgohello@v1.2.0/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/hello@v1.2.0/v2]: open /tmp/tmp.OGVGwT81BY/src/v/github.com/myitcv/vgopkg/hello@v1.2.0/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

This comment has been minimized.

Copy link
Author

commented Apr 13, 2018

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/hola@v1.0.0/v2/hola]: open /Users/nick/dev/gopath/src/v/github.com/nicksnyder/hola@v1.0.0/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.

@nicksnyder nicksnyder closed this Apr 13, 2018

@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
4 participants
You can’t perform that action at this time.