E:无法找到包 git - EC2 上的 Ubuntu
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12438946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
E: Unable to locate package git - Ubuntu on EC2
提问by gabrtv
Looks to me like there may be a problem with the Ubuntu EC2 mirrors. After a fresh apt-get update, I'm seeting this:
在我看来,Ubuntu EC2 镜像可能存在问题。在新的 apt-get 更新之后,我看到了这个:
$ apt-get install -yq git
E: Unable to locate package git
After a few more apt-get
's, it will often succeed.
再多打几下apt-get
,往往会成功。
回答by Nasser Al-Wohaibi
Update apt-get
packages, run the following command:
更新apt-get
包,运行以下命令:
$ apt-get update
回答by gabrtv
The mirrors still seem to be broken, but I was able to work around the issue with a dumb loop:
镜子似乎仍然坏了,但我能够用一个愚蠢的循环解决这个问题:
# stupid loop to get around ubuntu package mirror problems
for attempt in 1 2 3; do
if [ ! -z "`which git`" ]; then
break
fi
echo "Trying to install git, attempt $attempt"
sudo apt-get update -yq --fix-missing
sudo apt-get install -yq git
done
3 attempts is usually enough to find a working mirror.
3 次尝试通常足以找到一个工作镜像。