Handling multiple versions of the same software


It is fairly common to be in a situation where you want to be able to use any of several different versions of the same software. The problem with this in Pacman is that different versions of the same software typically are incompatible in the sense that they use the same environment variables, put the same binaries in the users path etc. Nevertheless, you can have multiple versions of the same software in an installation and chose which version that you want to actually setup and use. This tutorial illustrates a number of points:

The example we will use is different versions of Python as available in the Demo cache. As we will be doing multiple installs, let's begin by making a snapshot so that things go faster. Do
% pacman -snap Demo
If you browse the snapshot with
% pacman -d version -lc Demo.snap
You'll see that there are three versions of Python packages in the snapshot.

Now let's see what happens if you proceed naively and -get multiple versions of Python. First try

% pacman -get "Demo.snap:Python | version ('2.1.3')"
% pacman -l
[*] Python, in cache [/home/youssef/Pacman/work]
           version = 2.1.3
    [*] PythonDocs, in cache [/home/youssef/Pacman/work]
               version = 2.1.3
Now, however, if you install another version you will see something like this
% pacman -get "Demo.snap:Python | version('2.2.3')"
Package [Demo.snap:Python] not [installed]:
    Can't add [/home/youssef/Pacman/work/python-2.1.3/python-2.1.3/bin] to path variable [PATH]
        Path [pydoc] in also in [/home/youssef/Pacman/work/python-2.2.3/python-2.2.3/bin].
        Path [python] in also in [/home/youssef/Pacman/work/python-2.2.3/python-2.2.3/bin].
        Path [python2] in also in [/home/youssef/Pacman/work/python-2.2.3/python-2.2.3/bin].
This is Pacman's way of telling you that there there there is a clash between packages. In this particular case, both Python packages add their /bin directories to the standard Unix $PATH with a Pacman path statement. The two bin directories both contain pydoc, python and python2 and one or the other will be ignored. To see how to solve this, let's start again by first doing
% pacman -remove
and then -install-ing the three packages one at a time rather than using -get. Do
% pacman -install "Demo.snap:Python | version('2.1.3')"
% pacman -install "Demo.snap:Python | version('2.2.3')"
% pacman -install "Demo.snap:Python | version('2.3.4')"
and you will find that this works. The reason is that -get attempts to create a coherent total environment for the installation and create setup scripts while -install does not. Now you have three versions of Python installed in your installation. How, however, to do you set up to use a particular version? The answer is shown in the figure.

If the installation you have created is ../work, cd elsewhere and do

% pacman -get "../work:Python | version('2.2.3')"
just as if you were installing the software. Although nothing is actually installed, Pacman creates a consistent environment for you, using the contents of ../work and creates setup scripts that do the right things to use the software in the original installation.

This tutorial illustrates the sense in which "setting up" software is a special case of installation from the Pacman point of view. With Pacman, installation, configuration and setup are all done with within the same framework.


Pacman Headquarters