Go "invalid version: unknown revision" - Fix in CI
Go resolves a module version to a real tag, commit, or pseudo-version. When the revision named in go.mod or on the command line does not exist upstream, resolution fails.
What this error means
A go get or build fails with invalid version: unknown revision vX.Y.Z. It means the tag was deleted or never existed, a branch was renamed, or a hand-written pseudo-version points at no commit.
go
go: github.com/foo/bar@v1.4.0: invalid version: unknown revision v1.4.0Common causes
Tag or branch no longer exists
The referenced tag was deleted or the default branch was renamed, so the revision cannot be found.
Hand-written pseudo-version
A manually typed pseudo-version points at a commit that is not in the repository.
How to fix it
Pin a revision that exists
- List the real versions and require one that resolves.
- Run go mod tidy and commit.
Terminal
go list -m -versions github.com/foo/bar
go get github.com/foo/bar@v1.4.1
go mod tidyLet go get generate the pseudo-version
- For an untagged commit, fetch by full SHA so Go computes a valid pseudo-version.
Terminal
go get github.com/foo/bar@<full-commit-sha>How to prevent it
- Pin full, published versions and avoid deleted tags.
- Let
go getgenerate pseudo-versions rather than typing them. - Verify a tag exists upstream before requiring it.
Related guides
Go "reading X: 404/410 Not Found" fetching module - Fix in CIFix Go "reading https://proxy.golang.org/...: 404 Not Found / 410 Gone" in CI - a missing version or a transi…
Go "download X: dial tcp: i/o timeout" - Fix in CIFix Go "download X: dial tcp ...: i/o timeout" in CI - a transient network failure reaching the module proxy.…
Go "module X found, but does not contain package" - Fix in CIFix Go "module X found (vY), but does not contain package X/sub" in CI - the module resolves but the subpacka…