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

Retraction in go.mod should be allowed to retract versions of subdirectory go.mod files in the same git repo #49015

Closed
fishy opened this issue Oct 16, 2021 · 4 comments

Comments

@fishy
Copy link

fishy commented Oct 16, 2021

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

$ go version
go version go1.17.2 linux/amd64

Does this issue reproduce with the latest release?

This is the latest release

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fishy/.cache/go-build"
GOENV="/home/fishy/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fishy/.gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fishy/.gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/nix/store/vydvhfg076dfchm93hn96li2k1jqh04n-go-1.17.2/share/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/nix/store/vydvhfg076dfchm93hn96li2k1jqh04n-go-1.17.2/share/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/fishy/work/test-go-mod-retract/go.mod"
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-build3897776340=/tmp/go-build -gno-record-gcc-switches"

What did you do?

This is forked from the discussion of #34055 and is an issue currently affecting Apache Thrift.

I made a minimal reproducible example at https://github.com/fishy/test-go-mod-retract to demonstrate the issue, but the high level summary is:

  1. The project made a mistake by adding go.mod to a subdirectory, without realizing the consequences of that.
  2. The project realized that's a mistake, removed the go.mod in the subdirectory and added go.mod to the root directory instead.
  3. The action in 2 doesn't fix the issue totally. the version with go.mod under the subdirectory will be recognized by go toolchain (and pkg.go.dev site) as the "latest" version, over whatever git semver tag you tagged at the project later (for example, if you go to https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift, it will tell you that it's not the "latest" version).
  4. Even if you try to retract that version from root go.mod file, it won't work (as I demonstrated in the test-go-mod-retract repo).

What did you expect to see?

Either:

  1. We are able to retract a version from a previous, subdirectory go.mod file, from the root go.mod file

or

  1. Provide a way to retract the whole go.mod file (e.g. we can add the subdirectory go.mod saying "every previous version coming out of this go.mod file are retracted and this go.mod file should be ignored")

What did you see instead?

The consequences of the mistake of adding subdirectory go.mod file lasts forever with no way to fix completely.

@seankhliao
Copy link
Member

1 seems infeasible, the module system doesn't operate on the concept of repos, and individual modules are independent.

2 is already possible possible by publishing a higher version which retracts all the versions before, up to and including the current version

@fishy
Copy link
Author

fishy commented Oct 16, 2021

Sorry @seankhliao I didn't explain myself well in my proposal 2.

My understanding is (please correct me if I'm wrong) that the current thing we have in 2, is that yes we can retract all previous versions of this module in the subdirectory/go.mod file, but by doing so we are adding subdirectory/go.mod again, making the current version available, and we are going back to dealing with all the consequences of having a subdirectory/go.mod again, which totally defeats the purpose (the purpose is to retract all versions under subdirectory/go.mod and make it to always use root go.mod going forward).

Thus, my proposal is to add something like (any of the following or some better names, I'm bad at names):

  • retract *
  • retract all
  • retract module
  • retract-module
  • retract_module
  • etc.

With the semantic of "retract all previous versions of this module, and also ignore the current version of this module and lookup the parent directory for go module instead".

Does that make sense?

@seankhliao
Copy link
Member

seankhliao commented Oct 16, 2021

Say you're currently have subdirectory/go.mod tagged with subdirectory/v0.15.0.

You can add a commit with subdirectory/go.mod with retract [v0.0.0-00000000000000-000000000000, v0.15.1], publish it by tagging subdirectory/v0.15.1 then remove afterwards. go should treat it as retracting all versions up to that point,

@fishy
Copy link
Author

fishy commented Oct 16, 2021

Thankns, @seankhliao! That worked.

fishy added a commit to fishy/thrift that referenced this issue Oct 16, 2021
skipci.

Currently when people going to
https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift it
shows that a previous version with lib/go/thrift/go.mod file is the
latest version.

With solution provided in
golang/go#49015 (comment), this
commit will NOT be merged, but tagged as
`lib/go/thrift/v0.0.1-do-not-use`, in order to retract the bad version
and make `v0.15.0` and the future versions as the correct latest version
recognized by go toolchain.
fishy added a commit to fishy/thrift that referenced this issue Oct 16, 2021
Currently when people going to
https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift it
shows that a previous version with lib/go/thrift/go.mod file is the
latest version.

With solution provided in
golang/go#49015 (comment), this
commit will NOT be merged, but tagged as
`lib/go/thrift/v0.0.1-do-not-use`, in order to retract the bad version
and make `v0.15.0` and the future versions as the correct latest version
recognized by go toolchain.

[skip ci]
fishy added a commit to fishy/thrift that referenced this issue Oct 16, 2021
Currently when people going to
https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift it
shows that a previous version with lib/go/thrift/go.mod file is the
latest version.

With solution provided in
golang/go#49015 (comment), this
commit will NOT be merged, but tagged as
`lib/go/thrift/v0.0.1-do-not-use`, in order to retract the bad version
and make `v0.15.0` and the future versions as the correct latest version
recognized by go toolchain.

[skip ci]
fishy added a commit to fishy/thrift that referenced this issue Oct 17, 2021
Currently when people going to
https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift it
shows that a previous version with lib/go/thrift/go.mod file is the
latest version.

With solution provided in
golang/go#49015 (comment), this
commit will NOT be merged, but tagged as
`lib/go/thrift/v0.0.1-do-not-use`, in order to retract the bad version
and make `v0.15.0` and the future versions as the correct latest version
recognized by go toolchain.

[skip ci]
fishy added a commit to fishy/thrift that referenced this issue Oct 18, 2021
Currently when people going to
https://pkg.go.dev/github.com/apache/thrift@v0.15.0/lib/go/thrift it
shows that a previous version with lib/go/thrift/go.mod file is the
latest version.

With solution provided in
golang/go#49015 (comment), this
commit will NOT be merged, but tagged as
`lib/go/thrift/v0.0.1-do-not-use`, in order to retract the bad version
and make `v0.15.0` and the future versions as the correct latest version
recognized by go toolchain.

[skip ci]
@golang golang locked and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants