Bazel is fiddly. Projects that compile with one version of Bazel don't work with another, and keeping multiple
versions of Bazel around is a pain. Bazenv solves this problem by managing your Bazel version on a project by project
basis. Bazenv is inspired by jenv
and rbenv
, which solve the same problem for Java and Ruby.
- Bazenv is built with go. To download:
go get -d github.com/salesforce/bazenv/...
- Install Bazenv with
make deps install
. This will buildbazenv
and itsbazel
stub. - Make sure
$GOHOME/bin
is at the beginning of your path. - Install a version of Bazel with
bazenv install <version>
. - Set the global Bazel version with
bazenv global <version>
.
- Use
bazenv install
to download and install any Bazel version on Bazel's Github releases page. - Use
bazenv add
to add an existing Bazel install directory to Bazenv.
- To see all available Bazel versions, use
bazenv list
. - Use
bazenv global
to set the global Bazel version. This version will be used unless specifically overridden with a local version. - Use
bazenv local
to set a local Bazel version for a given directory. This version will be used for all child directories.
- Bazenv stores configuration and all installed Bazel versions in the
~/.bazenv
directory. .bazenv_version
files are used to configure the local Bazel version.- The Bazenv
bazel
shim reads from Bazenv's configuration to locate the correct Bazel binary and execute it.
- Make sure Bazenv's
bazel
shim is before any otherbazel
binary on your path. bazenv doctor
will evaluate your Bazenv environment.