Search code examples
bazel

Are there any tools for migrating old bazel workspace into latest version bazel


I have an existing bazel project which can be compiled successfully by bazel v0.5.3. Since the plugin for clion only support bazel 0.24.0+ , I update my bazel into the latest version. However clion tells "ERROR: Error evaluating WORKSPACE file", when loading the project into clion.

Are there any approach to update old bazel project?


Solution

  • Bazelisk provides a --strict and --migrate flag that can help you:

    USE_BAZEL_VERSION=0.24.0 bazelisk --strict build //...
    

    --strict enables all incompatible flags and helps you to identify upgrade problems.

    If --strict fails you should try --migrate. It enables incompatible flags step by step and gives you a report of the incompatible flags that lead to a build problem:

    USE_BAZEL_VERSION=0.24.0 bazelisk --migrate build //...
    

    Take also a look at the documentation about Backward Compatibility:

    When we introduce an incompatible change, we try to make it easier for Bazel users to update their code. We do this by means of migration windows and migration recipes.

    Migration window is one or more release of Bazel during which a migration from old functionality to new functionality is possible, according to a migration recipe.

    During the migration window, both the old functionality and the new functionality are available in the Bazel release. For every incompatible change, we provide a migration recipe that allows updating the user code (BUILD and .bzl files, as well as any Bazel usage in scripts, usage of Bazel API and so on) in such a way that it works simultaneously without any flags with old and new functionality.