Go: x/tools: internal error: go list gives conflicting information

Created on 14 Sep 2019  路  11Comments  路  Source: golang/go

While running staticcheck (at tip) using Go tip (8cc57c0ccc882a06352e6ad73cb7c281d34be3ef) with x/tools at tip (0240832f5c3d9ddcdcd51c66edbf8cd889a54108), I repeatedly got this error message:

internal error: go list gives conflicting information for package github.com/acme/server/src/cmd/server [github.com/acme/server/src/cmd/server.test]

I'm using a Mac latest version.

  • github.com/acme/server/src/cmd/server is a main package that imports github.com/acme/server/src and other packages.

  • github.com/acme/server/src is a library with package name package server.

I cleaned every cache I could find and could still reproduce the problem. I could not reproduce using Go 1.13.

Along the way I noticed that some files were importing github.com/BurntSushi/toml and some files were importing github.com/burntsushi/toml. I fixed this problem - using BurntSushi/toml everywhere - but still got the same error afterwards.

That's all the debugging information I have the time to provide at this point, sorry.

FrozenDueToAge Tools

Most helpful comment

Note for future people getting this error, for example while running golangci-lint: this also happens if you have an import cycle in your packages (including test ones). go test will print an appropriate error message, but loading packages with go/packages won't.

All 11 comments

I cannot reproduce at commit 396d62533013a39b527db4b02195e816e36dbf9a, so maybe I can bisect if I have time.

That message implies that in a single call to go list the json result had more than one entry for the same import path, and that those two entries disagreed about what that import path represented.
The thing it prints after the message is the import path, which implies that it thinks the problem is with the test variant of github.com/acme/server/src/cmd/server, do you have a main_test?
try running with GOPACKAGESDEBUG=true and see the exact go list command it is invoking, and then run that go list by hand to see what it does?

Yes, I have a main_test, though I tried deleting the file and moving the test contents to acme/server/src/server_test.go and was still able to reproduce.

I'm bisecting now.

I can reproduce with 24781a1faf62ac5c9a553af6f46b787e972f5539 and I cannot reproduce with 79877e5f91fb77362235d9160ddbeada5878a9c5 so I believe 24781a1faf62ac5c9a553af6f46b787e972f5539 is the offending commit.

I really need to see the go list invocation and what it prints to work out why
If you set GOPACKAGESDEBUG=true in your environment, go/packages gets nice and noisy

2019/09/14 03:00:56 18.409854ms for GOROOT=/Users/kevin/go GOPATH=/Users/kevin GO111MODULE=on PWD=/Users/kevin/src/github.com/acme/server go "env" "GOMOD", stderr: <<>>
2019/09/14 03:00:56 22.336353ms for GOROOT=/Users/kevin/go GOPATH=/Users/kevin GO111MODULE=on PWD=/Users/kevin/src/github.com/acme/server go "list" "-m" "-json" "all", stderr: <<>>
2019/09/14 03:00:57 290.0404ms for GOROOT=/Users/kevin/go GOPATH=/Users/kevin GO111MODULE=on PWD=/Users/kevin/src/github.com/acme/server go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=true" "-deps=true" "-find=false" "--" "./...", stderr: <<>>
internal error: go list gives conflicting information for package github.com/acme/server/src/cmd/server [github.com/acme/server/src/cmd/server.test]

So if you run that third command by hand, it should print a whole bunch of JSON for us?

Yes, I don't feel super comfortable pasting the output in a public channel though. I will mail to the email address in your profile shortly.

Just sent.

After talking to you offline it is a duplicate of #34321 so I am going to close this bug in favor of that one. Thanks for all your help isolating this!

Note for future people getting this error, for example while running golangci-lint: this also happens if you have an import cycle in your packages (including test ones). go test will print an appropriate error message, but loading packages with go/packages won't.

Was this page helpful?
0 / 5 - 0 ratings