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 mod download shows outdated versions #38524

Closed
slon opened this issue Apr 19, 2020 · 2 comments
Closed

cmd/go: go mod download shows outdated versions #38524

slon opened this issue Apr 19, 2020 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@slon
Copy link
Contributor

slon commented Apr 19, 2020

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

$ go version
go version go1.14.2 linux/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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/prime/.cache/go-build"
GOENV="/home/prime/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/prime/Code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/fake_module540658617/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-build518326984=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Here are complete steps to reproduce the issue.

  1. Create empty module.
  2. Run go get rsc.io/quote/v3.
  3. Run go mod download -json
  4. Run go list golang.org/x/text
  5. Run go mod download -json again.
Complete output
prime@bee /t/testmodule> go mod download -json
{
	"Path": "golang.org/x/text",
	"Version": "v0.0.0-20170915032832-14c0d48ead0c",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.0.0-20170915032832-14c0d48ead0c.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c",
	"Sum": "h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=",
	"GoModSum": "h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ="
}
{
	"Path": "rsc.io/quote/v3",
	"Version": "v3.1.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/rsc.io/quote/v3@v3.1.0",
	"Sum": "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=",
	"GoModSum": "h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0="
}
{
	"Path": "rsc.io/sampler",
	"Version": "v1.3.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/rsc.io/sampler@v1.3.0",
	"Sum": "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=",
	"GoModSum": "h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA="
}
prime@bee /t/testmodule> go list golang.org/x/text/...
go: finding module for package golang.org/x/tools/go/loader
go: finding module for package golang.org/x/tools/go/buildutil
go: found golang.org/x/tools/go/buildutil in golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290
golang.org/x/text
golang.org/x/text/cases
golang.org/x/text/cmd/gotext
golang.org/x/text/cmd/gotext/examples/extract
golang.org/x/text/cmd/gotext/examples/extract_http
golang.org/x/text/cmd/gotext/examples/extract_http/pkg
golang.org/x/text/cmd/gotext/examples/rewrite
golang.org/x/text/collate
golang.org/x/text/collate/build
golang.org/x/text/collate/tools/colcmp
golang.org/x/text/currency
golang.org/x/text/date
golang.org/x/text/encoding
golang.org/x/text/encoding/charmap
golang.org/x/text/encoding/htmlindex
golang.org/x/text/encoding/ianaindex
golang.org/x/text/encoding/internal
golang.org/x/text/encoding/internal/enctest
golang.org/x/text/encoding/internal/identifier
golang.org/x/text/encoding/japanese
golang.org/x/text/encoding/korean
golang.org/x/text/encoding/simplifiedchinese
golang.org/x/text/encoding/traditionalchinese
golang.org/x/text/encoding/unicode
golang.org/x/text/encoding/unicode/utf32
golang.org/x/text/feature/plural
golang.org/x/text/internal
golang.org/x/text/internal/catmsg
golang.org/x/text/internal/cldrtree
golang.org/x/text/internal/colltab
golang.org/x/text/internal/export/idna
golang.org/x/text/internal/format
golang.org/x/text/internal/gen
golang.org/x/text/internal/number
golang.org/x/text/internal/stringset
golang.org/x/text/internal/tag
golang.org/x/text/internal/testtext
golang.org/x/text/internal/triegen
golang.org/x/text/internal/ucd
golang.org/x/text/internal/utf8internal
golang.org/x/text/language
golang.org/x/text/language/display
golang.org/x/text/message
golang.org/x/text/message/catalog
golang.org/x/text/message/pipeline
golang.org/x/text/number
golang.org/x/text/runes
golang.org/x/text/search
golang.org/x/text/secure
golang.org/x/text/secure/bidirule
golang.org/x/text/secure/precis
golang.org/x/text/transform
golang.org/x/text/unicode
golang.org/x/text/unicode/bidi
golang.org/x/text/unicode/cldr
golang.org/x/text/unicode/norm
golang.org/x/text/unicode/rangetable
golang.org/x/text/unicode/runenames
golang.org/x/text/width
prime@bee /t/testmodule> go mod download -json
{
	"Path": "github.com/yuin/goldmark",
	"Version": "v1.1.27",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/github.com/yuin/goldmark/@v/v1.1.27.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/github.com/yuin/goldmark/@v/v1.1.27.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/github.com/yuin/goldmark/@v/v1.1.27.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/github.com/yuin/goldmark@v1.1.27",
	"Sum": "h1:nqDD4MMMQA0lmWq03Z2/myGPYLQoXtmi0rGVs95ntbo=",
	"GoModSum": "h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74="
}
{
	"Path": "golang.org/x/crypto",
	"Version": "v0.0.0-20191011191535-87dc89f01550",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/crypto/@v/v0.0.0-20191011191535-87dc89f01550.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/crypto/@v/v0.0.0-20191011191535-87dc89f01550.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/crypto/@v/v0.0.0-20191011191535-87dc89f01550.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/crypto@v0.0.0-20191011191535-87dc89f01550",
	"Sum": "h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=",
	"GoModSum": "h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI="
}
{
	"Path": "golang.org/x/mod",
	"Version": "v0.2.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/mod/@v/v0.2.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/mod/@v/v0.2.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/mod/@v/v0.2.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/mod@v0.2.0",
	"Sum": "h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=",
	"GoModSum": "h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA="
}
{
	"Path": "golang.org/x/net",
	"Version": "v0.0.0-20200226121028-0de0cce0169b",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20200226121028-0de0cce0169b.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20200226121028-0de0cce0169b.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/net/@v/v0.0.0-20200226121028-0de0cce0169b.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/net@v0.0.0-20200226121028-0de0cce0169b",
	"Sum": "h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=",
	"GoModSum": "h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s="
}
{
	"Path": "golang.org/x/sync",
	"Version": "v0.0.0-20190911185100-cd5d95a43a6e",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sync/@v/v0.0.0-20190911185100-cd5d95a43a6e.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sync/@v/v0.0.0-20190911185100-cd5d95a43a6e.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sync/@v/v0.0.0-20190911185100-cd5d95a43a6e.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e",
	"Sum": "h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=",
	"GoModSum": "h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM="
}
{
	"Path": "golang.org/x/sys",
	"Version": "v0.0.0-20190412213103-97732733099d",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20190412213103-97732733099d.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20190412213103-97732733099d.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20190412213103-97732733099d.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/sys@v0.0.0-20190412213103-97732733099d",
	"Sum": "h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=",
	"GoModSum": "h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs="
}
{
	"Path": "golang.org/x/text",
	"Version": "v0.3.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/text/@v/v0.3.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/text@v0.3.0",
	"Sum": "h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=",
	"GoModSum": "h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ="
}
{
	"Path": "golang.org/x/tools",
	"Version": "v0.0.0-20200417140056-c07e33ef3290",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/tools/@v/v0.0.0-20200417140056-c07e33ef3290.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/tools/@v/v0.0.0-20200417140056-c07e33ef3290.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/tools/@v/v0.0.0-20200417140056-c07e33ef3290.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/tools@v0.0.0-20200417140056-c07e33ef3290",
	"Sum": "h1:NXNmtp0ToD36cui5IqWy95LC4Y6vT/4y3RnPxlQPinU=",
	"GoModSum": "h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE="
}
{
	"Path": "golang.org/x/xerrors",
	"Version": "v0.0.0-20191204190536-9bdfabe68543",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/xerrors/@v/v0.0.0-20191204190536-9bdfabe68543.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/xerrors/@v/v0.0.0-20191204190536-9bdfabe68543.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/golang.org/x/xerrors/@v/v0.0.0-20191204190536-9bdfabe68543.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543",
	"Sum": "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=",
	"GoModSum": "h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0="
}
{
	"Path": "rsc.io/quote/v3",
	"Version": "v3.1.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/quote/v3/@v/v3.1.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/rsc.io/quote/v3@v3.1.0",
	"Sum": "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=",
	"GoModSum": "h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0="
}
{
	"Path": "rsc.io/sampler",
	"Version": "v1.3.0",
	"Info": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.info",
	"GoMod": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.mod",
	"Zip": "/home/prime/Code/go/pkg/mod/cache/download/rsc.io/sampler/@v/v1.3.0.zip",
	"Dir": "/home/prime/Code/go/pkg/mod/rsc.io/sampler@v1.3.0",
	"Sum": "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=",
	"GoModSum": "h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA="
}

What did you expect to see?

I'm expecting, that first invocation of go mod download would list final versions of all go modules.

What did you see instead?

First invocation of go mod download is showing outdated versions, that are later upgraded after running go list.

I certainly do not expect go list to change my go.mod file. In my understanding, go list should be running read-only queries.

@andybons andybons changed the title go mod download shows outdated versions cmd/go: go mod download shows outdated versions Apr 20, 2020
@andybons andybons added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 20, 2020
@andybons andybons added this to the Unplanned milestone Apr 20, 2020
@andybons
Copy link
Member

@bcmills @jayconrod @matloob

@jayconrod
Copy link
Contributor

This seems like it's working as intended.

The latest version of rsc.io/quote/v3 requires golang.org/x/text at v0.0.0-20170915032832-14c0d48ead0c. That's an old version that does not have a go.mod file. The go command acts as if that version had a go.mod file with no requirements. So there are packages in that module that import packages not provided by any required modules.

That's fine if those packages are never built. As soon as the go command processes imports in those packages, it will look for modules that provide missing packages and add requirements on the latest versions of those modules to go.mod so that future commands are deterministic. In particular, go list golang.org/x/text/... does this. The go command adds a requirement on the latest version of golang.org/x/tools.

module m

go 1.14

require (
	golang.org/x/tools v0.0.0-20200420001825-978e26b7c37c // indirect
	rsc.io/quote/v3 v3.1.0 // indirect
)

golang.org/x/tools transitively requires golang.org/x/text at a newer version, v0.3.0. You can see the module requirement graph with go mod graph. So after the tools dependency is added, a newer version of golang.org/x/text is used.

I certainly do not expect go list to change my go.mod file. In my understanding, go list should be running read-only queries.

This may be surprising at first, but all module-aware commands may update go.mod if some information they need is missing so that future runs are repeatable. You may want to use the -mod=readonly flag instead.

@golang golang locked and limited conversation to collaborators Apr 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go 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

4 participants