sudo apt-get update
时,都会显示这个错误:W: Failed to fetch http://ppa.launchpad.net/ 404 Not Found
怎么修复这些错误?
sudo apt-get update
时,都会显示这个错误:W: Failed to fetch http://ppa.launchpad.net/ 404 Not Found
跳到这个答案底部以获取在Ubuntu 15.04之前的所有Ubuntu版本上删除有问题软件源的脚本化方法
404或未找到错误消息是一个HTTP标准响应代码,表示客户端能够与服务器通信,但服务器无法找到所请求的内容。
当用户尝试访问损坏或失效链接时,网站托管服务器通常会生成"404 - 页面未找到"的网页。
通常,主要有三个方面导致更新管理器
中出现这些错误。
PPA通常保存在以下两个位置之一
/etc/apt/sources.list
/etc/apt/sources.list.d/
目录下,例如webupd8team-jupiter-natty.list
这个列表文件通常包含:
deb http://ppa.launchpad.net/webupd8team/jupiter/ubuntu oneiric main
# deb-src http://ppa.launchpad.net/webupd8team/jupiter/ubuntu oneiric main
在文本行的前面加上#
表示该行是注释,不会被软件包管理器检查。
通常情况下,如果您从终端运行sudo apt-get update
或者在点击刷新按钮后,在更新管理器中单击详细信息按钮,您将看到以下错误:
如果 404 错误是由于在 /etc/apt/sources.list
中添加了一个额外的软件源导致的,那么可以在行首添加 #
字符注释掉有问题的软件源。
gksu gedit /etc/apt/sources.list
这里是关于更新管理器的错误报告,以解决这个问题:
如果您在没有PPA的情况下遇到这些问题,请查看以下问题:这是一个用于自动删除所有404未找到的PPA的脚本。将下面的代码复制并粘贴到一个文件中,并将其命名为ppa-remove
。
#!/bin/bash
sudo rm /tmp/update.txt
tput setaf 6
echo "Initializing.. Please Wait"
sudo apt-get update >> /tmp/update.txt 2>&1
awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt
awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt
sort -u /tmp/awk1.txt > /tmp/awk2.txt
tput sgr0
if [ -s /tmp/awk2.txt ]; then
tput setaf 1
printf "PPA's going to be removed\n%s\n" "$(cat /tmp/awk2.txt)"
tput sgr0
while read -r line; do
echo "sudo add-apt-repository -r ppa:$line"
done < /tmp/awk2.txt > out
bash out
else
tput setaf 1
echo "No PPA's to be removed"
tput sgr0
fi
sudo chmod +x ppa-remove
ppa-remove
文件复制并粘贴到/usr/bin
目录中,这样您就可以从任何地方访问它。
sudo ppa-remove
[ -f /tmp/update.txt ] && sudo rm /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait" || echo "No update file"
sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; uniq /tmp/awk1.txt > /tmp/awk2.txt
sudo apt-get update >> /tmp/update.txt 2>&1;
将命令sudo apt-get update
的标准输出和错误输出都写入文件/tmp/update.txt
。
awk '( /W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt;
Awk在文件/tmp/update.txt
中搜索包含W:
、launchpad
、404
的行。如果找到了这样的行,它会在该行中显示(标准输出)从第26个位置开始的所有字母。然后将此标准输出重定向(写入)到文件/tmp/awk.txt
。
例如:
W: Failed to fetch http://ppa.launchpad.net/pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages 404 Not Found
http://ppa.launchpad.net/pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages
在第五列中从第26个字符开始 - pitti/postgresql/ubuntu/dists/saucy/main/binary-i386/Packages
上述行已存储到/tmp/awk.txt
文件中。现在执行下一个命令,awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt;
awk
找出以分隔符 /
连接的列1和列2,这些列1和列2来自于 /tmp/awk.txt
文件,并将标准输出重定向到 /tmp/awk1.txt
文件。
现在 /tmp/awk1.txt
文件包含了一行 pitti/postgresql
。
uniq /tmp/awk1.txt > /tmp/awk2.txt
如果有两行相同,unique
命令只显示(stdout)一行。那一行被写入到 /tmp/awk2.txt
中。最后,/tmp/awk2.txt
包含了唯一的PPA名称。
tput sgr0
这个命令将终端文本的颜色改为白色。
最后,if
条件语句将被执行。if [ -s /tmp/awk2.txt ]
检查/tmp/awk2.txt文件是否存在内容。如果是,则从/tmp/awk2.txt
中取出第一行,并执行sudo add-apt-repository -r ppa:$line
命令。它会一直执行到最后一行。
如果没有内容,则表示没有内容可移除。所以它会显示"没有PPA需要移除"。
quantal
)提供软件包。quantal
目录丢失了,因此你会收到404 Not Found Error Messages
。以下是您在wdt-main
PPA收到的错误信息:
W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/source/Sources 404 Not Found
, W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/binary-amd64/Packages 404 Not Found
, W:Failed to fetch http://ppa.launchpad.net/petrakis/wdt-main/ubuntu/dists/quantal/main/binary-i386/Packages 404 Not Found
http://ppa.launchpad.net/petrakis/
并深入查看导致错误的链接。您将能够看到实际问题是什么。sudo rm /etc/apt/sources.list.d/ppaname-ppa-$(lsb_release -sc).list*
/etc/apt/sources.list
中检查了一些,但不知道还要看/etc/apt/sources.list.d/
。谢谢。 - rusty如果你真的需要来自那个仓库的软件包,你可以使用旧版本的镜像。
然而,请注意,并非所有旧版本都与你的主要软件包仓库向后兼容;其中一些会与你的主要软件包仓库发生冲突。
当发生冲突时,你唯一能做的就是从源代码构建或等待提供者发布适用于你的Ubuntu版本的仓库。我们无法确定软件包提供者何时会为我们的版本发布他们的软件包,所以你需要负责检查他们的仓库是否适用于你的版本。
这适用于任何基于Debian的仓库。然而,并不能保证成功。
sudo apt-get update
,结果完美运行。 - Shashanth/etc/apt/sources.list
中。
Sources: https://gist.github.com/rohitrawat/60a04e6ebe4a9ec1203eac3a11d4afc1
那拯救了我的Linux系统。> 你的资源被搞乱或损坏了,但我们可以制作一个新的清单。
打开终端并输入
sudo rm /etc/apt/sources.list
sudo rm /etc/apt/sources.list.d/ppaname-ppa-$(lsb_release -sc).list*
sudo apt-get update && upgrade