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 all' fails when offline after 'go mod tidy' due to missing .info files #42723

Open
jayconrod opened this issue Nov 19, 2020 · 2 comments

Comments

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Nov 19, 2020

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

$ go version
go1.15.5

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=""
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="off"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
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-build494451782=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go clean -modcache
go mod tidy
env GOPROXY=off
go list -m all

-- go.mod --
module m

go 1.15

require golang.org/x/mod v0.3.0
-- go.sum --
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-- use.go --
package use

import _ "golang.org/x/mod/semver"

What did you expect to see?

go list -m all should print all modules in build list.

What did you see instead?

go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off
go list -m: module lookup disabled by GOPROXY=off

go list -m loads an .info file for each module in the build list in order to include a timestamp in the output. Normally, the timestamp isn't shown, but it appears in the -json output, and it may appear in the -f output (related: #29666).

Most commands (including go mod tidy) don't download .info files for canonical versions. They're mainly used to resolve branch, tag, and commit names to versions. So when we go offline, the .info files are not in the cache, and go list -m fails.

We need to decide what to do here. If we can't load an .info file because we're offline or our proxies returned an error, we should just omit the field from the output instead of reporting an error.

We may want to reconsider reporting timestamps for canonical versions at all. I think the only case where we use them are when evaluating the @upgrade and @patch queries to decide whether a pseudo-version is chronologically newer than the highest release or pre-release version. Timestamps aren't required in the proxy protocol, and .info files aren't authenticated, so they can change and get out of sync with the cache.

cc @bcmills @matloob

@jayconrod jayconrod added this to the Backlog milestone Nov 19, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 19, 2020

Change https://golang.org/cl/271577 mentions this issue: cmd/go: remove ListModules call in runGet

@jayconrod
Copy link
Contributor Author

@jayconrod jayconrod commented Nov 20, 2020

After some discussion with @bcmills and @matloob yesterday, I we should stop reading .info files for canonical versions in go list -m and stop showing the Time field in go list -m -json.

The @upgrade and @patch queries use the timestamp if the current version is a pseudo-version to determine when the version returned by @latest is chronologically newer than the current version. The timestamp is part of the pseudo-version, but we retrieve and read .info files for non-pseudo-versions for this comparison.

gopherbot pushed a commit that referenced this issue Nov 20, 2020
ListModules was used to download .info files so that 'go list -m all'
would succeed later when offline. However, 'go list -m all' may
already fail when offline after 'go mod tidy', so it doesn't make
sense to add complexity to 'go get'.

Instead, remove the ListModules call and fix the test that
accidentally depended on it.

For #42723

Change-Id: I692597cf5ca15c23fa6fc9d2bac4b6e044299482
Reviewed-on: https://go-review.googlesource.com/c/go/+/271577
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
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
2 participants
You can’t perform that action at this time.