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: go list should set Package.Root to the module root directory, not GOPATH #46119

Closed
perillo opened this issue May 12, 2021 · 6 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@perillo
Copy link
Contributor

perillo commented May 12, 2021

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

$ go version
go version go1.16.4 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE="*.local"
GOMODCACHE="/home/manlio/.local/lib/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="*.local"
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/manlio/src/go/src/github.com/perillo/i3workon/go.mod"
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-build2730267008=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.16.4 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.16.4
uname -sr: Linux 5.12.2-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.33.
gdb --version: GNU gdb (GDB) 10.2

What did you do?

From inside a module root directory:
go list -find -json ./pkg

What did you expect to see?

Package.Root set to the current module root directory, ignoring GOPATH.

What did you see instead?

Package.Root is set to the GOPATH directory containing the package.

@mvdan
Copy link
Member

mvdan commented May 12, 2021

Can you run go env GOMOD right before or after go list, in the same directory? Because from your go env earlier it shows GOMOD="/dev/null", implying that you weren't inside a module.

@perillo
Copy link
Contributor Author

perillo commented May 12, 2021

Sorry, I ran the go bug command from a different directory. I have updated the information.

@mvdan
Copy link
Member

mvdan commented May 12, 2021

On a module checked out at ~/src/sh, I correctly get "Root": "/home/mvdan/src/sh", for both go list -json . and go list -json -find .. My guess is that go list gets confused in your case, because you've checked out the module inside your GOPATH.

I still agree this sounds like a bug.

@perillo
Copy link
Contributor Author

perillo commented May 12, 2021

I have all my modules inside GOPATH and with Module.Dir = os.path.Join("$GOPATH/src", Module.Path).

@gopherbot
Copy link

Change https://golang.org/cl/319209 mentions this issue: cmd/go/internal/load: override Package.Root in module mode

@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 12, 2021
@heschi heschi added this to the Backlog milestone May 12, 2021
@heschi
Copy link
Contributor

heschi commented May 12, 2021

cc @bcmills @jayconrod @matloob

@bcmills bcmills modified the milestones: Backlog, Go1.17 May 14, 2021
@golang golang locked and limited conversation to collaborators May 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants