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

Keep version in sync between MODULE.bazel and version.bzl #386

Open
tetromino opened this issue Aug 30, 2022 · 8 comments
Open

Keep version in sync between MODULE.bazel and version.bzl #386

tetromino opened this issue Aug 30, 2022 · 8 comments
Assignees
Labels
P3 We're not considering to work on this, but happy to review a PR. (No assignee) type: feature request

Comments

@tetromino
Copy link
Collaborator

Reminder to myself: after merging #385, we will need some sort of a diff test to keep the module version and the version.bzl version in sync; neither file can load the other - MODULE.bazel prohibits load statements.

@tetromino tetromino added type: feature request P3 We're not considering to work on this, but happy to review a PR. (No assignee) labels Aug 30, 2022
@tetromino tetromino self-assigned this Aug 30, 2022
@tetromino
Copy link
Collaborator Author

tetromino commented Sep 8, 2022

The natural way to do so would be to extract version from MODULE.bazel via buildozer:

cat MODULE.bazel | buildozer 'print version' '-:bazel_skylib'

Unfortunately, this means we need to depend on buildozer, and while this is easy enough to do via WORKSPACE, it fails with --experimental_enable_bzlmod:

error loading package '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools//api_proto': Unable to find package for @[unknown repo 'rules_proto' requested from @gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools]//proto:defs.bzl: The repository '@[unknown repo 'rules_proto' requested from @gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools]' could not be resolved: Repository '@rules_proto' is not visible from repository '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools'. and referenced by '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools//edit:go_default_library'

I believe that I'm hitting bazel-contrib/rules_go#3265

Alternatively, we could avoid the problem trivially if there were an official buildtools module in the central registery - but it doesn't exist yet.

Current work in progress is sitting at https://github.com/tetromino/bazel-skylib/tree/version_consistency a.k.a. #396

@fmeum
Copy link
Contributor

fmeum commented Sep 9, 2022

@tetromino I just submitted a PR that should add support for go_proto_library to rules_go with Bzlmod: bazel-contrib/rules_go#3283. I manually verified that it can build buildozer.

@fmeum
Copy link
Contributor

fmeum commented Sep 12, 2022

rules_go 0.34.0 is now available in the register and should support go_proto_library.

@tetromino
Copy link
Collaborator Author

rules_go 0.34.0 is now available in the register and should support go_proto_library.

0.34.0 was released in July. I think your fix is in 0.35.0, which isn't in the register yet :)

@fmeum
Copy link
Contributor

fmeum commented Sep 12, 2022

Given the experimental status of rules_go's bzlmod support as well as the BCR, we decided to continuously push updates to it, modifying existing versions if necessary - so 0.34.0 is indeed what you want. That will of course change when the BCR and Bzlmod support in Bazel become more stable.

@tetromino
Copy link
Collaborator Author

Hmm. I've confirmed that 0.34.0 that got downloaded by bazel from BCR into my external/ dir does have the fix, but I'm still hitting the same error - Repository '@rules_proto' is not visible from repository '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools'

ERROR: /private/var/tmp/_bazel_$USER/b2b208390ac65027996afab7ba69d49e/external/gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools/edit/BUILD.bazel:3:11: error loading package '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools//build_proto': Unable to find package for @[unknown repo 'rules_proto' requested from @gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools]//proto:defs.bzl: The repository '@[unknown repo 'rules_proto' requested from @gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools]' could not be resolved: Repository '@rules_proto' is not visible from repository '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools'. and referenced by '@gazelle~0.26.0~go_deps~com_github_bazelbuild_buildtools//edit:go_default_library'
ERROR: Analysis of target '//tests:bazel_skylib_version_consistency_test' failed; build aborted:

@tetromino
Copy link
Collaborator Author

Ah, I now understand the problem: I also need bazel-contrib/bazel-gazelle#1331

Time for git_override.

@fmeum
Copy link
Contributor

fmeum commented Sep 12, 2022

Gazelle 0.26.0 should have the fix, but it was updated in place so you might need to clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering to work on this, but happy to review a PR. (No assignee) type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants