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

cmd/go: panic when running "go mod vendor" on tip #46659

Open
kevinburkemeter opened this issue Jun 9, 2021 · 7 comments
Open

cmd/go: panic when running "go mod vendor" on tip #46659

kevinburkemeter opened this issue Jun 9, 2021 · 7 comments

Comments

@kevinburkemeter
Copy link

@kevinburkemeter kevinburkemeter commented Jun 9, 2021

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

$ go version
go version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000 darwin/amd64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env
GO111MODULE="off"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kevin/Library/Caches/go-build"
GOENV="/Users/kevin/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kevin/pkg/mod"
GONOPROXY="github.com/meterup"
GONOSUMDB="github.com/meterup"
GOOS="darwin"
GOPATH="/Users/kevin"
GOPRIVATE="github.com/meterup"
GOPROXY="direct"
GOROOT="/Users/kevin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/kevin/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/s1/909yt58s4wj8h_7v7frr8rkm0000gn/T/go-build73385364=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000 darwin/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.17-6551763a60 Tue Jun 8 20:45:46 2021 +0000
uname -v: Darwin Kernel Version 19.6.0: Thu May  6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H1217
lldb --version: lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
gdb --version: GNU gdb (GDB) 10.2

What did you do?

Added the following to go.mod and ran "go mod vendor && go mod tidy"

module github.com/meterup/packages/go/terraform

go 1.16

require github.com/hashicorp/terraform v0.15.5

// These "replace" directives are from Terraform 0.15.3 - Terraform 0.15.5 has different replace directives

replace google.golang.org/grpc v1.31.1 => google.golang.org/grpc v1.27.1

replace k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab

What did you expect to see?

All of the packages placed in the vendor directory

What did you see instead?

go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
panic: internal error: adding [google.golang.org/grpc@v1.31.1] to module graph had no effect on root requirements ([github.com/hashicorp/terraform@v0.15.5])

goroutine 1 [running]:
cmd/go/internal/modload.loadFromRoots({0x166e5c0, 0xc000024130}, {{{0x0, 0x0}, 0xc0001a2060, 0x1, {0x0, 0x0}, 0x1, 0x1, ...}, ...})
	/Users/kevin/go/src/cmd/go/internal/modload/load.go:1090 +0x12e9
cmd/go/internal/modload.LoadPackages({0x166e5c0, 0xc000024130}, {{0x0, 0x0}, 0xc0001a2060, 0x1, {0x0, 0x0}, 0x1, 0x1, ...}, ...)
	/Users/kevin/go/src/cmd/go/internal/modload/load.go:324 +0x328
cmd/go/internal/modcmd.runTidy({0x166e5c0, 0xc000024130}, 0xc0000284c8, {0xc0000201d0, 0x0, 0x7ffeefbff497})
	/Users/kevin/go/src/cmd/go/internal/modcmd/tidy.go:114 +0x1b7
main.main()
	/Users/kevin/go/src/cmd/go/main.go:201 +0xadf
make: *** [Makefile:8: vendor] Error 2
@kevinburkemeter
Copy link
Author

@kevinburkemeter kevinburkemeter commented Jun 9, 2021

So I had the dependencies wrong. I was looking at the go.mod (and replace directives) for Terraform v0.15.3 (or possibly earlier) when I ran make vendor. When I updated the replace directives to match Terraform v0.15.5, I was able to run make vendor successfully.

Still, it doesn't seem like Go should be panicking during normal operation.

When I run the command with Go 1.16, I get an infinite loop:

go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/examples/helloworld/helloworld in google.golang.org/grpc v1.31.1
go: found google.golang.org/grpc/naming in google.golang.org/grpc v1.31.1
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jun 9, 2021

can you share the contents of go.mod?

@seankhliao seankhliao changed the title panic when running "go mod vendor" on tip cmd/go: panic when running "go mod vendor" on tip Jun 9, 2021
@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented Jun 9, 2021

@bcmills bcmills self-assigned this Jun 10, 2021
@bcmills bcmills added this to the Go1.17 milestone Jun 10, 2021
@bcmills
Copy link
Member

@bcmills bcmills commented Jun 10, 2021

(I'm going to try to fix this by the 1.17 final, but since it infinite-loops on 1.16 it's not a release blocker.)

@bcmills
Copy link
Member

@bcmills bcmills commented Jun 10, 2021

@kevinburkemeter, could you give a bit more detail about the relevant replace and require directives before and after you updated them to match Terraform v0.15.5? (If this was in an open-source repo, specific commits would be really helpful so I can distill them into a regression test.)

@kevinburkemeter
Copy link
Author

@kevinburkemeter kevinburkemeter commented Jun 10, 2021

Gah, yeah, I'm sorry, I thought I pasted the go.mod file but clearly I didn't. One second.

@kevinburkemeter
Copy link
Author

@kevinburkemeter kevinburkemeter commented Jun 10, 2021

I've updated the issue description with the go.mod file that reproduces the panic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants