16

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?

5
  • You should read up on snap packages. Apr 17, 2016 at 23:43
  • You might even be able to build your own snaps for tmux and vnstat yourself, if they haven't already been built. You do need 16.04 though. developer.ubuntu.com/en/snappy/build-apps Apr 17, 2016 at 23:47
  • @Zacharee1 thanks for the link. I totally see why the Snaps system is necessary now. The PHP community had the same issue where PEAR/PECL is analogous apt/dpkg and Snaps is analogous to composer Apr 18, 2016 at 0:10
  • @Zacharee1 The newer version of tmux is also already in Ubuntu 16.04. If one wants it on 14.04, it would probably be better to just rebuild the source package from 16.04, or request a backport of the new version, to the backports archive for 14.04.
    – dobey
    Apr 18, 2016 at 0:31
  • But what about all the packages that are managed my "alternatives". Java is an example, and you can have many versions of it. Python is another one, not managed by "alternatives" but by other means: Python3 and Python2 are considered different languages.
    – jgomo3
    Jan 16, 2017 at 18:38

3 Answers 3

6

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.

2
  • Thanks, so basically you are saying I would need to compile from source (most likely independent of the package manager) and mostly self contained in its own monolithic directory - not following the [linux file system hierarchy]( en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard) then use a local instance of the library /dependency , and modify the source to include this local library, not the system library. At which point I, as you say once you start compiling programs yourself, you can cause yourself all kinds of problems. Apr 18, 2016 at 0:03
  • That's exactly right. I'm afraid you've been caught in the middle of dependency hell. Usually in cases like yours where different programs depend on different versions of the library, the different versions of the library are shipped as different packages. A good example is libjpeg: there's a libjpeg8, libjpeg9, and libjpeg62. But that is an issue for the package maintainer. Apr 18, 2016 at 0:15
2

No, you can not have different versions of the same package installed at the same time. Usually dependencies are expressed as at least version X. For packages that are all built from the same source however, the dependency is often exact. This is what you have run into. libncurses5 and libtinfo5 are both built from the ncurses source package. If you want to upgrade one of the packages built from this source, you must upgrade all of them, so you simply need to get and install the same version of the other packages built from this source, so they are all on the same version.

2
  • thanks, yes running tmux 2.1 wasn't critical for me, so I was able to fix this issue by simply removing tmux 2.1 with dpkg --force-all then use apt to downgrade back to version 5.xx of libtinfo5, and install the distro provided tmux. But this issue was trivial what I was really interested to know about is the fact that two packages can't co-exist within Ubuntu's package managed ecosystem. This obviously has major consequences, but also explains so many issues and comments etc that previously didn't make sense! Apr 18, 2016 at 2:20
  • @the_velour_fog, note that some packages ( mostly libraries, bug gcc is usually an application that does this ) are given a new name and store their files in a different place so that you can install two versions at the same time. This is mostly done when a library makes a change that is not backward compatible. In that case you might see a "libfoo4" whose version is 4.5.6, and a "libfoo5" package, whose version is 5.1.2, and you can have both installed so that packages that need the older, incompatible version of the library can still get it.
    – psusi
    Apr 18, 2016 at 22:26
1

I had the exact same case where I needed to have both PacketTracer 8.1.1 and 8.2.0. Although it was not possible to have both of them with sudo dkpg -i CiscoPacketTracer_820_Ubuntu_64bit.deb since the install flag -i will always do an override, extracting both of them to custom directories and creating the start scripts myself solved the issue and allowed me to have two different versions of the applications.

Supposing I have these these two versions of PacketTracer that I want to use at the same time:

  • CiscoPacketTracer_811_Ubuntu_64bit.deb
  • CiscoPacketTracer_820_Ubuntu_64bit.deb

To keep it organized, I started by creating a custom directory in /opt and changing the ownership of it to my user

sudo mkdir /opt/packettracer
sudo chown sina:sina /opt/packettracer

The trick is to extract the content of the .deb archives and NOT DO AN INSTALL. You can easily achieve that with

dpkg -x CiscoPacketTracer_811_Ubuntu_64bit.deb /opt/packettracer/811
dpkg -x CiscoPacketTracer_820_Ubuntu_64bit.deb /opt/packettracer/820

Usually, you can directly run the executable but that might not always be the case and you might run into some errors, especially when it comes to installing dependencies. One quick workaround I did is to install one of the packages with sudo gdebi CiscoPacketTracer_811_Ubuntu_64bit.deb which will gives me the dependencies, but then I removed the installed PacketTracer with sudo dpkg -r packettracer. I still had the dependencies however.

You can also run into a use-case specific issue where the library has a wrapper script that it calls. I can't talk about every use case, but for PacketTracer for example I ended up creating a start.sh script at the /opt/packettracer directory that accepts the directory of the version I want to run.

I can then directly run both versions with

/opt/packettracer/start.sh 811
/opt/packettracer/start.sh 820

For completeness, I found the initial script by doing a classic installation with dkpg -i then typing which packettracer. I then took the script and modified it into the following:

#!/bin/bash

if [[ ! -d $1 ]]; then
        echo "Cannot start packettracer. Invalid directory for first argument! $1";
        exit 1;
fi;

echo "Custom Script: Starting Packet Tracer $1"
PREFIX=/opt/packettracer/$1

PTDIR=$PREFIX/opt/pt

export LD_LIBRARY_PATH=$PREFIX/opt/pt/bin
pushd $PREFIX/opt/pt/bin > /dev/null
$PREFIX/opt/pt/bin/PacketTracer "$@" > /dev/null 2>&1
popd > /dev/null
2
  • 1
    This was already answered and the answer is a clear NO. Your one example which is not what was asked about might be an exception. The conflicting module the OP asked about can not have 2 versions as most modules can not.
    – David
    Apr 8, 2023 at 16:50
  • 1
    @David, that is exactly so when it comes to modules. I stumbled on the issue initially wanting to install two different versions of a software, not a module per-say which is why I just documented my findings in case someone (or future me) has the same problem again.
    – usersina
    Apr 8, 2023 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .