Ubuntu – Can multiple versions of the same package co-exist on the same system

aptdependenciespackage-management

In order to install tmux 2.1, I needed to install libtinfo5 version 6, I did this by downloading a .deb archive containing libtinfo5 and installing directly with command:

sudo dpkg -i libtinfo5_6.0+20160213-1ubuntu1_amd64.deb

This satisfied tmux 2.1's dependency and tmux installed ok.
Now I tried to install vnstat using

sudo apt-get install vnstat 

apt-get error exited with the following

$ sudo apt-get install vnstat
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libncurses5 : Depends: libtinfo5 (= 5.9+20150516-2ubuntu1) but 6.0+20160213-1ubuntu1 is to be installed
 libncursesw5 : Depends: libtinfo5 (= 5.9+20150516-2ubuntu1) but 6.0+20160213-1ubuntu1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

My understanding has always been that Ubuntu's package management system was capable of installing and managing multiple versions of the same package, for situations exactly like this. In other words apt/dpkg recognises

  • tmux needs libtinfo5 – version 6 to work
  • vnstat needs libtinfo5 – version 5 to work

Then apt/dpkg say's ok, I'll install both versions.
I can see how certain programs like a system binary, e.g. bash or ls can only be installed once as most invocations simply say bash -c "<command>" and not bashv.3.2 -c "<command>".
So my question is can the package manager install and manage multiple dependencies?, or is this just not possible because, like in the bash example above, most programs make a call to the dependency by the dependencies name without specifying version. In which case the issue is beyond the control of the package manager (i.e. its more of a programming compilation/configuration/organisation issue) and the package manager gives up at that point?

Best Answer

No, it is not possible to have two versions of the same package, because there will be conflicting files. If a library is capable of being installed in two different versions at the same time is a different matter. If you're brave, you could get the source code for one version and see if you can install that to a different directory. This could very well mess up your system in nasty ways. It could also just plain not work. Dpkg won't be satisfied, so you'll have to get the source for one of the programs and compile that too. But bear in mind that once you start compiling programs yourself, you can cause yourself all kinds of problems.

Related Question