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 get -u behaves differently with and without GOPROXY when a module doesn't exist at head #31766

Open
hyangah opened this issue Apr 30, 2019 · 2 comments
Labels
GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Apr 30, 2019

$ go version
go version devel +fbc6a97222 Mon Apr 29 19:54:30 2019 +0000 linux/amd64

The problem exists with go1.12 as well.

What did you do?

Without proxy, I could run go get -u successfully. With proxy, it fails with cryptic error message.

$ export GOPROXY=direct
$ mkdir scratch; cd scratch; go mod init example
$ go get github.com/spf13/viper
$ go get -u
go: finding golang.org/x/sys latest
go: finding golang.org/x/crypto latest
go: finding golang.org/x/tools latest
go: finding github.com/ugorji/go/codec latest
go: finding gopkg.in/check.v1 latest
go: finding golang.org/x/sync latest
go: finding golang.org/x/net latest
go: finding github.com/armon/consul-api latest
$ export GOPROXY=https://proxy.golang.org
$ mkdir scratch; cd scratch; go mod init example
$ go get github.com/spf13/viper
$ go get -u
go get: upgrading github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8: reading https://proxy.golang.org/github.com/ugorji/go/codec/@v/list: 404 Not Found

What happens underneath:

The viper module or its dependencies have dependency on github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8. The github.com/ugorji/go/codec does not exist in the origin at head (no go.mod file, no valid tag), but it probably existed with @d75b2dc. Thus, go mod download github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8 succeeds with and without GOPROXY.

But when trying to upgrade, with GOPROXY=direct, the go command runs a sequence of git commands and detects there is no tag, no go.mod file at head and doesn't attempt to upgrade.

With GOPROXY=, the go command queries /@v/list endpoint to find available module versions. The proxy doesn't know about the named module (because the module doesn't exist according to what go list -m -v reports), so answers HTTP error (404/410/500/...). Then, the go command treats it as a hard error.

I think in this case (the list query failure), the go command should not fail but proceed as if there is no newer version to upgrade (indeed, there is no version to upgrade to!)

@fatduo
Copy link

fatduo commented May 10, 2019

+1

go get: upgrading github.com/ugorji/go/codec@v0.0.0-20181204163529-d75b2dcb6bc8: unexpected status (http://*********/github.com/ugorji/go/codec/@v/list): 500 Internal Server Error

athen log

ERRO[0308] exit status 1: go: finding github.com/ugorji/go/codec latest
go list -m github.com/ugorji/go/codec: no matching versions for query "latest"  http-method=GET http-path=/github.com/ugorji/go/codec/@v/list http-url=/github.com/ugorji/go/codec/@v/list kind="Internal Server Error" module= operation=download.ListHandler ops="[download.ListHandler pool.List protocol.List vcsLister.List]" version=

@bcmills
Copy link
Contributor

bcmills commented May 22, 2019

CC @jayconrod

@bcmills bcmills added this to the Go1.13 milestone May 22, 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 May 22, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go modules 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