Score:0

How do I fix apt-get check` failed, you may have broken packages

in flag

I tried fixing a broken autodl irssi installation on a rented dedicated server running Ubuntu 18.04.1 LTS (GNU/Linux 4.9.0-15-amd64 x86_64) and Swizzin Box by removing and reinstalling the box autodl package.

removing autodl gave :-

SUCCESS autodl removed 
ERROR dpkg database is locked by apt-get. Please try again later

trying to reinstall it gave :-

INFO Installing autodl 
E: Unable to correct problems, you have held broken packages. 
ERROR The simulation check resulted in an error. Please consult the log.

the log shows

Reading package lists...
Building dependency tree...
Reading state information...
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 pkg-config : Depends: libdpkg-perl but it is not installed

running 'apt --fix-broken install' gives :-

0 upgraded, 0 newly installed, 1 to remove and 107 not upgraded.
After this operation, 193 kB disk space will be freed.
Do you want to continue? [Y/n] y

(Reading database ... 87206 files and directories currently installed.)

Removing pkg-config (0.29-4+b1) ...

Can't locate Dpkg/Arch.pm in @INC (you may need to install the Dpkg::Arch module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/pkg-config-dpkghook line 14.

BEGIN failed--compilation aborted at /usr/share/pkg-config-dpkghook line 14.

dpkg: error processing package pkg-config (--remove):

 subprocess installed pre-removal script returned error exit status 2

Errors were encountered while processing:

 pkg-config

E: Sub-process /usr/bin/dpkg returned an error code (1)

Does anyone have any suggestions how I can resolve this issue?

EODCraft Staff avatar
cn flag
Looks as if it's looking for some Perl libraries. Google Perl install and see how to install this package. `Dpkg::Arch module`
Paladinz avatar
in flag
Trying to install perl gives
Paladinz avatar
in flag
trying to install perl gives perl : Depends: perl-modules-5.26 (>= 5.26.1-6ubuntu0.5) but it is not going to be installed Depends: libperl5.26 (= 5.26.1-6ubuntu0.5) but it is not going to be installed pkg-config : Depends: libdpkg-perl but it is not going to be installed Trying to install these gives The following packages have unmet dependencies: pkg-config : Depends: libdpkg-perl but it is not going to be installed
Score:-1
in flag

Try sudo apt --fix-broken install libdpkg-pearl. Also, look to see if you have any pinned packages: run apt policy, and check for anything interesting. In this case, 'interesting' includes any third-party repositories: if the line doesn't include "ubuntu.com", its suspicious.

There are cases where third-party repositories (those that aren't from Canonical) are needed, such as for proprietary software that can't be redistributed or when the latest upstream version of software is a hard requirement. However, these repositories MUST be designed specifically to work with the base installation of whatever OS you have, and should not contain extraneous packages. You should absolutely never attempt to gain compatibility by adding references to another operating system: for instance, by adding Debian Stretch as a package source for a Ubuntu Bionic release. Lots of bizarre package conflicts and unexpected replacements can occur.

I wasn't able to recreate this situation in a chroot: apt --fix-broken install worked even after some aggressive removals. Aptitude may be able to give you more info, but I doubt you'll be able to get it running, given you're current package mess. A pastebin of dpkg --list would be the next bit of debugging information.

Paladinz avatar
in flag
thanks Calum, `sudo apt --fix-broken install libdpkg-pearl` returns `E: Unable to locate package libdpkg-pearl`. I don't know enough to spot what would be interesting in `apt policy` but the output is [here](https://pastebin.com/FkfuiQxd) if you have the time to look at it. the output from `dpkg --list` is [here](https://pastebin.com/StY6AGkk)
Paladinz avatar
in flag
after rereading your comment I spotted the autocorrect and ran the command with perl not pearl. it returns `You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: libdpkg-perl : Depends: perl but it is not going to be installed Recommends: libfile-fcntllock-perl but it is not going to be installed Recommends: liblocale-gettext-perl but it is not going to be installed`
Calum McConnell avatar
in flag
@Paladinz Sorry for the late response. The reason I was interested in apt-policy is because pinned packages and other weird things can interfere with APT's normal functioning. It seems this is partially the case here: you are not running Ubuntu BONIC, but instead a blend of Debian Stretch, Buster-Backports, and Bonic. This is a massive problem: these repositories are not intended to be used simultaneously. Because the versions progress differently, you get some new Ubuntu packages, some old Debian packages, and some super new Debian packages. You're going to want to fix that.
Calum McConnell avatar
in flag
@Paladinz the solution is going to be a bit involved. Go through the sources.list and sources.list.d files, and remove anything that includes the 'debian.org' domain, as well as the leaseweb mirrors of the debian files. It looks like the only two third-party repositories you need are syncthing and nodesource. If you truly need the upstream version of that software, take another look at their installation docs. However, Node.JS as well as SyncThing are available in the official Ubuntu repositories, so you can probably remove those lines as well. After this, try troubleshooting again.
Paladinz avatar
in flag
thank you, we all have lives so any useful response is welcome even if it takes some time :) I'll clean up the sources and see what happens.
Paladinz avatar
in flag
I am seeing the same errors, even with `sources.list` only containing `deb http://security.ubuntu.com/ubuntu bionic-security main multiverse universe restricted` and `deb http://archive.ubuntu.com/ubuntu bionic universe multiverse restricted`. Output from `apt-get update && apt-get dist-upgrade` and `apt --fix-broken install` is [HERE](https://pastebin.com/XedXXvqq). My appologies if I am unaware of basic details but my friend who set up the system passed away due to Covid and Unix is not my natural habitat.
Calum McConnell avatar
in flag
Okay, lets try `apt install --fix-broken perl pkg-config`. It looks like the issue is that someone tried to manually remove a ton of packages, including Perl: since Perl is an essential part of a debian system, this caused the breakage you see now. It may be easier to look at reinstalling from scratch: there are a lot of packages that were removed (anything marked with an 'r' in the dpkg list output), many of which are probably needed for this server to function.
Paladinz avatar
in flag
Yes, that was me when the system said something like not being needed and to use autoremove. **It didn't go well**. `apt install --fix-broken perl pkg-config` returns `perl : Depends: perl-modules-5.26 (>= 5.26.1-6ubuntu0.5) but it is not going to be installed | Depends: libperl5.26 (= 5.26.1-6ubuntu0.5) but it is not going to be installed | pkg-config : Depends: libdpkg-perl but it is not installable | E: Unmet dependencies. Try 'apt --fix-broken install'.`. Starting from scratch will mean moving 15tb of data so I'll have to source a new server to move it to, it may well be the only option.
Calum McConnell avatar
in flag
Okay, so I just realized I never actually said to clear any pinned packages. You're going to want to do that: it's possible that the znc-perl pin is trying to hold back all of perl to 5.22. To clear those pins, remove anything in /etc/apt/preferences.d and /etc/apt/preferences. Then run apt policy to confirm that you're clean.
Calum McConnell avatar
in flag
Also, I messed up. `dpkg --list` isnt the information needed to debug these problems. Instead, could you provide me with the contents of `/var/lib/dpkg/status`? That file contains enough additional information for me to accurately simulate your system, which would let me stop firing guesses at you that don't work.
Paladinz avatar
in flag
thanks Calum, `apt policy` looks good, the output is [here](https://pastebin.com/EZwfG2mc), the outpout of `/var/lib/dpkg/status` is [here](https://zerobin.net/?d3e9c1eb8fef7c7c#+wrxLlUwThDcR3nrwm8Tn7K6Mb6MljiEGBKHxM+2YAY=)
Calum McConnell avatar
in flag
okay. I was able to get a less-broken system with `sudo apt install --fix-broken libjpeg-turbo8-` (the minus after the package name directs it to be removed, which helps apt figure the solution). This package appears to be redundant and conflicting with libturbojpeg0: so it is safe to remove. The system was still borked afterwards, with a ton of held-back packages, but it's certainly more workable. Can you send me the status again, after running that command?
Paladinz avatar
in flag
Unfortunately that didn't help as the system says `Package 'libjpeg-turbo8' is not installed, so not removed` and gives the usual `pkg-config : Depends: libdpkg-perl but it is not installable` error after.
Calum McConnell avatar
in flag
I see the issue: our apt versions are totally different. I have been testing on a much newer version of apt than what you have currently installed: presumably the --fix-broken option has gotten some upgrades. Here is a more functional command: `apt install --fix-broken build-essential cpp cpp-7 dpkg-dev g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libdpkg-perl libfile-fcntllock-perl libgcc-7-dev libgdbm-compat4 libgdbm5 libisl19 liblocale-gettext-perl libmpc3 libmpfr6 libperl5.26 libstdc++-7-dev perl`.
Paladinz avatar
in flag
the output from the `apt install` command is [HERE](https://zerobin.net/?69bb6e9b1fd15353#7fgTcFeiPqnBvMWGNV0FNU+KLcC+OyC5TSUST5krFww=) and the output of `/var/lib/dpkg/status` is [HERE](https://zerobin.net/?262213e20afc38f6#qEmqTEuAjHONr1C0QxqnMNGFKnTYnf9eARek3IO5RZo=)
Calum McConnell avatar
in flag
Took another look at your apt policy output: it looks like you're missing "main" from the sources.list entry for archive.ubuntu.com. I'm sorry I didn't spot it before: add "main" to that file (next to where it says "universe" and "multiverse", and then try again.
Paladinz avatar
in flag
I'd never have spotted it was missing so it's all good! the sources.list entry now has `deb http://archive.ubuntu.com/ubuntu bionic main universe multiverse restricted` and the `apt install` command worked, the contents of `/var/lib/dpkg/status` is [HERE](https://zerobin.net/?d3778344ec7d302d#EJPGwsWwPBD91qiAipFV4VGLdRTfk7uidifE8ekNOYc=)
Calum McConnell avatar
in flag
Okay, so we now have a *working* installation of Debian, lets get back to fixing the original problem of IRSSI-autodl being broken. This will require some debugging effort: I am willing to bet that part of WHY it was originally broken was because of the funky version mismatches. For instance, you are currently running IRSSI from Debian 9, as opposed to the version from Ubuntu Bionic. This can be fixed by executing `apt install --reinstall irssi`: however, that may need to be repeated many times. There are also a lot of (theoretically) unused packages. What problems are you seeing now?
Paladinz avatar
in flag
Now I am seeing no problems at all, autodl is managed by the Swizzin Box interface and reinstalled through that (after I installed git and updated), everything looks to be working perfectly! Thank you very much Calum for all the effort you've put into this, it is very much appreciated.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.