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 buildbazenvand itsbazelstub. - Make sure
$GOHOME/binis 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 installto download and install any Bazel version on Bazel's Github releases page. - Use
bazenv addto add an existing Bazel install directory to Bazenv.
- To see all available Bazel versions, use
bazenv list. - Use
bazenv globalto set the global Bazel version. This version will be used unless specifically overridden with a local version. - Use
bazenv localto 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
~/.bazenvdirectory. .bazenv_versionfiles are used to configure the local Bazel version.- The Bazenv
bazelshim reads from Bazenv's configuration to locate the correct Bazel binary and execute it.
- Make sure Bazenv's
bazelshim is before any otherbazelbinary on your path. bazenv doctorwill evaluate your Bazenv environment.