Installing bazel 0.24.1 from Source Code
- Install the system dependencies. Ubuntu and CentOS are used as examples.
- Ubuntu 18.04 x86_64:
apt-get install build-essential openjdk-11-jdk python zip unzip
- CentOS 8.3 aarch64 environment:
yum install java-11-openjdk-devel.aarch64 yum install java-11-openjdk.aarch64 yum groupinstall 'Development Tools' yum install zip
If java-11-openjdk fails to be installed, manually install it by referring to Installing java-11-openjdk1 Manually.
- Ubuntu 18.04 x86_64:
- Set environment variables.
- Open the .bashrc file.
vim ~/.bashrc
- Add the java-11-openjdk installation path to the file. (The path in the following command is simply an example. Replace it with the actual installation path.)
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH
- Run the :wq! command to save the file and exit.
- Run the following command for the environment variables to take effect:
source ~/.bashrc
- Open the .bashrc file.
- Download the bazel compressed source package and upload it to any directory on the server.
- Go to the directory where the source package is stored and perform compilation and installation.
- Decompress the downloaded bazel source package.
unzip bazel-0.24.1-dist.zip -d bazel-0.24.1-dist
- Go to the decompressed folder, and run the following configuration, compilation, and installation commands:
cd bazel-0.24.1-dist/ env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh cp output/bazel /usr/local/bin
- Decompress the downloaded bazel source package.
- Validate your installation.
After the installation is complete, run the following command to check the version:
bazel --version
Parent topic: Sample Reference