Debian – How to fix “apt-get install -f apt-transport-https” error: 404 Not Found

aptdebdebianpackage-management

We have a pair of load balanced managed VMs which install apt-transport-https as part of a startup script.

However recently the servers went into an error state because on startup they could no longer download the version of the package required (1.0.9.8.3) because it is no longer present on the mirror: 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?

Trying the suggestion of --fix-missing does not help.

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

Next I manually downloaded the higher version of apt-transport-https (1.0.9.8.4) bug I was unable to install it directly because of a dependency on 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.

Can anyone help me resolve this problem? Is it as simple as upgrading libapt-pkg4.12? If so, how do I go about that?

EDIT: Also I am unable to run apt-get update … because I haven't got apt-transport-https installed. Which I think they call Catch-22!

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?

This is what my /etc/apt/sources.list looks like:

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

Thank you in advance

Best Answer

I appear to have fixed the issue by symlinking the https dir in /usr/lib/apt/methods to the http dir.

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

Since I don't actually have any https:// sources configured it seems harmless and then when apt-get install apt-transport-https runs it actually overwrites the symlink with the correct files.

Related Question