Skip to content

cmd/go: spurious "v1.x.y is not a tag" error when a tag's commit was previously download without the tag #53955

Closed
@central182

Description

@central182

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

$ go version
go version go1.18.4 linux/amd64

Does this issue reproduce with the latest release?

Yes. I was able to reproduce from Docker image golang:1.18.4.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY="github.com/central182"
GONOSUMDB="github.com/central182"
GOOS="linux"
GOPATH="/go"
GOPRIVATE="github.com/central182"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/example/go.mod"
GOWORK=""
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-build856782336=/tmp/go-build -gno-record-gcc-switches"

What did you do?

On my host machine

  1. Create a private Go module. (Say it's hosted on https://github.com/central182/foobar and the latest commit is ef2f664, with tag v1.0.9 pointing to some earlier commit.)
  2. Launch a Docker container that is able to access my private repositories on GitHub.
$ docker run -it -v /home/me/shared_ssh:/root/.ssh golang:1.18.4

Inside Docker

  1. Do the necessary configuration for downloading private Go modules via SSH.
$ export GOPRIVATE=github.com/central182
$ git config --global url."ssh://[email protected]".insteadOf "https://github.com"
  1. Create a temporary Go module.
$ cd ~ && mkdir example && cd example && go mod init example
go: creating new go.mod: module example
  1. Get the foobar module with its latest commit hash ef2f664.
$ go get github.com/central182/foobar@ef2f664
go: downloading github.com/central182/foobar v1.0.10-0.20220226164108-ef2f6641951f
go get: added github.com/central182/foobar v1.0.10-0.20220226164108-ef2f6641951f

On my host machine

  1. Tag ef2f664 with v1.0.10 and push it to GitHub.
$ git tag v1.0.10
$ git push --tags
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:central182/foobar.git
 * [new tag]         v1.0.10 -> v1.0.10
$ git log --oneline
ef2f664 (HEAD -> main, tag: v1.0.10, origin/main) Empty commit

Inside Docker

  1. Try to get the foobar module with the tag v1.0.10, and watch it fail.
$ go get github.com/central182/[email protected]
go get: github.com/central182/[email protected]: invalid version: resolves to version v1.0.11-0.20220226164108-ef2f6641951f (v1.0.10 is not a tag)
  1. However, if I repeat step 7 again, the download will succeed.
$ go get github.com/central182/[email protected]
go: downloading github.com/central182/foobar v1.0.10
go get: upgraded github.com/central182/foobar v1.0.10-0.20220226164108-ef2f6641951f => v1.0.10

What did you expect to see?

No failure at step 7.

What did you see instead?

The tag did exist while go said otherwise.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions