问题
I tried following commands but keep getting same error everytime:
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
sudo apt-get update
But the command sudo apt-get install bazel
gives same error every time:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package bazel
How would I be able to install the bazel package?
回答1:
Actually there was a similar problem:
https://askubuntu.com/questions/378558/unable-to-locate-package-while-trying-to-install-packages-with-apt
I tried the answer voted most, and found that there wasn't a bazel package.
So I went to the official website of bazel:
https://docs.bazel.build/versions/master/install-ubuntu.html
I tried the recommended way,"Using Bazel custom APT repository", but got stuck in the 1st step, and I found many similar problems in Google, but nothing helps.
So I tried the 2nd way,"Install using binary installer", thankfully it works!
Here are the steps I copied from it(a little changed):
- Install required packages
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
Download Bazel
Go to Bazel's GitHub releases page.
Download the binary installer bazel-0.7.0-installer-linux-x86_64.sh(the latest version I got). This installer contains the Bazel binary and the required JDK, and can be used even if JDK is already installed.
Note that bazel-0.7.0-without-jdk-installer-linux-x86_64.sh also exists. It is a version without embedded JDK 8. Only use this installer if you already have JDK 8 installed.
Run the installer
chmod +x bazel-0.7.0-installer-linux-x86_64.sh
./bazel-0.7.0-installer-linux-x86_64.sh --user
The --user flag installs Bazel to the $HOME/bin directory on your system and sets the .bazelrc path to $HOME/.bazelrc. Use the --help command to see additional installation options.
Set up your environment
If you ran the Bazel installer with the --user flag as above, the Bazel executable is installed in your $HOME/bin directory. It's a good idea to add this directory to your default paths, as follows:
export PATH="$PATH:$HOME/bin"
You can also add this command to your ~/.bashrc file.
来源:https://stackoverflow.com/questions/45767275/unable-to-install-bazel-on-ubuntu-14-04-using-apt-get