Sometimes you get “The following packages have unmet dependencies” error during installation or upgrade of a particular package in Ubuntu. This error occurs if you install package using apt-get command and it is unable to find/install some of the upstream packages required for successful installation. In this article, we will look at how to resolve unmet dependencies in Ubuntu.
How to Resolve Unmet Dependencies in Ubuntu
Here are the different ways to resolve unmet dependencies in Ubuntu. Before you proceed, please take a backup of configuration files /etc/apt/sources.list and /var/lib/dpkg/status files with the following commands.
$ sudo cp /etc/apt/sources.list /etc/apt/sources-backup.list $ sudo cp /var/lib/dpkg/status /var/lib/dpkg/status-backup
Now let us look at the different ways to fix this problem.
1. Use -f parameter
Run apt-get install -f to fix broken dependencies in your system.
$ sudo apt-get install -f
Then run the following command
$ sudo dpkg –configure -a
Then run the apt-get install -f command again.
$ sudo apt-get install -f
Now try installing your package with the following command, where PACKAGE is the name of package you want to install.
$ sudo apt-get install PACKAGE
2. Use aptitude
Aptitude is an alternative to apt-get which fixes unmet dependencies automatically, sometimes. Install it with the following command.
$ sudo apt-get install aptitude
Now use aptitude to install your package, instead of using apt-get
$ sudo aptitude install PACKAGE
3. Clear Package Database
Sometimes, a corrupted package database can also cause the issue of unmet dependencies. Run the following commands
$ sudo apt-get clean $ sudo apt-get autoclean
The first command cleans local repositories, except lock files from /var/cache/apt/archives, and /var/cache/apt/archives/partial/. The second command removes packages you can no longer download and are outdated.
4. Eliminate Held Packages
Sometimes packages are held because they have unmet dependencies. Removing such packages can fix unmet dependencies issue. You can do so with the following command.
$ sudo apt-get -u dist-upgrade
If the output lists any held packages, then run the following command to remove them.
$ sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
If you see an output N not upgraded, where N is the number of packages that couldn’t be upgraded, then you will need to remove them one by one. Use the following command to remove a particular package. Replace PACKAGENAME with the name of package to be removed.
$ sudo apt-get remove –dry-run PACKAGENAME
5. Disable PPAs
PPAs (Personal Package Archives) are third-party package repositories hosted on Launchpad, for packages not supported by official Ubuntu repository.
Use the following command to remove a particular PPA from your system. Replace ppa_name/ppa with the name of your PPA
$ sudo add-apt-repository –remove ppa:ppa_name/ppa $ sudo apt-get autoclean
Then try installing your package and you should be able to install it.
In this article, we have looked at many different ways to fix unmet dependencies. However, it is important to keep your system up-to-date and use only trusted PPAs to avoid these kind of issues. If you are still unable to install your package, consider downloading and using its binary, if available.
How to Execute Shell Script from Python
How to Copy Files from One Directory to Another in Linux
Grep : Exclude Files & Directories
How to Install Fail2ban in CentOS 7
How to Copy File to Multiple Directories in Linux