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

V3 breaks "go install" and "go run" #287

Closed
alfa-alex opened this issue Aug 29, 2024 · 3 comments
Closed

V3 breaks "go install" and "go run" #287

alfa-alex opened this issue Aug 29, 2024 · 3 comments
Assignees

Comments

@alfa-alex
Copy link
Contributor

Up to V2, it was very handy to be able to run, e.g., the schemagen tool with go run (go run github.com/scylladb/gocqlx/v2/cmd/schemagen@latest) or to install it with go install.

Since V3, this is no longer possible, as go would complain:

go: github.com/scylladb/gocqlx/v3/cmd/schemagen@latest (in github.com/scylladb/gocqlx/[email protected]):
        The go.mod file for the module providing named packages contains one or
        more replace directives. It must not contain directives that would cause
        it to be interpreted differently than if it were the main module.

This is specified in golang/go#40276:

If that module has a go.mod file, it must not contain directives that
would cause it to be interpreted differently if the module were the main
module. In particular, it must not contain replace or exclude
directives.

(A longer discussion about this can be found in this issue.)

Thus, the reason for this to occur in the case of gocqlx is the replace directive that was added in v3:

replace github.com/gocql/gocql => github.com/scylladb/gocql v1.14.0

I want to raise awareness of this, as the ability to run schemagen with go run (or install it with go install) has been very useful to me.

Unfortunately, I cannot propose an immediate mitigation of this issue (other than replacing all imports to use the scylladb/gocql module directly).

@sylwiaszunejko
Copy link
Collaborator

Unfortunately for now there is no way to use scylladb/gocql in the imports, see the discussion here: scylladb/gocql#161. Changing module name for scylladb/gocql is a breaking change so it would require major release in scylladb/gocql repo, but this would not happen soon, here is the issue for changes that require new version release scylladb/gocql#232.

Unfortunately I do not have any quick workaround to make using go install possible @dkropachev any thoughts?

@dkropachev
Copy link
Collaborator

@alfa-alex , Thanks for bringing this to our attention, unfortunately, it won't go away until scylladb/gocql#232 is merged and we need at least a year to make it happen.
Luckily there is a workaround:

git clone [email protected]:scylladb/gocqlx.git`
cd gocqlx/cmd/schemagen/
go install .

@dkropachev
Copy link
Collaborator

I am closing it, but feel free to ask more questions or even reopen it.

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

No branches or pull requests

3 participants