公式ではbazel4のインストールまでしか記載されてなかったので記録
https://docs.bazel.build/versions/5.4.1/install-redhat.html
今回はgithubからインストール用のスクリプトをダウンロード、実行してインストールを行なっていきます
version
# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
unzip, wgetがインストール済みであること
手順
まず、githubから仕様したいバージョンを選び、Assetsからbazel-*-installer-linux-x86_64.sh
のリンクをコピーしておきます(ちなみにMacOSだと*-installer-darwin-x86_64.sh
)
https://github.com/bazelbuild/bazel/releases
例としてバージョン7.2.0を選択した場合
https://github.com/bazelbuild/bazel/releases/download/7.2.0/bazel-7.2.0-installer-linux-x86_64.sh
インストーラーをダウンロードして実行します
# wget https://github.com/bazelbuild/bazel/releases/download/7.2.0/bazel-7.2.0-installer-linux-x86_64.sh
# chmod +x bazel-7.2.0-installer-linux-x86_64.sh
# ./bazel-7.2.0-installer-linux-x86_64.sh
Bazel installer
---------------
Bazel is bundled with software licensed under the GPLv2 with Classpath exception.
You can find the sources next to the installer on our release page:
https://github.com/bazelbuild/bazel/releases
#
## Build information
- [Commit](https://github.com/bazelbuild/bazel/commit/241a192)
which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
Uncompressing.......
Bazel is now installed!
Make sure you have "/usr/local/bin" in your path.
For bash completion, add the following line to your ~/.bashrc:
source /usr/local/lib/bazel/bin/bazel-complete.bash
For fish shell completion, link this file into your
/root/.config/fish/completions/ directory:
ln -s /usr/local/lib/bazel/bin/bazel.fish /root/.config/fish/completions/bazel.fish
See http://bazel.build/start to start a new project!
これでインストールが完了
記載のように/usr/local/bin
にパスが通っていればbazelコマンドが使えるようになっているはずです
# bazel --version
bazel 7.2.0
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
通っていない場合は以下で通します
# export PATH=$PATH:/usr/local/bin