equinixmetal-archive / packngo

[Deprecated] A Golang client for the Equinix Metal API. (Packet is now Equinix Metal)
https://deploy.equinix.com/labs/equinix-sdk-go/
Other
79 stars 53 forks source link

v0.30.0 is not a tag, says `go get` #368

Closed jabielecki closed 1 year ago

jabielecki commented 1 year ago

Description

I'd like to use packngo at v0.30.0 and I see an unexpected behavior:

$ mkdir /tmp/goget
$ cd /tmp/goget/
$ go mod init x
go: creating new go.mod: module x
$ go get -d github.com/packethost/packngo
go: github.com/packethost/packngo@v0.30.0: invalid version: resolves to version v0.29.1-0.20230515141158-b45284c83715 (v0.30.0 is not a tag)

What I expected

A success, like the last time:

$ go get -d github.com/packethost/packngo@v0.29.0
$ echo $?
0

Extra checks

$ go get -d github.com/packethost/packngo@v0.30.0
go: github.com/packethost/packngo@v0.30.0: invalid version: resolves to version v0.29.1-0.20230515141158-b45284c83715 (v0.30.0 is not a tag)
$ find ~ -name packngo
/home/kubit/go/pkg/mod/cache/download/github.com/packethost/packngo
/home/kubit/go/src/github.com/packethost/packngo
$ mv /home/kubit/go/pkg/mod/cache/download/github.com/packethost/packngo /tmp/cache-packngo

(nothing changed)

Versions

$ git version
git version 2.34.1

$ go version
go version go1.19.2 linux/amd64

$ git config -l
user.email=47531708+jabielecki@users.noreply.github.com
user.name=Jakub Bielecki
user.signingkey=<omit>
url.git@github.com:.insteadof=https://github.com
url.git@github.com:.insteadof=https://github.com
url.ssh://git@gitlab.com/.insteadof=https://gitlab.com/
gpg.format=ssh
commit.gpgsign=true
tag.gpgsign=true
init.defaultbranch=main
displague commented 1 year ago

I wasn't able to reproduce this locally nor in a container:

#!/usr/bin/env bash
# test.sh - 0775 (create this file locally in a directory docker can mount)

mkdir -p /tmp/packngotest
cd /tmp/packngotest

go mod init x
go get -d github.com/packethost/packngo
$ chmod a+x test.sh
$ nerdctl run --rm -i -v `pwd`/test.sh:/test.sh golang /test.sh
go: creating new go.mod: module x
go: downloading github.com/packethost/packngo v0.30.0
go: added github.com/packethost/packngo v0.30.0
jabielecki commented 1 year ago

After some digging with go get -x -d it looks like a cache issue. It tried to do something like this:

cd /home/kubit/go/pkg/mod/cache/vcs/8dc4fa85dc5f6f855e9b38517f6f12aee7464b4e24cbbdda535bee36d38a1e90; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' b45284c83715 --
b45284c83715a160236f466d510dac15592a263b 1684159918 HEAD -> master, origin/master

No tag reported, that's the problem. :point_up:

$ cd /home/kubit/go/pkg/mod/cache/vcs/8dc4fa85dc5f6f855e9b38517f6f12aee7464b4e24cbbdda535bee36d38a1e90; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' v0.29.0 --
850d0677ea8c7fc9b02e4555da14ecb8226b4cf0 1667576362 tag: v0.29.0

$ cd /home/kubit/go/pkg/mod/cache/vcs/8dc4fa85dc5f6f855e9b38517f6f12aee7464b4e24cbbdda535bee36d38a1e90; git -c log.showsignature=false log --no-decorate -n1 '--format=format:%H %ct %D' v0.30.0 --
fatal: bad revision 'v0.30.0'

I think what happened is that we've used github.com/packethost/packngo@v0.29.1-0.20230515141158-b45284c83715 before the tag v0.30.0 existed. Note the tag is using exactly the same commit id b45284c83715.

Good to know that directory like ~/go/pkg/mod/cache/download/github.com/packethost/packngo is only a minor part of the cache, and not relevant to git issues. Removing it mostly doesn't make any sense. :bulb: :slightly_smiling_face:

The problem was shared between people who obtained their cache in the same way initially (from the same shared go.mod file), but it's rather unlikely to happen in the wild. Closing, thank you.