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

Cannot get latest version: module contains a go.mod file, so module path should be github.com/bblfsh/bblfshd/v2 #334

Open
KateGo520 opened this issue Jul 21, 2020 · 5 comments · May be fixed by #335

Comments

@KateGo520
Copy link

KateGo520 commented Jul 21, 2020

Background

The github.com/bblfsh/bblfshd uses Go modules and the current release version is v2. And it’s module path is "github.com/bblfsh/bblfshd", instead of "github.com/bblfsh/bblfshd/v2". It must comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation. Quoting the specification:

A package that has opted in to modules must include the major version in the import path to import any v2+ modules
To preserve import compatibility, the go command requires that modules with major version v2 or later use a module path with that major version as the final element. For example, version v2.0.0 of example.com/m must instead use module path example.com/m/v2.
https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Steps to Reproduce

GO111MODULE=on, run go get targeting any version >= v2.13.0 of the bblfsh/bblfshd:

$ go get github.com/bblfsh/[email protected]
go: finding github.com/bblfsh/bblfshd v2.16.1
go: finding github.com/bblfsh/bblfshd v2.16.1
go get github.com/bblfsh/[email protected]: github.com/bblfsh/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

run go get github.com/bblfsh/bblfshd, the version will stuck in v2.12.1:

$go get github.com/bblfsh/bblfshd
go: downloading github.com/bblfsh/bblfshd v1.2.0
go: downloading github.com/bblfsh/bblfshd v2.12.1+incompatible
go: github.com/bblfsh/bblfshd upgrade => v2.12.1+incompatible 

SO anyone using Go modules will not be able to easily use any newer version of bblfsh/bblfshd.

Solution

1. Kill the go.mod files, rolling back to GOPATH.

This would push them back to not being managed by Go modules (instead of incorrectly using Go modules).
Ensure compatibility for downstream module-aware projects and module-unaware projects projects

I see these dependencies in your go.mod file, which need modle awareness. So you'd better not use third-party tools(such as: Dep, glide, govendor…).

github.com/bblfsh/go-client/v4 v4.0.1
github.com/bblfsh/sdk/v3 v3.3.1
github.com/src-d/enry/v2 v2.0.0

You also need to update the import path to:

import github.com/bblfsh/go-client/…
import github.com/bblfsh/sdk/…
import github.com/src-d/enry/…

2. Fix module path to strictly follow SIV rules.

Patch the go.mod file to declare the module path as github.com/bblfsh/bblfshd/v2 as per the specs. And adjust all internal imports.
The downstream projects might be negatively affected in their building if they are module-unaware (Go versions older than 1.9.7 and 1.10.3; Or use third-party dependency management tools, such as: Dep, glide,govendor…).

If you don't want to break the above repos. This method can provides better backwards-compatibility.
Release a v2 or higher module through the major subdirectory strategy: Create a new v2 subdirectory (github.com/bblfsh/bblfshd/v2) and place a new go.mod file in that subdirectory. The module path must end with /v2. Copy or move the code into the v2 subdirectory. Update import statements within the module to also use /v2 (import "github.com/bblfsh/bblfshd/v2/…"). Tag the release with v2.x.y.

3. Suggest your downstream module users use hash instead of a version tag.

If the standard rule of go modules conflicts with your development mode. Or not intended to be used as a library and does not make any guarantees about the API. So you can’t comply with the specification of "Releasing Modules for v2 or higher" available in the Modules documentation.
Regardless, since it's against one of the design choices of Go, it'll be a bit of a hack. Instead of go get github.com/bblfsh/bblfshd@version-tag, module users need to use this following way to get the bblfsh/bblfshd:
(1) Search for the tag you want (in browser)
(2) Get the commit hash for the tag you want
(3) Run go get github.com/bblfsh/bblfshd@commit-hash
(4) Edit the go.mod file to put a comment about which version you actually used
This will make it difficult for module users to get and upgrade bblfsh/bblfshd.

[*] You can see who will be affected here: [1 module users, e.g., src-d/engine-deprecated]
https://github.com/src-d/engine-deprecated/blob/master/go.mod#L9

Summary

You can make a choice to fix DM issues by balancing your own development schedules/mode against the affects on the downstream projects.

For this issue, Solution 2 can maximize your benefits and with minimal impacts to your downstream projects the ecosystem.

References

@KateGo520
Copy link
Author

@ncordon @dennwc Could you help me review this issue? Thx :p

@grumbach
Copy link
Member

Hi @KateGo520, thank you very much for this issue! I agree with you, this is a pretty high severity one. As you suggested @ncordon and @dennwc probably know what's best to do.
As a backup plan in case they're unavailable, I'd gladly accept a PR with your favorite fix.
I hope you are doing well in these times of crisis.

@KateGo520
Copy link
Author

@grumbach Thank you for your reply.

@kuba--
Copy link
Member

kuba-- commented Jul 25, 2020

IMO, it would be totally fine to update/fix go.mod file and release v2.17.0

@sxh519 sxh519 linked a pull request Aug 17, 2020 that will close this issue
@KateGo520
Copy link
Author

@grumbach A PR with your favorite fix here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants