The Linux Page

Upgrade from 18.04 or 20.04 to 22.04 and MPI packages...

What's the Issue?

It looks like there was a bug in the MPI binary package where some alternative created a "same link" issue.

alternatives: error: /var/lib/dpkg/alternatives/mpi corrupt: slave link same as main link

The error says that an "update-alternatives ..." command found an issue trying to create an alternative where the alternative is actually not an alternative.

Did the Upgrade Work?

If you saw many other installations going and this is the last thing you see, then yes, you have your OS upgraded to the newer version. You can reboot and do whatever, but the error above will prevent you from doing futher software updates until corrected.

Solution

The solution is actually very simple, you can just delete the file referenced above, or at least rename it:

sudo mv /var/lib/dpkg/alternatives/mpi /var/lib/dpkg/alternatives/mpi.hide

Once that file is out of the way, you will be able to handle the next set of commands to fix the issue. In my case, I just purged the packages:

sudo apt-get purge openmpi-bin openmpi-common

and then reinstalled them:

sudo apt-get install openmpi-bin openmpi-common

I think that's the cleanest way.

Finishing the Upgrade

Note that this error prevents the standard update from running the last command used to clean up your system of old packages. That means you have many lingering packages on your system. It is safe, although it could create issues long term. To fix the issue, run the auto-remove command:

sudo apt-get autoremove --purge

The --purge is to make sure everything goes with the corresponding package (i.e. all their settings get removed too).

What is Open MPI?

This is an Open Source set of libraries and tools offering a Message Passing Interface (MPI).

This is useful to run software that can make use of multiple CPUs or multiple machines in a LAN to run heavy computations as often done in the scientific community and also by data researchers at many private companies.

The software offers C/C++ extensions which are accessed using the mpicc or mpiCC compilers. It also supports Fortran and it has extensions for python.