cmd/go: install cannot find non-module version when module proxy doesn't implement @latest #44594
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go install golang.org/x/lint/golint@latest
What did you expect to see?
Successful installation.
What did you see instead?
Description
I'm having trouble getting Go 1.15/1.16 to fetch a non-module package version when a module proxy that doesn't support
$base/$module/@latest
is in the list.Querying my local module proxy for
$goproxy/golang.org/x/lint/@v/list
returns 200 OK with an empty response body. This is the same ashttps://proxy.golang.org/golang.org/x/lint/@v/list
-- in fact, my local proxy is relaying the request toproxy.golang.org
.My local module proxy doesn't support
$goproxy/golang.org/x/lint/@latest
and returns 404 Not Found.proxy.golang.org
returns 200 OK with a JSON body containing a pseudo-version.The problem is that
go
doesn't seem to be moving on to trydirect
in my list of proxies. Per https://golang.org/ref/mod#goproxy-protocol,$base/$module/@latest
isn't required to be implemented, but this combination of (list=>200, latest=>404) doesn't seem to be working with the current code.Investigation so far
I've traced things through in a local build of go1.16 and found that execution is getting to the call to
p.latest()
on line 376:go/src/cmd/go/internal/modfetch/proxy.go
Lines 370 to 377 in f21be2f
This call is a bit strange to me -- if querying
@latest
fails, it seems to be trying@v/list
again, which it already did in an earlier call toproxyRepo.Versions()
. I'm curious to know if it serves a purpose.Even if I bypass the call to
p.latest()
in a local build andreturn nil, err
right before that, I think it's going togo/src/cmd/go/internal/modload/query.go
Lines 227 to 236 in f21be2f
ErrNotExist
and instead falls through to the end:go/src/cmd/go/internal/modload/query.go
Line 246 in f21be2f
Since
NoMatchingVersionError
is not anErrNotExist
,modfetch.TryProxies
sees this as an error and does not fail over to the next proxy in the list:go/src/cmd/go/internal/modfetch/proxy.go
Lines 179 to 181 in f21be2f
I think my analysis here is right, but I'm not entirely sure of what all the surrounding code is doing, so I'm having trouble telling if Go is doing something wrong or I'm falling into a subtle but expected behavior.
My current idea for a fix would be to replace
p.latest
with simply returning the error and to return earlier inmodload.queryProxy
ifrepo.Latest()
returnsErrNotExist
. I haven't started testing this yet, and I'm putting in this Issue in hopes that someone can to let me know if this sounds right before I start going too far down the wrong path. Thanks!The text was updated successfully, but these errors were encountered: