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 · 1 comment

Comments

Projects
None yet
2 participants
@hyangah
Copy link
Contributor

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

This comment has been minimized.

Copy link

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=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.