apt-get error on openhabian when calling '/usr/lib/apt/methods/http'

2

I hope I'm right here, some days ago apt-get broke on my Raspberry Pi Model B rev. 2 (running Openhabian). I'm not sure why yet and wasn't able to fix it myself.

When I try to apt-get update as root I get the following output:

[15:58:05] root@openHABianPi:/home/openhabian# apt-get update
Reading package lists... Done
E: Method http has died unexpectedly!
E: Sub-process http received signal 4.
E: Method /usr/lib/apt/methods/http did not start correctly
E: Method https has died unexpectedly!
E: Sub-process https received signal 4.
E: Method /usr/lib/apt/methods/https did not start correctly
E: Method https has died unexpectedly!
E: Sub-process https received signal 4.
E: Method /usr/lib/apt/methods/https did not start correctly
E: Method https has died unexpectedly!
E: Sub-process https received signal 4.
E: Method /usr/lib/apt/methods/https did not start correctly
E: Method https has died unexpectedly!
E: Sub-process https received signal 4.
E: Method /usr/lib/apt/methods/https did not start correctly
E: Method http has died unexpectedly!
E: Sub-process http received signal 4.
E: Method /usr/lib/apt/methods/http did not start correctly
E: Method http has died unexpectedly!
E: Sub-process http received signal 4.
E: Method /usr/lib/apt/methods/http did not start correctly
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/dists/stretch/InRelease
E: Failed to fetch https://apt.homegear.eu/Raspbian/stretch/InRelease
E: Failed to fetch https://deb.debian.org/debian/dists/stretch-backports/InRelease
E: Failed to fetch https://mirrordirector.raspbian.org/raspbian/dists/testing/InRelease
E: Failed to fetch https://dl.bintray.com/openhab/apt-repo2/dists/stable/InRelease
E: Failed to fetch http://archive.raspberrypi.org/debian/dists/stretch/InRelease
E: Failed to fetch http://repos.azulsystems.com/debian/dists/stable/InRelease
E: Some index files failed to download. They have been ignored, or old ones used instead.

When I try to check the version of /usr/lib/apt/methods/http (https is a link to that) I get the following output:

[15:59:05] root@openHABianPi:/home/openhabian# /usr/lib/apt/methods/http
Illegal instruction

I have apt-transport-https installed. I also did apt-get autoremove and there may be some dependences missing from whatever package /usr/lib/apt/methods/http is part of, even tough as far as I know that shouldn't happen.

Thank you for your help!

Edit 1:

[23:11:36] root@openHABianPi:/home/openhabian# dpkg -i apt_1.4.9_armhf.deb
dpkg: warning: downgrading apt from 1.8.0 to 1.4.9
(Reading database ... 47399 files and directories currently installed.)
Preparing to unpack apt_1.4.9_armhf.deb ...
Unpacking apt (1.4.9) over (1.8.0) ...
dpkg: dependency problems prevent configuration of apt:
 libapt-pkg5.0:armhf (1.8.0) breaks apt (<< 1.6~) and is installed.
  Version of apt to be configured is 1.4.9.

dpkg: error processing package apt (--install):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.28-8) ...
Processing triggers for man-db (2.7.6.1-2) ...
Errors were encountered while processing:
 apt

I installed libapt-pkg5.0_1.4.9_armhf.deb and then was able to install apt_1.4.9_armhf.deb

I still have the problem that apt-get update freezes with 0% [Working] at one source, this may still be caused by incompatible sources.

Edit 2:
The problems were caused by a wrong source originating from a letsencrypt/certbot-setup, I got rid of all remaining problems by removing the source, pinning my packages to stable (was using "now" for a lot of packages) and basically doing a very careful apt-get dist-upgrade with a lot of manual checking. You may have to exclude https sources temporarily even with apt-transport-https installed as it didn't work for me too (failed with "Illegal instruction" on call of /usr/lib/apt/methods/https because of dependencies).

Malspherus

Posted 2019-03-28T16:49:27.737

Reputation: 23

Answers

0

I'm hoping your dpkg still works ok... On my Debian/MX system (also based on Debian stretch), the /usr/lib/apt/methods/http file is part of the apt package, checked with dpkg -S /usr/lib/apt/methods/http.

Browsing through what might be your main repository http://raspbian.raspberrypi.org/raspbian/dists/stretch/InRelease and specifically looking in http://raspbian.raspberrypi.org/raspbian/dists/stretch/main/binary-armhf/Packages (it's 59M) I see it's got

Package: apt
Version: 1.4.9

Which is the same version number as mine too. So I'm guessing your apt package was messed up somehow, perhaps an incompatible version from another source "upgraded" it? You can check your apt's version with one of:

  • apt-cache showpkg apt
  • apt-cache show apt if apt-cache still works, or
  • dpkg -s apt
  • dpkg-query --show apt

Hopefully it's not 1.4.9, so you can try installing this version. Browsing more through the repository, http://raspbian.raspberrypi.org/raspbian/pool/main/a/apt/ has the apt_1.4.9_armhf.deb file.

[It's mirror list is here, with other download links.]

If you download the .deb. file, and install it with

dpkg -i apt_1.4.9_armhf.deb

that should install a hopefully good version of apt.

Be careful not to "upgrade" apt again to a possibly broken version, I'd check the source of any candidates with apt-cache policy apt and maybe remove "bad" sources, or consider pinning apt to a good source only (see man apt_preferences) or locking it's version.

Xen2050

Posted 2019-03-28T16:49:27.737

Reputation: 12 097

Thank you for your reply, you were spot on, dpkg works, apt isn't version 1.4.9 and I also tried to install that exact version before posting here because I thought it was already installed, but it turns out that I actually have 1.8.0 installed and changing to 1.4.9 throws errors (I added the output to the original post) – Malspherus – 2019-03-28T22:20:20.437

So downgrading libapt-pkg5.0 fixed things? That's good, at least this problem got solved, if my answer was helpful please do select it as correct (click the check-mark next to it) & even upvote if you're able. I'm not sure about the one source not downloading, maybe it's just down for now? – Xen2050 – 2019-03-28T23:03:28.043

Yes, I'll try the solutions from here now, hopefully they'll completely solve it since I don't use small lists that are likely to go offline.

I marked and upvoted your answer, though the upvote won't show for now since my account is new. Thank you again!

– Malspherus – 2019-03-28T23:30:00.507

I'd still guess it's a not fully compatible source, but I don't know enough about raspberries & openhabian to guess which. I had similar problems using www.deb-multimedia.org with my MX/Debian, that source was a little different & has some weird version numbers (like 2:1.4.5 that get installed instead of a newer 1.6), I kept it for a small handfull of codecs but pinned it's priority to never auto-install (I think 50), but removing it & manually installing a couple packages should've worked too. Welcome & thanks for the check, I think you still need a couple more rep points to upvote, ah well. – Xen2050 – 2019-03-30T19:21:59.630