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: modules with empty go.mod files not diagnosed well #25272

Open
IngCr3at1on opened this Issue May 6, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@IngCr3at1on

IngCr3at1on commented May 6, 2018

I can't actually decide if this is a bug or just me doing something wrong....

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

go version go1.10.1 linux/amd64
go version go1.10.1 linux/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)?

GOARCH="amd64"
GOBIN="/home/ing/ply/go/bin"
GOCACHE="/home/ing/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ing/ply/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build144176356=/tmp/go-build -gno-record-gcc-switches"

What did you do?

in a working directly create a main:

package main // import "github.com/IngCr3at1on/bugexample"

import (
	"github.com/JustAnotherOrganization/l5424"
	"github.com/JustAnotherOrganization/l5424/x5424"
)

func main() {
	log := x5424.New().NewEntry(l5424.FacilityKernel)
	log.Alertln("Foo")
	log.Noticeln("Bar")
}

and a go.mod
touch go.mod

Or simply pull down github.com/IngCr3at1on/bugexample

What did you expect to see?

The program should compile

What did you see instead?

vgo: resolving import "github.com/JustAnotherOrganization/l5424"
vgo: finding github.com/JustAnotherOrganization/l5424 (latest)
vgo: adding github.com/JustAnotherOrganization/l5424 v0.1.0
vgo: import "github.com/JustAnotherOrganization/l5424/x5424" [/home/ing/ply/go/src/v/github.com/JustAnotherOrganization/l5424@v0.1.0/x5424]: open /home/ing/ply/go/src/v/github.com/JustAnotherOrganization/l5424@v0.1.0/x5424: no such file or directory

Initially only the tag v0.1.0 existed; someone in the #vgo channel on Gopher's Slack suggested I add the tag x5424/v0.1.0 but that doesn't seem to make a difference.


It's worth adding that the issue reminds me of #24605 but I'm not sure if they're the same...

@gopherbot gopherbot added this to the vgo milestone May 6, 2018

@davecgh

This comment has been minimized.

davecgh commented May 26, 2018

We are seeing something that seems very likely to be related since it is a nested package in dcrd. However, rather than not being able to find the module, instead the dependency solver believes the nested module is provided by the parent module despite the parent module not including it as evidenced by looking in $GOPATH/src/v to verify.

This can currently be reproduced as of dcrd commit be318f5a by navigate to the connmgr package, clearing the contents of the go.mod file, and running vgo build.

The following are the results:

$ git clone https://github.com/decred/dcrd $GOPATH/src/github.com/decred/dcrd
...
Resolving deltas: 100% (15995/15995), done.

$ cd $GOPATH/src/github.com/decred/dcrd/connmgr
$ git checkout be318f5a
Note: checking out 'be318f5a'.
...

$ rm go.mod*; touch go.mod

$ vgo version
go version go1.10.2 windows/amd64 vgo:2018-02-20.1

$ vgo build
vgo: resolving import "github.com/decred/dcrd/chaincfg"
vgo: finding github.com/decred/dcrd/chaincfg (latest)
vgo: adding github.com/decred/dcrd/chaincfg v1.0.0
vgo: resolving import "github.com/decred/dcrd/wire"
vgo: finding github.com/decred/dcrd/wire (latest)
vgo: adding github.com/decred/dcrd/wire v1.0.0
vgo: resolving import "github.com/decred/slog"
vgo: finding github.com/decred/slog (latest)
vgo: adding github.com/decred/slog v1.0.0
vgo: import "github.com/decred/dcrd/connmgr" ->
        import "github.com/decred/dcrd/chaincfg" ->
        import "github.com/decred/dcrd/chaincfg/chainhash": found in both github.com/decred/dcrd/chaincfg v1.0.0 and github.com/decred/dcrd/chaincfg/chainhash v1.0.0
vgo: downloading github.com/decred/dcrd/wire v1.0.0
vgo: downloading github.com/decred/slog v1.0.0

We can verify the chainhash module is not part of the chaincfg v1.0.0 module by looking in GOPATH:

$ ls -al "$GOPATH/src/v/github.com/decred/dcrd/chaincfg@v1.0.0"
total 315K
drwxr-xr-x 1 davec None    0 May 25 18:52 ./
drwxr-xr-x 1 davec None    0 May 25 18:52 ../
drwxr-xr-x 1 davec None    0 May 25 18:52 chainec/
-rw-r--r-- 1 davec None 2.5K May 25 18:52 doc.go
-rw-r--r-- 1 davec None 8.8K May 25 18:52 genesis.go
...

For some extra data, here are the relevant tags:

$ git l
* be318f5a (HEAD, tag: chaincfg/v1.0.0, origin/master, origin/HEAD, master) chaincfg: Refine vgo deps.
* d5016f28 (tag: addrmgr/v1.0.0) addrmrg: Refine vgo deps.
* 4ee21d80 (tag: wire/v1.0.0) wire: Refine vgo deps.
* 07433d4c (tag: chaincfg/chainhash/v1.0.0) chainhash: Define vgo module.
@rsc

This comment has been minimized.

Contributor

rsc commented Jul 10, 2018

@Dcrd I think your problem is more like #26250. Fix CL going out today.

@IngCr3at1on, the first problem is that the go.mod files checked into the repo are empty. They need to have a module line, like

module github.com/JustAnotherOrganization/I5424

and

module github.com/JustAnotherOrganization/I5424/x5424

I will make this issue track having a good diagnosis of this condition.

Once those go.mod files are updated (and new tags added), then I think you'll be up against #26250. Watch for that issue to be closed.

@rsc rsc changed the title from x/vgo: nested packages are unresolve-able when using version tags. to x/vgo: modules with empty go.mod files not diagnosed well Jul 10, 2018

@rsc rsc modified the milestones: vgo, Go1.11 Jul 12, 2018

@rsc rsc added the modules label Jul 12, 2018

@rsc rsc changed the title from x/vgo: modules with empty go.mod files not diagnosed well to cmd/go: modules with empty go.mod files not diagnosed well Jul 12, 2018

@IngCr3at1on

This comment has been minimized.

IngCr3at1on commented Jul 20, 2018

comment deleted (possibly separate issue, seems resolved).

@rsc rsc modified the milestones: Go1.11, Go1.12 Aug 17, 2018

@bcmills bcmills modified the milestones: Go1.12, Go1.13 Nov 15, 2018

@bcmills bcmills added the NeedsFix label Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment