38

I have just upgraded my Kubuntu from 18.04 to 20.04. Unfortunately there is an error that keeps showing up everytime I use apt upgrade or installing something with apt. The error is:

update-alternatives: error: /var/lib/dpkg/alternatives/mpi corrupt: slave link same as main link /usr/bin/mpicc

It has been reported and yet has not been patched until the time I write this question.

After more than a month trying various ways to deal with this problem I finally found the solution as you can see below. I hope it is useful for you who met with the same problem.

Muhammad Radifar
  • 1,267
  • 1
  • 7
  • 8
  • Had this error also. Other errors that popped up with this one (for google as you have the perfect answer) were "E: Internal Error, No file name for openmpi-bin:amd64" and "/usr/sbin/dpkg-reconfigure: openmpi-bin is broken or not fully installed" and "dpkg: error processing package openmpi-bin" – Bastion Jun 16 '23 at 02:20

1 Answers1

75

First remove the update-alternatives for openmpi:

sudo rm -f /etc/alternatives/mpi* /var/lib/dpkg/alternatives/mpi*

Then install openmpi-bin again:

sudo apt install open-mpi

answer Y when asked for confirmation.

In Ubuntu 22.04 (or if the above line doesn't work) - try this instead:

sudo apt install openmpi-bin
RunOrVeith
  • 4,487
  • 4
  • 32
  • 50
Muhammad Radifar
  • 1,267
  • 1
  • 7
  • 8
  • 20
    sudo rm /var/lib/dpkg/alternatives/mpi; sudo apt install openmpi-bin – Ted Feng Oct 29 '20 at 00:03
  • 29
    Resolved a similar issue for me upgrading from 20.04 to 22.04 – ScottMcC Jun 12 '22 at 13:20
  • Thank you for this - and ditto what @ScottMcC said above, removing the alternatives links resolved an error I was encountering going from Ubuntu 20.04 to 22.04 as well. – dga Dec 21 '22 at 19:35