Unable to install bazel on Ubuntu 14.04 using apt-get

喜夏-厌秋 提交于 2020-01-04 07:47:07

问题


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):

  1. Install required packages

    sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python

  2. 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.

  3. 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.

  4. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!