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: build fails on non-main github.com/stretchr/testify #25604

Closed
leighmcculloch opened this issue May 28, 2018 · 6 comments
Closed

x/vgo: build fails on non-main github.com/stretchr/testify #25604

leighmcculloch opened this issue May 28, 2018 · 6 comments
Milestone

Comments

@leighmcculloch
Copy link
Contributor

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

go version go1.10 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)?

$ vgo env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/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-build030057171=/tmp/go-build -gno-record-gcc-switches"
VGOMODROOT=""

What did you do?

go get github.com/stretchr/testify
cd $GOPATH/src/github.com/stretchr/testify
git checkout c679ae2cc0cb27ec3293fea7e254e47386f05d69
vgo build

Note: The commit checked out above is the master branch when the issue was encountered. I've specified the commit in my example for reproducibility.

What did you expect to see?

The build to complete with a go.mod file written to the local directory.

What did you see instead?

The build failed with error panic: unbuildable.

$ vgo build                                                                                 
vgo: finding github.com/stretchr/objx v0.0.0-20180106011353-facf9a85c22f               
vgo: finding github.com/stretchr/testify v1.2.0                                              
vgo: finding github.com/stretchr/objx v0.0.0-20140526180921-cbeaeb16a013                                                                     
vgo: finding github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0  
vgo: finding github.com/pmezard/go-difflib v1.0.0                                          
vgo: finding github.com/davecgh/go-spew v1.1.0                                                                                               
panic: unbuildable
                                                                                         
goroutine 1 [running]:                                           
golang.org/x/vgo/vendor/cmd/go/internal/mvs.buildList(0xc420024011, 0x1b, 0x0, 0x0, 0x981ec0, 0xc42000d880, 0x0, 0x0, 0xc42000d880, 0xc4201d3660, ...)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/mvs/mvs.go:63 +0x103a                 
golang.org/x/vgo/vendor/cmd/go/internal/mvs.BuildList(0xc420024011, 0x1b, 0x0, 0x0, 0x981ec0, 0xc42000d880, 0x86d220, 0xc420028d00, 0x7fb9d8efb000, 0x1, ...)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/mvs/mvs.go:33 +0x78              
golang.org/x/vgo/vendor/cmd/go/internal/vgo.iterate(0xc4201d3770)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/vgo/load.go:124 +0xae
golang.org/x/vgo/vendor/cmd/go/internal/vgo.importPaths(0xc42009c010, 0x0, 0x0, 0x76faa7, 0xc420028840, 0x1)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/vgo/load.go:83 +0xe4
golang.org/x/vgo/vendor/cmd/go/internal/vgo.ImportPaths(0xc42009c010, 0x0, 0x0, 0xc420028840, 0x1, 0x1)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/vgo/load.go:71 +0x5a
golang.org/x/vgo/vendor/cmd/go/internal/load.ImportPaths(0xc42009c010, 0x0, 0x0, 0x411a59, 0xc420020260, 0x16)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/load/pkg.go:1485 +0x4f
golang.org/x/vgo/vendor/cmd/go/internal/load.PackagesAndErrors(0xc42009c010, 0x0, 0x0, 0xc4201d3a90, 0x433f89, 0xc420000300)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/load/pkg.go:1457 +0xac
golang.org/x/vgo/vendor/cmd/go/internal/load.PackagesForBuild(0xc42009c010, 0x0, 0x0, 0x10, 0x10, 0x8a3240)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/load/pkg.go:1499 +0x5d
golang.org/x/vgo/vendor/cmd/go/internal/work.runBuild(0xb90920, 0xc42009c010, 0x0, 0x0)
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/internal/work/build.go:301 +0x85
golang.org/x/vgo/vendor/cmd/go.Main()
        /usr/local/gopath/src/golang.org/x/vgo/vendor/cmd/go/main.go:155 +0x82e
main.main()
        /usr/local/gopath/src/golang.org/x/vgo/main.go:31 +0x20
@gopherbot gopherbot added this to the vgo milestone May 28, 2018
@myitcv
Copy link
Member

myitcv commented May 28, 2018

I'll just note that whilst this should work (building a non-main package) this is failing on a line marked TODO.

Using the github.com/stretchr/testify/assert does work however:

cd `mktemp -d`
export GOPATH=$PWD
mkdir hello
cd hello
cat <<EOD > hello.go
package blah // import "example.com/blah"

import (
  "testing"
  "github.com/stretchr/testify/assert"
)

func TestSomething(t *testing.T) {

  // assert equality
  assert.Equal(t, 123, 123, "they should be equal")
}
EOD
echo >go.mod
vgo test

@myitcv myitcv changed the title x/vgo: build fails on github.com/stretchr/testify x/vgo: build fails on non-main github.com/stretchr/testify May 28, 2018
@leighmcculloch
Copy link
Contributor Author

If I change my local copy of testify to v1.2.0, then vgo build works. It seems it's getting confused because I'm attempting to build master which somehow must circularly reference around onto itself but at v1.2.0.

This works:

go get github.com/stretchr/testify
cd $GOPATH/src/github.com/stretchr/testify
git checkout v1.2.0
vgo build

This fails:

go get github.com/stretchr/testify
cd $GOPATH/src/github.com/stretchr/testify
git checkout master
vgo build

@anacrolix
Copy link
Contributor

#24103

@myitcv
Copy link
Member

myitcv commented May 29, 2018

I'll close this as a duplicate of #24103 - thanks @anacrolix

@leighmcculloch
Copy link
Contributor Author

@anacrolix @myitcv I don't think this is a duplicate. Same error message, but the cause appears to be different.

In #24103 the issue is there are no Go files at the root, and simply adding a ./... build path fixes the problem. In this issue #25604 there are Go files at the root and adding ./... does not fix the issue. In this case it's like vgo is circular referencing on the package being built, as it tries to lookup a version of itself that isn't the version being built. As I mentioned above in #25604 (comment), building the version it tries to lookup works.

@leighmcculloch
Copy link
Contributor Author

Calling vgo build on master attempts to pull in v1.2.0 on the second line of the build output:

github.com/stretchr/testify [master] $ vgo build                                                                                 
vgo: finding github.com/stretchr/objx v0.0.0-20180106011353-facf9a85c22f               
vgo: finding github.com/stretchr/testify v1.2.0
vgo: finding github.com/stretchr/objx v0.0.0-20140526180921-cbeaeb16a013                                                                     
vgo: finding github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0  
vgo: finding github.com/pmezard/go-difflib v1.0.0                                          
vgo: finding github.com/davecgh/go-spew v1.1.0                                                                                               
panic: unbuildable

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