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

[Bug]: It is impossible to bump compatibility level if you mutually depend on another module. #2232

Closed
aiuto opened this issue Jun 11, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@aiuto
Copy link
Contributor

aiuto commented Jun 11, 2024

What happened?

Trying to add rules_pkg/1.0.0, which bumps compatibility_level.
Presubmit fails:

So, the obvious problem with enforcing this

  • If I bump protobuf to depend on the new version, that will fail because this is not submitted yet.
  • If I include protobuf in rules_pkg/MODULE.bazel, I suspect that won't help, because we'll still be at mismatched levels.

Version

module(
    name = "rules_pkg",
    version = "1.0.0",  # Must sync with version.bzl.
    compatibility_level = 2,
    repo_name = "rules_pkg",
)

# Do not update to newer versions until you need a specific new feature.
bazel_dep(name = "rules_license", version = "0.0.7")
bazel_dep(name = "rules_python", version = "0.31.0")
bazel_dep(name = "bazel_skylib", version = "1.4.2")

# Only for development
bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True)
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)

# Find the system rpmbuild if one is available.
find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True)
use_repo(find_rpm, "rules_pkg_rpmbuild")

register_toolchains(
    "@rules_pkg_rpmbuild//:all",
    dev_dependency = True,
)

How to reproduce

https://github.com/bazelbuild/bazel-central-registry/pull/2180

Any other information?

No response

@aiuto aiuto added the bug Something isn't working label Jun 11, 2024
@aiuto
Copy link
Contributor Author

aiuto commented Jun 11, 2024

Possible solution:

  • Allow bazel_dep(min_version="...", [max_version="..."])
  • This would just make sure we get any version of the package at least min_version.
  • and no more than max_version

rules_proto only cares about the most backwards portable pieces of rules_pkg, so it would set min_version="0.1.0". Then it could pick up either the 0.x series or the 1.x series.

Another solution:
Loops in module dependencies that come back to different compatibility levels are allowed, with a warning message.

Or that the compatibilty_level of anything specified in the project MODULE.bazel wins in favor of any explicit versions called out transitively. Maybe that happens in general, but not if the compat level is in the module() stanza.

@Wyverald
Copy link
Member

  • Allow bazel_dep(min_version="...", [max_version="..."])

We already have this: https://bazel.build/rules/lib/globals/module#bazel_dep.max_compatibility_level

@aiuto
Copy link
Contributor Author

aiuto commented Jun 11, 2024

OK. That is half the battle. But the problem remains that I have to modify rules_proto to push my new version of rules_pkg. That is a lot of friction.

@Wyverald
Copy link
Member

Well, yes... I don't know what your expected outcome is. If you upload a version of rules_pkg which transitively depend on some rules_proto, you need to at least depend on a rules_proto that can work with the rules_pkg you're uploading. That seems reasonable to me.

At the end of the day, incrementing the compatibility level of your module is a big deal. Bazel's default here is to be safe and disallow multiple compatibility levels to coexist -- the other alternatives are bad in their own ways.

aiuto added a commit to aiuto/rules_pkg that referenced this issue Jul 9, 2024
aiuto added a commit to bazelbuild/rules_pkg that referenced this issue Jul 9, 2024
* Revert compatibility_level back to 1 so we can push to BCR.

See bazelbuild/bazel-central-registry#2232
for discussion.

* update version#
@Wyverald Wyverald closed this as not planned Won't fix, can't repro, duplicate, stale Jul 23, 2024
@Wyverald
Copy link
Member

Closing as this doesn't seem actionable -- we can reopen if you have other suggestions.

@aiuto
Copy link
Contributor Author

aiuto commented Jul 24, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants