When you are installing any new package or upgrading any package through terminal in Ubuntu you may sometimes be presented with “you have held broken packages” error, and thus preventing you from installing the package that you want.
Well this is because the package that you are trying to install already has been installed with any older or newer version or any other dependencies that you package depends on has the same issue. Either way we need the package installed. So what do we do.
Simple we force the system to find a solution and install the new package that we want.
When we do apt-get install on the system the system checks for all the dependencies the package requires and then tries to install the dependencies as well but doesn’t try to solve any conflicts with the package or version of the package.
We need a command with a better algorithm to perform the operation. Then comes aptitude command.
Many people may tell you that both apt-get and aptitude are same command but its only the top most layer thats same. They have different working algorithms working in the background. aptitude has more conflict resolving capability than apt-get. So in our case we use aptitude to install the packages
$ sudo aptitude -f install package-name
Read carefully what comes next as it will present you with some options to solve your issue.Firstly It will ask you to leave the issue as it is.
Enter n for no to that.
Then it will provide us with a work around for the solution, which is to downgrade/upgrade the depending packages.
Check carefully that the solution doesn’t contain any necessary packages that may affect other softwares.
If all is well, enter y for yes and it will start patching up the depending packages to make the new package installable.
Finally your new package will be install.