[Solved ] Apt and Unmet Dependencies

This problem is posted all over the web with no consistent solution.
Post after post with no result users can rely on.

In my case, I had a distribution upgrade after I had unmet dependencies.
Obviously apt doesnt work nice if these unmet dependencies persist.

$] dpkg --audit
The following packages have been unpacked but not yet configured.
They must be configured using dpkg --configure or the configure
menu option in dselect for them to work:
 libegl-mesa0:amd64   free implementation of the EGL API -- Mesa vendor library
 libgl1-mesa-dri:amd64 free implementation of the OpenGL API -- DRI modules
 libgl1-mesa-glx:amd64 transitional dummy package
 libglapi-mesa:amd64  free implementation of the GL API -- shared library
 libglx-mesa0:i386    free implementation of the OpenGL API -- GLX vendor libra
 libnss-winbind:amd64 Samba nameservice integration plugins
 libosmesa6:i386      Mesa Off-screen rendering extension
 libpam-winbind:amd64 Windows domain authentication integration plugin
 mesa-vdpau-drivers:amd64 Mesa VDPAU video acceleration drivers

The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 winbind              service to resolve user and group information from Window

Since I already tried to reinstall these packages, and it failed, how do I completely remove them from the apt/dpkg database ?
I am careful with --purge as it can uninstall other programs willy nilly.

What would be great is to bulk remove all these unmet dependencies so they are not reported or relied on anymore as the contingencies are unresolvable.

If we can get a simple solution it will help not only me but a lot of people in all the unresolved threads.

Have you tried?

sudo apt-get --fix-broken install

That was in fact the first I tried.
It yields the same result as audit.

Here is the relevant tail of the final fail message after running
sudo apt-get --fix-broken install

Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

In my case and I guess others battling with the same, there is no way to resolve this other than to make apt/dpkg forget about these packages completely as there is no solution to using them.

The question is therefore how to make dpkg forget about only these so that apt can work normally again.

Try to remove it. See if that helps. Something like

sudo apt-get remove pkg_1
sudo apt-get --fix-broken install

Replace pkg_1 with all of the above packages.

There is no built in dpkg command that will clear all unmet dependencies as I ask in my original question ?

The reason I ask is that I tried to write a script to remove them all at once but found that dpkg output is wildly varying from version to version representing the same state.
I then found that they actually warn against using dpkg output in scripts as the scripts wil fail with probably random results from version to version.

So I guess removing them one by one is the only option given the developers own comments.
I was curious if someone here maybe know of a single command to remove unmet dependencies, but it is clear that it is not so.

Sometimes during a very ugly upgrade where you messed up unintentionally , you can sit with 50+ Unmet dependencies.
So removing them one by one becomes tedious.

That doesnt work see example below. You cannot remove something that is not installed but is part of an unsuccessful upgrade.

The only option here is to make dpkg forget about these packages as they are neither installed not can they be installed, but they gunk up the entire apt process as they are remembered and insisted on to be installed even though I dont want or need them.

So how do I rather tell dpkg to just forget about the broken packages and move on so apt can be used again.

# apt-get remove libosmesa6:i386 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libgl1-mesa-dri : Breaks: libgl1-mesa-dri:i386 (!= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
 libgl1-mesa-dri:i386 : Breaks: libgl1-mesa-dri (!= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
 libgl1-mesa-glx : Breaks: libgl1-mesa-glx:i386 (!= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
 libgl1-mesa-glx:i386 : Breaks: libgl1-mesa-glx (!= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
 libglapi-mesa : Breaks: libglapi-mesa:i386 (!= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
 libglapi-mesa:i386 : Breaks: libglapi-mesa (!= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
 libglx-mesa0 : Depends: libglapi-mesa (= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
                Breaks: libglx-mesa0:i386 (!= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
 libglx-mesa0:i386 : Depends: libglapi-mesa:i386 (= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
                     Breaks: libglx-mesa0 (!= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
 libosmesa6 : Depends: libglapi-mesa (= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
 mesa-vdpau-drivers : Breaks: mesa-vdpau-drivers:i386 (!= 18.3.2-1~mx17+1) but 18.2.6-1~mx17+1 is to be installed
 mesa-vdpau-drivers:i386 : Breaks: mesa-vdpau-drivers (!= 18.2.6-1~mx17+1) but 18.3.2-1~mx17+1 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

First, you type this

apt-get remove libosmesa6:i386 

Next you type

apt --fix-broken install

And it should fix it.

Yes I did exactly that.

It didnt fix it dpg --audit still list libosmesa6:i386 mesa.

What makes things worse is that the packages as listed by audit is not in the /var/lib/dpkg/status file, where if it was, I could have edited the data out and the problem would disappear. Since these packages are suppopsed to be upgrades to existing working libraries and is not installed, they CAN be and SHOULD be forgotten without any consequence.

Really pesky problem and dpkg developers really needs to address this.
All I can think of now is to do a grep on the entire dpkg system and see where these files are mentioned and then see if I can edit them out of existence.
This issue shows a huge shortcoming of dpkg.

For the record:
Web Wisdom says that any or all of the following will remove broken packages.
sudo apt-get autoremove
sudo apt-get --purge remove
sudo dpkg --remove --force-remove-reinstreq tspc
sudo apt-get autoclean
sudo apt-get clean
sudo apt-get -f install

Unfortunately that is utterly false . Audit still shows the broken packages.

More web widom states:
“Open synaptic Install synaptic. Then go to status and choose Broken. Then remove completely the broken packages.”

This will work but it will also uninstall 100s of working and necessary files, and completely breaks the system by an attempted downgrade. So I couldnt do that.
One of them will even Remove Xorg!

equivs might be the only remaining option, however to install it the catch is again to remove the broken packages. I will try install from source.
Equivs will create decoy dependencies and make anything install that is held back. In this case it is a valid solution as these broken packages are not even needed but gunk up the entire dpkg system.
The debs are not going to install so I had to find a binary version of equivs.
Luckily the author of equivs obviously know about this issue so he provides a binary !, no need to install as he know that dep errors will cause trouble that is the point f equiv to fix. Similar for other equivs programs needed.
It can be found here

To nixcraft
I will keep posting my progress here to keep things in one place, and clean up after final success or failure. If successful I will create a detailed summary and instructions.

I solved it, was trivial but very very sneaky and is why so many people cannot use the advice currently on the web.
I will write it up then you can clean up the thread regarding unnecessary discussion so it makes a decent document people can rely on for Nixcraft.

Here is how to fix this kind of very very nasty problem:

I tried everything available on the internet and little helped.
I give an actual example of how I fixed it:

After a botched up-grade or install, sometimes you get the message that there unresolved UNMET DEPENDENCIES and that you cannot use apt anymore. It is locked down until the dependencies are resolved.

In my case, I had a distribution upgrade after which I had unmet dependencies and non functioning apt & dpkg…

If this happens you need to do the following first.
In that case you need to run

dpkg --configure --pending
You will find
“Errors were encountered while processing”
In my case it was;
Errors were encountered while processing:

Step 2:
To correct this, pick one from the list
Pick from list
e.g. libpam-winbind:amd64

Then see if it is registered in /var/lib/dpkg/info

# ls -l /var/lib/dpkg/info |grep -i libpam-winbind:amd64
-rw-r–r-- 1 root root 741 Jul 29 17:26 libpam-winbind:amd64.list
-rw-r–r-- 1 root root 700 May 8 16:23 libpam-winbind:amd64.md5sums
-rwxr-xr-x 1 root root 47 May 8 16:23 libpam-winbind:amd64.postinst
-rwxr-xr-x 1 root root 148 May 8 16:23 libpam-winbind:amd64.prerm

Step 3:
To make dpkg not consider the dependency, do
mkdir /var/lib/dpkg/info/TEMP
mv /var/lib/dpkg/info/libpam-winbind:amd64* TEMP

Check again if it was moved
# ls -l /var/lib/dpkg/info |grep -i libpam-winbind:amd64
(gives no output if successful)

Step 4:
Now you need to purge this dependency from the system.
dpkg --purge libpam-winbind:amd64
dpkg: warning: files list file for package ‘libegl-mesa0:amd64’ missing; assuming package has no files currently installed
(Reading database … 670426 files and directories currently installed.)
Removing libpam-winbind:amd64 (2:4.5.16+dfsg-1+deb9u2) …

Step 5:
Now lets see if package is still in the dependency mess.

dpkg --configure --pending
Errors were encountered while processing:

And you see it is now gone.

Step 6:
Now repeat the process above for all the remaining unmet dependencies until it is all gone and dpkg --configure --pending shows no more unmet dependencies.
After that run
apt-get --fix-broken install
apt update
also run
dpkg --configure --pending
which now will show there are no more dependencies.

A warning that there are traces of a dependency will be presented in the output in YELLOW, but it will not affect apt in any way.Apt will work normal again.
The benign yellow error messages is a small price to pay for having your system back out of a nasty lockup

1 Like

Thanks :slight_smile:
This helped me alot.

Also take a look at my thread at ](Damaged libc6 how do I recover?). It is related to this problem. It solves the problem of a corrupt library that completely makes your linux distro inoperable and there is usually no way to recover other than reinstall. This method works for any library that is corrupt and bricks your system.

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki