Skip to content

Commit

Permalink
Switch from bazeliskrc to bazelversion (#4612)
Browse files Browse the repository at this point in the history
The only documentation I can find for `.bazelversion` is in
https://github.com/bazelbuild/bazelisk/blob/master/README.md. However,
`bazel` will error out if it doesn't match the `.bazelversion`. For
example:

```
╚╡/usr/bin/bazel build :all
ERROR: The project you're trying to build requires Bazel 7.3.0 (specified in [elided]/carbon-lang/.bazelversion), but it wasn't found in /usr/bin.
```

Switching to this because the `MODULE.bazel` requires tighter version
pinning in order to avoid churn, and this should help catch mistakes
early.

In `MODULE.bazel`, demote mention of the version issue because it should
only really occur now when the version is being deliberately changed, so
the connection should be more apparent.
  • Loading branch information
jonmeow authored Dec 3, 2024
1 parent 74dcd1f commit 0c2ed1b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
7 changes: 0 additions & 7 deletions .bazeliskrc

This file was deleted.

1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.3.0
16 changes: 2 additions & 14 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@
`MODULE.bazel.lock` may change locally when `bazel` is executed. This means one
of:
1. `MODULE.bazel` is changing.
1. An input is changing, typically `MODULE.bazel` or `.bazelversion`.
- Running `bazel mod deps` provides a canonical update to
`MODULE.bazel.lock`; include the changes.
- GitHub test actions may also identify platform-specific lockfile
updates.
2. The `bazel` version doesn't match the version used to generate the
`MODULE.bazel.lock`.
- Bazel releases can change the lock file contents.
- We use Bazelisk in order to keep everyone using the same version:
https://bazel.build/install/bazelisk
- Developers are encouraged to alias `bazel` to `bazelisk` for
ease-of-use; some setups, like Homebrew, will include that with a
`bazelisk` install.
- Contribution tools documentation includes `bazelisk` setup:
https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/contribution_tools.md
- Make sure `bazelisk --version` (or `bazel --version`) matches the
version in `.bazeliskrc`.
3. The host platform hasn't yet been added to the lock file.
2. The host platform hasn't yet been added to the lock file.
- Platforms tested with GitHub actions are kept up-to-date. Other
platforms may fall out of sync due to `bazel` or dependency changes,
and should be updated with a PR the same way a platform is added.
Expand Down
2 changes: 1 addition & 1 deletion docs/project/contribution_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ These tools are essential for work on Carbon.
- Main tools
- [Bazel](https://www.bazel.build/)
- [Bazelisk](https://docs.bazel.build/versions/master/install-bazelisk.html):
Downloads and runs the [configured Bazel version](/.bazeliskrc).
Downloads and runs the [configured Bazel version](/.bazelversion).
- [Clang](https://clang.llvm.org/) and [LLVM](https://llvm.org/)
- NOTE: Most LLVM 14+ installs should build Carbon. If you're having
issues, see
Expand Down

0 comments on commit 0c2ed1b

Please sign in to comment.