go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.24k stars 5.5k forks source link

Go package registry versions don't work #30413

Closed stuzer05 closed 7 months ago

stuzer05 commented 7 months ago

Description

So I published my package in gitea instance

https://gitea.stuzer.link/stuzer05/-/packages/go/gitea.stuzer.link%2Fstuzer05%2Fgo-monobank/v2303

but when I try to run go install/get command I get the following error

GOPROXY=https://gitea.stuzer.link/api/packages/stuzer05/go go install gitea.stuzer.link/stuzer05/go-monobank@v230
go: gitea.stuzer.link/stuzer05/go-monobank@v2303: no matching versions for query "v2303"

GOPROXY=https://gitea.stuzer.link/api/packages/stuzer05/go go get gitea.stuzer.link/stuzer05/go-monobank@v2303
go: gitea.stuzer.link/stuzer05/go-monobank@v2303: no matching versions for query "v2303"

also pkg.go.dev cannot see any package versions (even on-demand request)

https://pkg.go.dev/gitea.stuzer.link/stuzer05/go-monobank

how to fix this?

Gitea Version

trunk

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

docker

Database

None

wolfogre commented 7 months ago

I think the main issue is that v2303 isn't a valid version accepted by Go.

I am not sure if you are unfamiliar with Go and setting a non-semantic version number, or you are an expert with Go and wanting to configure some advanced operations.

I say this because I noticed that your repo had many valid semantic version numbers that had been cached by the official proxy. It seems you have deleted them.

$ curl https://proxy.golang.org/gitea.stuzer.link/stuzer05/go-monobank/@v/list
v0.15.0
v0.7.0
v0.7.3
v0.3.0
v0.7.2
v0.8.0
v0.6.0
v0.10.0
v0.20.0
v0.5.0
v0.12.0-alpha
v0.14.0-alpha
v0.18.0
v0.21.0
v0.19.1
v0.12.0
v0.19.0
v0.9.0
v0.4.0
v0.14.0
v0.3.1
v0.11.0
v0.1.0
v0.7.1
v0.13.0
v0.17.0
v0.2.0
v0.16.0

I'm confused, so please forgive me if I am too verbose.

If you want set a right version of your Go package, you could just create a tag with a semantic version. That's all, you don't need to set up a Go package on Gitea, which I think is for unusual scenarios.

If you do want v2303 and a Go package on Gitea, please see to the following reports I have figured out. Gitea works with that, but Go refuses to accept it.

$ GOPROXY=https://gitea.stuzer.link/api/packages/stuzer05/go go get -x gitea.stuzer.link/stuzer05/go-monobank@v2303
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/go-monobank/@v/list
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/@v/list
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/@v/list
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/@v/list: 404 Not Found (1.116s)
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/go-monobank/@v/list: 200 OK (1.117s)
# get https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/@v/list: 404 Not Found (1.117s)
go: gitea.stuzer.link/stuzer05/go-monobank@v2303: no matching versions for query "v2303"
$ curl https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/go-monobank/@v/list
v2303
$ curl https://gitea.stuzer.link/api/packages/stuzer05/go/gitea.stuzer.link/stuzer05/go-monobank/@v/v2303.info
{"Version":"v2303","Time":"2024-04-11T10:52:02+03:00"}

So @v/list returned v2303 and there's metadata in @v/v2303.info, but Go chose to overlook it.

And I noticed that there's also a tag named v2303.

But Go still refuses to accept it even without proxy.

$ GOPROXY=direct go get -x gitea.stuzer.link/stuzer05/go-monobank@v2303
# get https://gitea.stuzer.link/stuzer05/go-monobank?go-get=1
# get https://gitea.stuzer.link/?go-get=1
# get https://gitea.stuzer.link/stuzer05?go-get=1
# get https://gitea.stuzer.link/stuzer05/go-monobank?go-get=1: 200 OK (1.215s)
# get https://gitea.stuzer.link/?go-get=1: 200 OK (1.215s)
mkdir -p /Users/jason/go/pkg/mod/cache/vcs # git3 https://gitea.stuzer.link/stuzer05/go-monobank.git
# lock /Users/jason/go/pkg/mod/cache/vcs/b790e20537d9bdc8aa875f63b0970d6c4d7dae7ec3296c3786bceaa0b1e1d3c8.lock
# /Users/jason/go/pkg/mod/cache/vcs/b790e20537d9bdc8aa875f63b0970d6c4d7dae7ec3296c3786bceaa0b1e1d3c8 for git3 https://gitea.stuzer.link/stuzer05/go-monobank.git
cd /Users/jason/go/pkg/mod/cache/vcs/b790e20537d9bdc8aa875f63b0970d6c4d7dae7ec3296c3786bceaa0b1e1d3c8; git ls-remote -q origin
# get https://gitea.stuzer.link/stuzer05?go-get=1: 200 OK (1.477s)
1.621s # cd /Users/jason/go/pkg/mod/cache/vcs/b790e20537d9bdc8aa875f63b0970d6c4d7dae7ec3296c3786bceaa0b1e1d3c8; git ls-remote -q origin
go: gitea.stuzer.link/stuzer05/go-monobank@v2303: no matching versions for query "v2303"
stuzer05 commented 7 months ago

Thank you for provided curl requests, I could't find out how to make them myself. I have the same problem with another package

https://pkg.go.dev/gitea.stuzer.link/stuzer05/go-firefly3

It has semantic versioning (v2.0.12) ut still not seen at pkg.go.dev

stuzer05 commented 7 months ago

Fixed for go-firefly3, added /v2 to package name in go.mod

wolfogre commented 7 months ago

Hmm, I think you may not very familiar to Go. No offense, everyone started as a beginner.

Go modules have special handling for major versions, since a major version change means breaking changes according to semantic versioning rules.

Once you choose to start with v2.*.*, it assumes you want to break something in v1. To protect the projects that use the old v1 version. You must give up using gitea.stuzer.link/stuzer05/go-firefly3 (which is for v1) as the module name and switch to gitea.stuzer.link/stuzer05/go-firefly3/v2 in go.mod.

wolfogre commented 7 months ago

Fixed for go-firefly3, added /v2 to package name in go.mod

I'm glad to hear that you have resolved the issue. Since our discussion is off-topic regarding this issue now, I will close it.