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: invalid version: unknown revision when GOPROXY/GOSUMDB disabled #36624

Closed
carlpett opened this issue Jan 17, 2020 · 6 comments
Closed

Comments

@carlpett
Copy link

carlpett commented Jan 17, 2020

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

$ go version
go version go1.13.5 linux/amd64

Does this issue reproduce with the latest release?

1.13.6 is not yet packaged for my distro

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cape/.cache/go-build"
GOENV="/home/cape/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="github.com/COMPANY-REPO/*"
GONOSUMDB="github.com/COMPANY-REPO/*"
GOOS="linux"
GOPATH="/home/cape/dev"
GOPRIVATE="github.com/COMPANY-REPO/*"
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/cape/dev/src/github.com/fluxcd/flux/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-build206448337=/tmp/go-build -gno-record-gcc-switches"

(The only concious override from defaults is setting export GOPRIVATE=github.com/COMPANY-REPO/* in .bashrc, the rest are changed by go or the distro)

What did you do?

Clone github.com/fluxcd/helm-operator, go mod download. Note that there are no private repos involved.

What did you expect to see?

Compilation

What did you see instead?

go: github.com/fluxcd/flux@v1.17.1-0.20200109130101-ca3e8f451dd0: invalid version: unknown revision ca3e8f451dd0

Discussion

Troubleshooting was done on Slack with @Helcaraxan, see https://app.slack.com/client/T029RQSE6/C9BMAAFFB/thread/C9BMAAFFB-1579255221.002900

The error was resolved by overriding the Fedora defaults of GOPROXY=direct, GOSUMDB=off (see here for the reasoning).

It seems unexpected that disabling sum checks would prevent fetching a specific dependency? I've been using the setup for several months without running into this with other repos.

Note that there are no firewalls/proxies other things intercepting traffic, so access to Github is not a problem.

@Helcaraxan
Copy link
Contributor

Helcaraxan commented Jan 17, 2020

I was able to reproduce this on 1.13.6 from my home connection with no specific network setup either.

 -> git clone https://github.com/fluxcd/helm-operator && cd helm-operator
 -> go env -w GOPROXY=direct GOSUMDB=off
 -> go env GOPROXY GOSUMDB
direct
off
 -> go mod tidy
go: github.com/fluxcd/flux@v1.17.1-0.20200109130101-ca3e8f451dd0: invalid version: unknown revision ca3e8f451dd0

The commit in question does exist on GitHub.

@Helcaraxan
Copy link
Contributor

Tl;dr - The upstream users fluxcd/helm-operator should update the version of fluxcd/flux that they are referencing.

Ok. Dug a bit further and solved the problem. It's not an issue with the go toolchain itself.

  • The top-level module that is being build, fluxcd/helm-operator, references fluxcd/flux@ca3e8f451dd0 in its requires.
  • That commit, although it still can be accessed via the GitHub UI is no longer part of the actual git history of the fluxcd/flux repo. It is still visible most likely as part of a fork (as you can access commits from all forks from any repo in the network via the web UI).
  • This pseudo-version was however appropriately cached by the module proxy. Protecting users against the disappearance of the underlying commit, as it is intended to do.
  • The forced setting in Fedora's DNF package for Go of GOPROXY=direct instead of the usual GOPROXY=https://proxy.golang.org then resulted in the case of @carlpett to bypass the proxy and instead try to clone the actual repo and find the appropriate revision which had already been deleted.

I believe this means we can close this issue.

@carlpett
Copy link
Author

As @Helcaraxan found out, the commit is not part of any branch, so the error message is correct. Not much to do here, probably.

@heschi
Copy link
Contributor

heschi commented Jan 17, 2020

FYI @hyangah @katiehockman.

It would be interesting to say what the Fedora people have to say about this. I expect it will only happen more often as time goes on and more things are deleted.

@coanor
Copy link

coanor commented May 25, 2020

I'm using docker to test my repo, under centos 8.0, the go build works well, while under centos 6.5, I go the error unknown revision d71410dd73eb.

Under centos8.0, the Git version is 2.18.2, while under centos 6.5, Git version is 1.7.1, does git releated to the issue?

@schaepher
Copy link

I'm using docker to test my repo, under centos 8.0, the go build works well, while under centos 6.5, I go the error unknown revision d71410dd73eb.

Under centos8.0, the Git version is 2.18.2, while under centos 6.5, Git version is 1.7.1, does git releated to the issue?
@coanor

Yes. The go mod tidy command uses git ls-remote -q origin to load refs.
see: https://github.com/golang/go/blob/go1.15/src/cmd/go/internal/modfetch/codehost/git.go#L178

But the -q option was added to git in git v1.7.2-rc0.
see: git/git@cefb2a5

So if your git version is older then v1.7.2-rc0, this error is inevitable.

If you run go get your-repo, you will see the error from git:

$ go get a-repo
go get a-repo: module a-repo: git ls-remote -q origin in /go/pkg/mod/cache/vcs/f93901d37beed0fcdb30950985bd386107757c23046f467642803dcf63e192ee: exit status 129:
        usage: git ls-remote [--heads] [--tags]  [-u <exec> | --upload-pack <exec>] <repository> <refs>...

@golang golang locked and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants