Skip to content

docs: use .bazelversion for tutorial Bazel project #2312

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexTereshenkov
Copy link

@AlexTereshenkov AlexTereshenkov commented Jun 22, 2025

bazelisk is the recommended launcher for Bazel and is likely to be used by default by many users.

If a .bazelversion file exists in the current directory or recursively any parent directory, it will read the file and use the version specified in it (see the bazelisk docs). However, the tutorial directory is a workspace on it's own so it defaults to the official latest Bazel release.

Based on my tests

console output
$ bazel build //lib:booleans    
Starting local Bazel server (8.2.1) and connecting to it...
ERROR: Traceback (most recent call last):
        File "/home/alexey/.cache/bazel/_bazel_alexey/54830c7a3940282aa7cd026da0133683/external/rules_sh+/sh/posix.bzl", line 11, column 55, in <toplevel>
                load("@bazel_tools//tools/cpp:lib_cc_configure.bzl", "get_cpu_value")
Error: file '@bazel_tools//tools/cpp:lib_cc_configure.bzl' does not contain symbol 'get_cpu_value'

the tutorial project is not compatible with the latest Bazel version, so I believe it would be a reasonable precaution to match the supported version to what we have for the actual rules workspace. If the tutorial reader doesn't use bazelisk, they would at least get an indication of the compatible version so that they can ensure they are using the right version.

A follow-up work would be modernize the codebase to build it using a more modern Bazel version, if desired.

@avdv
Copy link
Member

avdv commented Jun 25, 2025

Thank you @AlexTereshenkov!

I think adding a .bazelversion is a bit too restrictive for a ruleset usually, since we don't want to constrain Bazel to a specific version -- it should also work with older versions and using Bazel 7. This is especially important here, since we test the tutorial on CI with nixpkgs here:

buildAndTest "../tutorial"

and the nixpkgs package collection does not always have the specific Bazel version available.

Might be better to use a .bazeliskrc file instead, and set USE_BAZEL_VERSION to 6.x.

Also, it's interesting that CI failed building the examples on Windows with Bazel 6 which should not be effected by this change at all.

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 this pull request may close these issues.

2 participants