5

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

8
  • Have you run apt-get update recently? You should have an updated list of what's available from the repositories, before you try to install any given package. 404 is likely happening because you're trying to install a version of the package that is no longer on the repository servers. Jan 20, 2017 at 16:21
  • 1
    Good question. I forgot to mention this, so I'll edit the question. I can't run apt-get update because I haven't got apt-transport-https installed!!! A nice Catch-22 Jan 20, 2017 at 16:27
  • 1
    Indeed, perhaps the redirector is sending you to an HTTPS mirror... Jan 20, 2017 at 16:42
  • 2
    Renaming the http to https in /usr/lib/apt/methods/ solved my problem. May 26, 2017 at 8:57
  • 1
    Thank you @Bethwel Too, this has solved an issue on the now defunct C.H.I.P. Mar 17, 2019 at 14:43

6 Answers 6

20

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.

3
  • 1
    This is actually a good idea. Thank you for posting your solution.
    – senfo
    Apr 25, 2018 at 13:04
  • 1
    Awesome trick, worked like a charm!
    – antisa
    Oct 12, 2021 at 9:16
  • 1
    use $ sudo ln -s http https, if the currently logged in user is not root.
    – xgqfrms
    Apr 19 at 14:19
7

The general solution is to update apt's indexes so it knows which versions are available:

apt-get update

Then installing apt-transport-https will find the appropriate versions on the repositories.

You should do this every time you want to install a new package, unless you've done it recently (within the last day typically).

If you can't run apt-get update because it needs apt-transport-https, you can fix things by (temporarily) switching your https:// URLs to http:// in /etc/apt/sources.list (and perhaps files in /etc/apt/sources.list.d). Using HTTP to download packages doesn't reduce your security, it only reduces your confidentiality (systems between your computer and the repositories can see what packages you're retrieving).

If that doesn't work, you can try picking a specific mirror, which should avoid any redirections to HTTPS URLs; look at the list, pick a mirror close to you and use that instead of httpredir.debian.org in your sources.

In your specific case it may well be simpler to manually download the required packages (and ship them alongside your setup scripts so that they continue working): apt-transport-https, libapt-pkg4.12 and whatever else is necessary. (You may end up needing to upgrade apt at the same time.)

4
  • 4
    I can't run apt-get update because I haven't got apt-transport-https installed! Jan 20, 2017 at 16:28
  • Ah yes, see my update. Jan 20, 2017 at 16:29
  • None of the URLs in either sources.list or sources.list.d are HTTPS. Jan 20, 2017 at 16:42
  • OK, you could try another mirror, or just manually download everything. Jan 20, 2017 at 16:47
3

There are a bunch of text files containing the URL for downloading apt packages within the folder /etc/apt/

Example name for those text files can be: /etc/apt/sources.list.d/mssql-release.list if you try to install packages from a Microsoft server.

And the content of /etc/apt/sources.list.d/mssql-release.list could be :

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

Sometimes the content from *.list files is downloaded via HTTPS instead of HTTP but if you have not installed the package apt-transport-https, you wouldn't be able to update your apt-get package manager. It will keep warning you about not being able to use the HTTPS sources.

What you can do then is to locate the offending *.list file(s) with HTTPS links and rename it: 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 Then you should be able to proceed with whatever apt-get operations you wish to perform.

Reference for coming up with this answer https://community.c9.io/t/installing-apt-transport-https-issue/10994/10

1
  • This is what allowed me to unbreak our entire companies build process when a docker image pointing to an old mono repo stopped working. RUN find /etc/apt/sources.list.d -type f -exec bash -c 'mv $1 ${1}.bak' -- {} \; && \ apt-get update && apt-get install -y apt-transport-https && \ find /etc/apt/sources.list.d -type f -exec bash -c 'mv $1 ${1//.bak}' -- {} \;
    – Ajax
    Nov 9, 2021 at 16:07
0

In my case (Ubuntu 20.04 LTS) the problem seemed to have to do with package python3-aiozmq depending to python-3.5 or not working:

The following packages will be upgraded:
  apt-transport-https
1 to upgrade, 0 to newly install, 0 to remove and 39 not to upgrade.
1 not fully installed or removed.
Need to get 4.680 B of archives.
After this operation, 1.024 B of additional disk space will be used.
Get:1 http://ftp.belnet.be/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.6 [4.680 B]
Fetched 4.680 B in 0s (24,3 kB/s)               
(Reading database ... 600039 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.0.6_all.deb ...
Unpacking apt-transport-https (2.0.6) over (2.0.5) ...
Setting up python3-aiozmq (0.7.1-2) ...
  File "/usr/lib/python3/dist-packages/aiozmq/rpc/base.py", line 251
    fut = asyncio.async(coro, loop=self.loop)
                  ^
SyntaxError: invalid syntax

dpkg: error processing package python3-aiozmq (--configure):
 installed python3-aiozmq package post-installation script subprocess returned error exit status 1
Setting up apt-transport-https (2.0.6) ...
Errors were encountered while processing:
 python3-aiozmq

It seems the problem has been fixed in the next version ('0.9'), but the new version is not there yet (so apt-get update won't fix the problem for now). The way I solved this was to manually download it:

wget http://ftp.it.debian.org/debian/pool/main/a/aiozmq/python3-aiozmq_0.9.0-1_all.deb

And then manually remove the problematic package and install it:

sudo apt remove python3-aiozmq
sudo dpkg -i python3-aiozmq_0.9.0-1_all.deb 

After that, sudo apt install apt-transport-https just worked for me.

-1

You can execute following command:

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

you have to add your proxy settings in case absence of their settings are causing issues to get the package. you can set http_proxy, https_proxy, no_proxy in your system/shell settings. I myself was facing similar issue in installing apache superset.

1
  • 1
    Your last sentence seems to have been cut off. Also, the OP made no mention of a proxy...?
    – Jeff Schaller
    Feb 23, 2019 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .