I hope this can be useful to others with the same problem that seemed unsolvable to me and which I found when trying to install ROS Humble on Ubuntu 22.04 LTS.
I had made an upgrade from Ubuntu 18.04 to 20.04 and then to 22.04 LTS.
This type upgrade is prone to leave some inconsistencies in the system and may be the reason why none of the solutions I found on the web, and which applied to Ubuntu 22.04 could solve the issue. I also asked ChatGPT for help but it did not found a solution (although its hints seemed correct for simpler cases).
None of the above-posted solutions solved my problem but the one by America (acirema) put me on the right track to address it.
The file /var/lib/dpkg/alternatives/mpi did not exist in my system; instead the file installed was mpi-x86_64-linux-gnu
did not solve the problem. When trying to re-install openmpi-bin the system detected it was already installed issuing the message 'openmpi-bin is already the newest version (4.1.2-2ubuntu1)' but did not detect alternatives, outputing as before:
Setting up libhdf5-openmpi-dev (1.10.7+repack-4ubuntu2) ...
update-alternatives: error: no alternatives for mpi
dpkg: error processing package libhdf5-openmpi-dev (--configure):
installed libhdf5-openmpi-dev package post-installation script subprocess returned error
exit status 2
Errors were encountered while processing:
libhdf5-openmpi-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
I finally solved the problem using the Synaptic package manager: Package / Mark for Complete Removal. Then installed openmpi-bin again and after that I found the above mentioned mpi* files that are expected to exist on Ubuntu 22.04 and all my packages are working correctly now.
I hope this can be useful to others with the same problem that seemed unsolvable to me and which I found when trying to install ROS Humble on Ubuntu 22.04 LTS.
I had made an upgrade from Ubuntu 18.04 to 20.04 and then to 22.04 LTS.
This type upgrade is prone to leave some inconsistencies in the system and may be the reason why none of the solutions I found on the web, and which applied to Ubuntu 22.04 could solve the issue. I also asked ChatGPT for help but it did not found a solution (although its hints seemed correct for simpler cases).
None of the above-posted solutions solved my problem but the one by America (acirema) put me on the right track to address it.
The file /var/lib/ dpkg/alternativ es/mpi did not exist in my system; instead the file installed was mpi-x86_ 64-linux- gnu
Applying: mpirun. openmpi mpicc.openmpi
sudo update-alternatives --remove mpirun /usr/bin/
sudo update-alternatives --remove mpi /usr/bin/
sudo dpkg --configure -a
or simply removing the files as suggested with (Note of caution: I always backup system files before deleting them):
sudo rm /etc/aternative s/mpi* dpkg/alternativ es/mpi*
sudo rm -f /var/lib/
did not solve the problem. When trying to re-install openmpi-bin the system detected it was already installed issuing the message 'openmpi-bin is already the newest version (4.1.2-2ubuntu1)' but did not detect alternatives, outputing as before:
Setting up libhdf5-openmpi-dev (1.10.7+ repack- 4ubuntu2) ... alternatives: error: no alternatives for mpi
update-
dpkg: error processing package libhdf5-openmpi-dev (--configure):
installed libhdf5-openmpi-dev package post-installation script subprocess returned error
exit status 2
Errors were encountered while processing:
libhdf5-openmpi-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
I finally solved the problem using the Synaptic package manager: Package / Mark for Complete Removal. Then installed openmpi-bin again and after that I found the above mentioned mpi* files that are expected to exist on Ubuntu 22.04 and all my packages are working correctly now.