bazel: CI projects are failing with bazel 0.10.0 RC1 due to wrongly identifying the current Bazel version

rules_closure fails to build:

ERROR: /Users/ci/workspace/Global/rules_closure-node=darwin-x86_64/WORKSPACE:6:1: Traceback (most recent call last):

	File "/Users/ci/workspace/Global/rules_closure-node=darwin-x86_64/WORKSPACE", line 6

		closure_repositories()

	File "/Users/ci/workspace/Global/rules_closure-node=darwin-x86_64/closure/repositories.bzl", line 69, in closure_repositories

		_check_bazel_version("Closure Rules", "0.4.5")

	File "/Users/ci/workspace/Global/rules_closure-node=darwin-x86_64/closure/repositories.bzl", line 172, in _check_bazel_version

		fail(("%s requires Bazel >=%s but was...)))

Closure Rules requires Bazel >=0.4.5 but was 0.10.0rc1

ERROR: Error evaluating WORKSPACE file

ERROR: error loading package 'external': Package 'external' contains errors

INFO: Elapsed time: 0.522s

FAILED: Build did NOT complete successfully (0 packages loaded)

The console output is here.

This is blocking the 0.10.0 release (#3958).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 51 (43 by maintainers)

Commits related to this issue

Most upvoted comments

What should projects that use bazel do in the face of this bug? We’re seeing this behavior now that 0.10.0 is out in the wild: https://github.com/PAIR-code/facets/issues/107

If you’re updating bazel-skylib for this check, make sure to update to bazelbuild/bazel-skylib#14. There was a small bug in bazelbuild/bazel-skylib#13 that caused the version check to fail for source builds of Bazel. It shouldn’t affect official releases or RCs though.

Done in: [1], the CL is pending for review and library compliance approval.

The CL above was merged, so that Gerrit job on Bazel-CI should be green again.

@jin @gunan suggested not adding a new dependency for parsing.

I can update https://github.com/bazelbuild/bazel-integration-testing/blob/master/bazel_version.bzl to use @jayconrod’s function, and have that file bundled in bazelbuild/bazel-skylib as the canonical version. What does everyone think?

e.g. in WORKSPACE

load("@bazel_skylib//:lib.bzl", "check_bazel_version")
check_bazel_version("0.5.0")

I propose the function below:

# Parse the bazel version string from `native.bazel_version`.
# For example, "0.10.0-rc1 0123abc"
def _parse_bazel_version(bazel_version):
  for i in range(len(bazel_version)):
    c = bazel_version[i]
    if not (c.isdigit() or c == "."):
      bazel_version = bazel_version[:i]
      break
  return tuple([int(n) for n in bazel_version.split(".")])

Find the first character in the version string which is not a digit or ‘.’, and ignore that character and everything after. Split the remaining string on ‘.’, and convert the pieces to integer.