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

Bzlmod support #3759

Open
aaliddell opened this issue Nov 21, 2023 · 6 comments · May be fixed by #4937
Open

Bzlmod support #3759

aaliddell opened this issue Nov 21, 2023 · 6 comments · May be fixed by #4937

Comments

@aaliddell
Copy link
Contributor

🚀 Feature

At present your Bazel support and dependencies are managed via your WORKSPACE file. Bazel 6 introduced Bzlmod for managing project dependencies using a registry, which helps to solve the transitive dependency problem.

I am attempting to support grpc-gateway under bzlmod here, but both paths I have tried presently do not work (direct plugins and Gazelle). My third option is to maintain a patchset on top of grpc-gateway that fixes dependency loads to work under bzlmod, which really won't be pleasant. Before I do this, are you considering adding Bzlmod support? Looking at what's presently in your WORKSPACE, I don't see any major blockers.

Some useful links:

@johanbrandhorst
Copy link
Collaborator

This sounds like a great idea, but will it break existing users of Bazel? What does the Bazel team recommend maintainers do? We do have existing Bazel users and I don't want to suddenly spring this on them.

CC @achew22, our resident Bazel expert ;)

@aaliddell
Copy link
Contributor Author

It's possible to offer support for both at the same time, but it is understandably more work to do so. Most projects that have published modules have got support for both methods, but personally I am cutting a major release of rules_proto_grpc that drops one and adds the other since WORKSPACE has been a collossal source of pain. There's a helpful project template here that helps automate the release process.

At the moment, bzlmod is an opt-in flag under Bazel 6, but from Bazel 7 (whose release is imminent) bzlmod will be enabled by default. This flag flip won't immediately break things, since in the absence of a MODULE.bazel file, the WORKSPACE is used instead. But the path appears to be that WORKSPACE is on the way out over a long deprecation period.

@johanbrandhorst
Copy link
Collaborator

Thanks for that extra context, I expect we'll want to support both.

@SanjayVas
Copy link

SanjayVas commented Dec 18, 2023

In case it helps, I have a Bazel module for grpc-gateway in my own registry. Note that it depends on the googleapis module in that registry, as that does not have an official module yet.

@lbhdc
Copy link

lbhdc commented Mar 4, 2024

Thanks @SanjayVas, I tried out your modules, and it works great.

For anyone else, to use it I added this to my bazelrc. This registers BCR and @SanjayVas registry.

common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main
common --registry=https://raw.githubusercontent.com/world-federation-of-advertisers/bazel-registry/main

Then I could add these modules to my MODULE.bazel.

bazel_dep(name = "googleapis", version = "0.0.0-bzlmod.1")
bazel_dep(name = "grpc-gateway", version = "2.18.1")

+1 for having bzlmod support directly from grpc-gateway

@SanjayVas
Copy link

This registers BCR and @SanjayVas registry.

I just wanted to give fair warning about using that registry directly. It's only intended to be used by other repos in that organization. There won't be any effort to avoid breaking other users. You may instead want to copy those modules into your own registry.

@AlejoAsd AlejoAsd linked a pull request Nov 12, 2024 that will close this issue
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.

4 participants