如何修复“apt-get install -f apt-transport-https”错误:404 Not Found?

如何修复“apt-get install -f apt-transport-https”错误:404 Not Found?

我们有一对负载平衡的托管虚拟机,它们安装 apt-transport-https 作为启动脚本的一部分。

然而,最近服务器进入错误状态,因为启动时它们无法再下载所需的软件包版本(1.0.9.8.3),因为它不再存在于镜像上:http://httpredir.debian.org/debian/pool/main/a/apt

root@validator-dev-group-c2v4:/etc# apt-get install -f apt-transport-https
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
Need to get 138 kB of archives.
After this operation, 195 kB of additional disk space will be used.
Err http://httpredir.debian.org/debian/ jessie/main apt-transport-https amd64 1.0.9.8.3
  404  Not Found
E: Failed to fetch http://httpredir.debian.org/debian/pool/main/a/apt/apt-transport-https_1.0.9.8.3_amd64.deb  404  Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

尝试的建议--fix-missing没有帮助。

root@validator-dev-group-c2v4:/etc# apt-get install --fix-missing apt-transport-https
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
Need to get 138 kB of archives.
After this operation, 195 kB of additional disk space will be used.
Err http://httpredir.debian.org/debian/ jessie/main apt-transport-https amd64 1.0.9.8.3
  404  Not Found
E: Failed to fetch http://httpredir.debian.org/debian/pool/main/a/apt/apt-transport-https_1.0.9.8.3_amd64.deb  404  Not Found
E: Internal Error, ordering was unable to handle the media swap

接下来我手动下载了更高版本的 apt-transport-https (1.0.9.8.4),但由于依赖 libapt-pkg4.12,我无法直接安装它。

root@validator-dev-group-c2v4:/home/<user># sudo dpkg -i ./apt-transport-https_1.0.9.8.4_amd64.deb 
Selecting previously unselected package apt-transport-https.
(Reading database ... 26719 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_1.0.9.8.4_amd64.deb ...
Unpacking apt-transport-https (1.0.9.8.4) ...
dpkg: dependency problems prevent configuration of apt-transport-https:
 apt-transport-https depends on libapt-pkg4.12 (>= 1.0.9.8.4); however:
  Version of libapt-pkg4.12:amd64 on system is 1.0.9.8.3.

谁能帮我解决这个问题?就像升级libapt-pkg4.12那么简单吗?如果是这样,我该怎么办?

编辑:我也无法运行apt-get update...因为我还没有apt-transport-https安装。我想他们称之为第二十二条军规!

root@validator-dev-group-c2v4:/home/<user># apt-get update
E: The method driver /usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?

这就是我的/etc/apt/sources.list样子:

deb http://httpredir.debian.org/debian/ jessie main
deb-src http://httpredir.debian.org/debian/ jessie main
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main
deb http://httpredir.debian.org/debian/ jessie-updates main
deb-src http://httpredir.debian.org/debian/ jessie-updates main

先感谢您

答案1

我似乎已经通过将https目录符号链接/usr/lib/apt/methodshttp目录来解决该问题。

root@validator-dev-group-c2v4:~# cd /usr/lib/apt/methods
root@validator-dev-group-c2v4:/usr/lib/apt/methods# ln -s http https

由于我实际上没有https://配置任何源,因此它看起来无害,然后在apt-get install apt-transport-https运行时它实际上会用正确的文件覆盖符号链接。

答案2

一般的解决方案是更新apt的索引,以便它知道哪些版本可用:

apt-get update

然后安装apt-transport-https将在存储库中找到合适的版本。

每次要安装新软件包时都应该执行此操作,除非您最近完成过此操作(通常是在最后一天内)。

apt-get update如果您因为需要而无法运行apt-transport-https,您可以通过(暂时)将https://URL 切换到http://in /etc/apt/sources.list(也许还有文件 in /etc/apt/sources.list.d)来解决问题。使用 HTTP 下载软件包不会降低您的安全性,只会降低您的机密性(您的计算机和存储库之间的系统可以看到您正在检索哪些软件包)。

如果不起作用,您可以尝试选择一个特定的镜像,这应该避免任何重定向到 HTTPS URL;看着那(这列表,选择一个靠近您的镜子并使用它,而不是httpredir.debian.org在您的来源中。

在您的具体情况下,手动下载所需的包(并将它们与您的安装脚本一起发送以便它们继续工作)可能会更简单:apt-transport-httpslibapt-pkg4.12以及其他必要的东西。 (您最终可能需要apt同时升级。)

答案3

文件夹内有一堆文本文件,其中包含下载 apt 包的 URL/etc/apt/

这些文本文件的示例名称可以是: /etc/apt/sources.list.d/mssql-release.list如果您尝试从 Microsoft 服务器安装软件包。

其内容/etc/apt/sources.list.d/mssql-release.list可以是:

deb [arch=amd64] https://packages.microsoft.com/debian/8/prod jessie main

有时,文件内容*.list是通过 HTTPS 而不是 HTTP 下载的,但如果您尚未安装该软件包apt-transport-https,您将无法更新 apt-get 软件包管理器。它会不断警告您无法使用 HTTPS 源。

然后您可以做的是使用 HTTPS 链接找到有问题的*.list文件并将其重命名: sudo mv /etc/apt/sources.list.d/mssql-release.list /etc/apt/sources.list.d/mssql-release.list1 sudo apt-get update sudo apt-get install -y apt-transport-https sudo mv /etc/apt/sources.list.d/mssql-release.list1 /etc/apt/sources.list.d/mssql-release.list sudo apt-get update 然后您应该能够继续执行您希望执行的任何 apt-get 操作。

得出这个答案的参考 https://community.c9.io/t/installing-apt-transport-https-issue/10994/10

答案4

您可以执行以下命令:

apt-get update && apt-get -y install apt-transport-https curl

相关内容