我尝试了以下命令,但是每次都会出现相同的错误:
I tried following commands but keep getting same error everytime:
echo "deb [arch=amd64] storage.googleapis/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list curl bazel.build/bazel-release.pub.gpg | sudo apt-key add - sudo apt-get update但是命令sudo apt-get install bazel每次都会给出相同的错误:
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我将如何安装bazel软件包?
How would I be able to install the bazel package?
推荐答案实际上存在一个类似问题:
askubuntu/questions/378558/在尝试使用apt安装软件包时无法定位软件包
我尝试了投票得最好的答案,发现没有打包包.
I tried the answer voted most, and found that there wasn't a bazel package.
所以我去了bazel的官方网站:
So I went to the official website of bazel:
docs.bazel.build/versions/master/install -ubuntu.html
我尝试了推荐的方法使用Bazel自定义APT存储库",但陷入了第一步,在Google中发现了许多类似的问题,但是没有帮助.
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):
sudo apt-get install pkg-config zip g ++ zlib1g-dev解压缩python
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
下载Bazel
Download Bazel
转到Bazel的 GitHub版本页面.
下载二进制安装程序bazel-0.7.0-installer-linux-x86_64.sh(我得到的最新版本).此安装程序包含Bazel二进制文件和必需的JDK,即使已安装JDK也可以使用.
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.
请注意,还存在bazel-0.7.0-without-jdk-installer-linux-x86_64.sh.它是不带有嵌入式JDK 8的版本.仅在已经安装JDK 8的情况下,才使用此安装程序.
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.
运行安装程序
chmod + x bazel-0.7.0-installer-linux-x86_64.sh
chmod +x bazel-0.7.0-installer-linux-x86_64.sh
./bazel-0.7.0-installer-linux-x86_64.sh --user
./bazel-0.7.0-installer-linux-x86_64.sh --user
-user 标志将Bazel安装到系统上的 $ HOME/bin 目录,并将 .bazelrc 路径设置为 $ HOME/.bazelrc .使用-help 命令查看其他安装选项.
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.
设置您的环境
如果使用上面的-user 标志运行Bazel安装程序,则Bazel可执行文件将安装在 $ HOME/bin 目录中.将此目录添加到默认路径是一个好主意,如下所示:
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"
export PATH="$PATH:$HOME/bin"
您还可以将此命令添加到您的〜/.bashrc 文件中.
You can also add this command to your ~/.bashrc file.
更多推荐
无法使用apt
发布评论