Closed i4ki closed 1 year ago
Duplicate of #50278
It's not a duplicate... This is not a case of forking a repository.
The proposed solution there involves a -replace
option which does not make any sense here, as the old repository doesn't exist anymore.
the issue is the same, you want to install a module using a different name than the one it declared in its go.mod file
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm not sure if this is a bug but if not I'd like to understand the reasoning.
We have an open-source cmd-line tool with several releases but we created a dedicated Github organization and transferred the repository to it. We planned to update the module name, all import paths and documentation to the new URL. Then the problem is that:
works fine but using the new module name it fails:
GitHub is now redirecting requests from the old repo to the new one, then installing with the old repo still works, but if explicitly using the new name/url then it fails...
In the Go proxy, the new module name can reach all releases created with the old name: https://proxy.golang.org/github.com/terramate-io/terramate/@v/v0.2.18.mod (Check the module declaration)
And if manually downloading the zip from the proxy, unzipping and then everything works (go install, go build, go test, etc).
So it looks like
go install
is very picky and disallows the installation if the requested module is different than the one obtained from the released modfile.Why?
EDIT: I identified the only check that prevents this from working
I just compiled Go from sources and removed this
if
below and then the install works: https://github.com/golang/go/blob/055c186f53493da473c888869ad468861ba25f1a/src/cmd/go/internal/modload/modfile.go#L634-L645I'd like to know if the comment above the
if
applies to this case as well (GitHub redirection).What did you expect to see?
The
go install
invocations using the new module name should be able to install releases created with the old module name.What did you see instead?
The
go install
cannot install releases created before a repository was transferred using the new module name.