apt --fix-broken install not working
I am using Ubuntu 20.04. When I execute the command:
sudo apt-get install build-essentialI get the output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.8ubuntu1.1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies: fontconfig:i386 : Depends: libfreetype6:i386 (>= 2.8.1) but 2.6.1-0.1ubuntu2 is to be installed libcairo2:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be installed libfontconfig1:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be installed libfreetype6 : Breaks: libfreetype6:i386 (!= 2.10.1-2ubuntu0.1) but 2.6.1-0.1ubuntu2 is to be installed libfreetype6:i386 : Depends: libpng12-0:i386 (>= 1.2.13-4) but it is not installable Breaks: libfreetype6 (!= 2.6.1-0.1ubuntu2) but 2.10.1-2ubuntu0.1 is to be installed libharfbuzz0b:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).When I check
sudo apt --fix-broken installI get the output
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies: fontconfig:i386 : Depends: libfreetype6:i386 (>= 2.8.1) but 2.6.1-0.1ubuntu2 is installed libcairo2:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed libfontconfig1:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed libfreetype6 : Breaks: libfreetype6:i386 (!= 2.10.1-2ubuntu0.1) but 2.6.1-0.1ubuntu2 is installed libfreetype6:i386 : Depends: libpng12-0:i386 (>= 1.2.13-4) but it is not installable Breaks: libfreetype6 (!= 2.6.1-0.1ubuntu2) but 2.10.1-2ubuntu0.1 is installed libharfbuzz0b:i386 : Depends: libfreetype6:i386 (>= 2.9.1) but 2.6.1-0.1ubuntu2 is installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependenciesI was trying to set up Modelsim on Ubuntu 20.04 with those libfree packages but it seems that I have ruined everything. Is there anyway I can completely get rid of them? I tried removing them and the output of the command
sudo dpkg --configure -ais empty now but I'm still receiving the errors above.
22 Answers
Looks like you tried to install 20.04 (focal) packages on a 16.04 (xenial) system.
As you have learned to your sorrow, mixing packages from different releases of Ubuntu is likely to break your system. If you need newer packages, you must run a newer release of Ubuntu.
Since you have a horrifying mixture of both packages on your system (we call that a Frankensystem), the simplest option is to back up your data and then reinstall Ubuntu.
It's quite possible for somebody with skills and patience to carefully read each error message and downgrade each focal package back to xenial. There is (obviously) no single, simple command for that. Once your data is backed up, feel free to give it a try -- if it becomes impossible then reinstall.
4I found some resources on the web, which might be useful.
Solution 1
As HVNSweeting says in their answer, they fixed it by following the below:
First, run:
dpkg -l | grep ^iU | awk '{print $2}' | xargs sudo dpkg --purgeIf the output is:
dpkg: error: --purge needs at least one package name argument
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !Then go to the next solution, or run:
sudo apt update && sudo apt upgradeDone!
Solution 2
As Amlan Saha Kundu says in their answer on Super User, you need to clear the contents of /var/lib/dpkg/status.
To do the above:
Backup the file by running:
sudo cp -r /var/lib/dpkg/status $HOMEThen clear the contents by running:
echo > /var/lib/dpkg/statusAfter that run:
sudo apt update && sudo apt upgrade
You can search the issue to get more solutions.