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/tools/go/packages: cannot load "cmd" from within a module #29913

Closed
mvdan opened this issue Jan 24, 2019 · 4 comments
Closed

x/tools/go/packages: cannot load "cmd" from within a module #29913

mvdan opened this issue Jan 24, 2019 · 4 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Jan 24, 2019

$ go version
go version devel +9d23975d89 Wed Jan 23 23:13:03 2019 +0000 linux/amd64
$ git describe --always
6466e726
$ go install ./gopackages
$ gopackages cmd >/dev/null; echo $?
0
$ mkdir /tmp/tempmodule
$ cd /tmp/tempmodule
$ go mod init tempmodule
go: creating new go.mod: module tempmodule
$ gopackages cmd >/dev/null; echo $?
gopackages: go list repeated package github.com/google/pprof/internal/driver with different values
2

This seems pretty serious - I'm having trouble using a linter that I wrote as it's now running into these errors. Perhaps related to #29826, but in this case the packages don't seem to be identical, as DeepEqual returns false.

/cc @matloob @ianthehat

@mvdan
Copy link
Member Author

mvdan commented Jan 24, 2019

Seems like the issue is that it's loading the vendored packages as modules:

$ cat go.mod
module tempmodule

go 1.12

require (
        github.com/google/pprof v0.0.0-20190109223431-e84dfd68c163 // indirect
        github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6 // indirect
        golang.org/x/arch v0.0.0-20181203225421-5a4828bb7045 // indirect
        golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b // indirect
        golang.org/x/sys v0.0.0-20190124100055-b90733256f2e // indirect
        golang.org/x/tools v0.0.0-20190124004107-78ee07aa9465 // indirect
)

I'm starting to wonder if this is supposed to be broken. Still, I presume there's something to fix; the error is confusing.

Edit: as expected, GO111MODULE=off gopackages cmd always works. I'll be using this as a workaround for now.

@bcmills
Copy link
Contributor

bcmills commented Jan 24, 2019

Dup of #26924, or at least closely related.

@mvdan
Copy link
Member Author

mvdan commented Jan 24, 2019

Perhaps. The errors we end up with seem different, so I'm not sure if we should close this issue as a duplicate.

@mvdan mvdan changed the title go/packages: cannot load "cmd" from within a module x/tools/go/packages: cannot load "cmd" from within a module Jan 24, 2019
@gopherbot gopherbot added this to the Unreleased milestone Jan 24, 2019
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 1, 2019
@bcmills bcmills self-assigned this Mar 1, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Sep 18, 2019

Seems to be fixed at head.

~/src/golang.org/x/tools/go/packages$ go version
go version devel +49e7c7672d Mon Sep 16 11:56:15 2019 +0000 linux/amd64
~/src/golang.org/x/tools/go/packages$ go install ./gopackages
~/src/golang.org/x/tools/go/packages$ gopackages cmd >/dev/null; echo $?
0
~/src/golang.org/x/tools/go/packages$ mkdir /tmp/tempmodule
~/src/golang.org/x/tools/go/packages$ cd /tmp/tempmodule
/tmp/tempmodule$ go mod init tempmodule
go: creating new go.mod: module tempmodule
/tmp/tempmodule$ gopackages cmd >/dev/null; echo $?
0

@bcmills bcmills closed this as completed Sep 18, 2019
@golang golang locked and limited conversation to collaborators Sep 17, 2020
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants