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 -m' should not require go.sum with -versions or when all args are version queries #41297

Open
jayconrod opened this issue Sep 9, 2020 · 5 comments
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jayconrod
Copy link
Contributor

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

$ go version
go version go1.15.1 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/jayconrod/Code/modcache"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/go"
GOPRIVATE=""
GOPROXY="http://[::]:6123/mod"
GOROOT="/opt/go/installed"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayconrod/Code/test/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build106221923=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go mod init m
go mod edit -require=rsc.io/quote@v1.0.0
go list -m -mod=readonly -versions rsc.io/quote
go list -m -mod=readonly rsc.io/quote@latest

What did you expect to see?

Both the go list -m commands above should succeed.

What did you see instead?

Both commands fail. This happens because go list -m loads the build list before processing arguments. go.sum is missing, so that fails.

There's no need to load the build list for these commands. They both succeed when run outside a module or when go.mod contains no requirements.

@jayconrod jayconrod added NeedsFix The path to resolution is known, but the work has not been done. modules labels Sep 9, 2020
@jayconrod jayconrod added this to the Backlog milestone Sep 9, 2020
@sibis
Copy link

sibis commented Sep 9, 2020

@jayconrod, Is this an up for grabs then? Because I'd like to try this one.

@jayconrod
Copy link
Contributor Author

@sibis Sure, feel free to take a look. I think it can mostly be done in src/cmd/go/internal/list/list.go.

@bcmills
Copy link
Contributor

bcmills commented Apr 10, 2021

@version turns out to be pretty easy, and I'm going to knock that out incidentally for #36460.

I think -versions will require part of the implementation for #29666, though: at the moment, we don't distinguish between -m -json -versions (which should also include information about the current version) and just -m -versions (which, without a -f template, does not need that information).

@gopherbot
Copy link

Change https://golang.org/cl/309191 mentions this issue: cmd/go/internal/modload: avoid loading the full module graph when listing specific modules

@gopherbot
Copy link

Change https://golang.org/cl/265777 mentions this issue: cmd/go/internal/modload: implement lazy loading

gopherbot pushed a commit that referenced this issue Apr 30, 2021
For #36460
Updates #41297

Change-Id: I1b82176a45df499e52f1a3a0ffe23eab2a1ca86e
Reviewed-on: https://go-review.googlesource.com/c/go/+/265777
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
gopherbot pushed a commit that referenced this issue Apr 30, 2021
…ting specific modules

For #36460
For #41297
Updates #29666

Change-Id: I5f324c0ef9a164f8043d2188101d141bb5fa7454
Reviewed-on: https://go-review.googlesource.com/c/go/+/309191
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants