bazel installation via the bazelisk method
Here is how I install bazel. I use this installation method on all of my machines. I do not think it is practical to go about this any other way. It is implied in all of my writings about bazel.
Why?
Sadly, bazel versions are wildly incompatible between major version releases. This means that as you encounter projects using newer and newer bazel versions, you may encounter random compatibility issues.
To work around that, bazelisk will recognize the version of bazel that your build needs, and will download and run the correct version for you automatically.
How?
I install bazelisk, and let it download and use the appropriate bazel version for each project.
Recipe
- Download
bazeliskfor your platform, and place it somewhere on your machine’s drive. - Create a symlink named
bazelsomewhere in your$PATH, pointing to the just downloadedbazelisklibrary. - Add the
.bazelversionfile in each project, to fix thebazelversion for that project. - If you store your project on Github, ensure you are using the correct
bazelversion in your workflows.