Why does go get fail with "invalid version: unknown revision"?
Asked Answered
E

4

16

I published an update to a Go module, bumping the version to v1.1.0. I created a tag named v1.1.0 and pushed the tag to GitHub.

https://github.com/depp/bytesize/releases/tag/v1.1.0

However, I cannot use this package in my other projects. I get an error that says, "invalid version: unknown revision v1.1.0". I don't know why the revision is "unknown", since it's tagged.

$ go get github.com/depp/[email protected]                    
go: downloading github.com/depp/bytesize v1.1.0
go get github.com/depp/[email protected]: github.com/depp/[email protected]: verifying module: github.com/depp/[email protected]: reading https://sum.golang.org/lookup/github.com/depp/[email protected]: 410 Gone
    server response: not found: github.com/depp/[email protected]: invalid version: unknown revision v1.1.0
[Exit: 1]
Ellerey answered 24/5, 2021 at 19:53 Comment(3)
export GOPRIVATE=github.com/deppLohse
It’s not a private module.Ellerey
maybe that helps: https://mcmap.net/q/503708/-go-build-can-39-t-find-a-revisionRutty
E
27

The tag was pushed after invoking go get once, which poisoned the Go module proxy cache.

From https://proxy.golang.org/:

Note that if someone requested the version before the tag was pushed, it may take up to 30 minutes for the mirror's cache to expire and fresh data about the version to become available.

The way to work around this before the cache expires is to use the GOPRIVATE environment variable to instruct go get to fetch this module directly, bypassing the cache.

From https://golang.org/cmd/go/:

GOPRIVATE, GONOPROXY, GONOSUMDB

Comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes that should always be fetched directly or that should not be compared against the checksum database.

The workaround is:

$ GOPRIVATE=github.com/depp/bytesize go get github.com/depp/[email protected]

Note that if you are already using GOPRIVATE, you will want to add modules rather than overriding the value completely.

Ellerey answered 24/5, 2021 at 20:1 Comment(1)
Finally, a real answer. So many bs written by other people in over 9000 issues on this.Gwynethgwynne
W
5

Try with:

export GOSUMDB=off

It also works for me for the error:

verifying module: invalid GOSUMDB: malformed verifier id
Williamwilliams answered 2/8, 2022 at 15:11 Comment(0)
W
0

Anecdotal evidence at best, but updating the go.mod file directly and running go mod tidy worked for me when none of the other answers did.

➜  cli git:(main) ✗ go get github.com/opencamp-hq/[email protected]
go: github.com/opencamp-hq/[email protected]: invalid version: unknown revision 0.2.3
➜  cli git:(main) ✗ GOPRIVATE=github.com/opencamp-hq/core go get github.com/opencamp-hq/[email protected]
go: github.com/opencamp-hq/[email protected]: invalid version: unknown revision 0.2.3
➜  cli git:(main) ✗ GOSUMDB=off go get github.com/opencamp-hq/[email protected] 
go: github.com/opencamp-hq/[email protected]: invalid version: unknown revision 0.2.3

... edited go.mod ...
➜  cli git:(main) ✗ go mod tidy
go: downloading github.com/opencamp-hq/core v0.2.3
Winshell answered 19/6, 2023 at 23:31 Comment(0)
W
0

For Chinese, maybe we can run :(

export GOPROXY="https://goproxy.cn,direct"

Waggoner answered 29/12, 2023 at 5:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.