Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy.golang.org: issues with go get and modules after repository re-name #42433

Closed
4kills opened this issue Nov 7, 2020 · 2 comments
Closed
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@4kills
Copy link

4kills commented Nov 7, 2020

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

$ go version
1.15.4

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\--\AppData\Local\go-build
set GOENV=C:\Users\--\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\--\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\--\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\--\AppData\Local\Temp\go-build775205982=/tmp/go-build -gno-record-gcc-switches

What did you do?

  1. Renamed the (previously go.mod containing) repository github.com/4kills/libdeflate -> github.com/4kills/go-libdeflate

  2. Try to import this project https://github.com/4kills/go-libdeflate

Sample program:

package main

import (
	"fmt"

	"github.com/4kills/go-libdeflate"
)

func main() {
	c, _ := libdeflate.NewCompressor()
	fmt.Print(c)
}
  1. go mod init

  2. go get

What did you expect to see?

Successfully go-getting the latest version of the repository (v2.0.4)

What did you see instead?

go: finding module for package github.com/4kills/go-libdeflate
go: found github.com/4kills/go-libdeflate in github.com/4kills/go-libdeflate v1.3.0
go: github.com/4kills/hendrikIstdoof imports
        github.com/4kills/go-libdeflate: github.com/4kills/go-libdeflate@v1.3.0: parsing go.mod:
        module declares its path as: github.com/4kills/libdeflate
                but was required as: github.com/4kills/go-libdeflate

Assumption:

See how go get tries to fetch v1.3.0 instead of v2.0.4? I guess this is due to the renaming of the repository as well as it having been a go module and thus being cached in proxy.golang.org with the wrong name!
As stated by https://proxy.golang.org/ the caches of old versions won't ever be removed. Still this is a very annoying issue when renaming repos

Workaround:

This workaround works as it fetches the latest version from the actual source repo instead of the proxy

go get github.com/4kills/go-libdeflate@master 
@dmitshur
Copy link
Contributor

dmitshur commented Nov 7, 2020

This problem isn't caused by the module mirror and it's not related to the rename; the same behavior would happen even if you use GOPROXY=direct.

The reason go get tries to fetch v1.3.0 is because it's the latest released version:

$ go list -m -versions github.com/4kills/go-libdeflate
github.com/4kills/go-libdeflate v0.1.0-alpha v0.2.0-alpha v0.2.1-alpha v1.0.0 v1.1.0 v1.2.0 v1.2.1 v1.2.2 v1.3.0 v2.0.4+incompatible

The v2.0.4 tag causes a v2.0.4+incompatible version to be created, since it points at a commit without a go.mod file, and the import path for that version would need to be github.com/4kills/go-libdeflate/v2, not github.com/4kills/go-libdeflate.

Take a look at https://blog.golang.org/publishing-go-modules and other posts in that series for how to publish versions of a module.

@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 7, 2020
@4kills
Copy link
Author

4kills commented Nov 7, 2020

I read post you provided and adjusted my repository to the conventions mentioned there (moving v2.x to a dir /v2) and now everything is working just fine.
Sorry for wasting your time. The jump from version v1.3.0 to v2.0.0 was exactly when I renamed the repo, so I assumed that was the issue.

@4kills 4kills closed this as completed Nov 7, 2020
@golang golang locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants