Cannot Install php8.1-bcmath on Ubuntu 22.04

$ sudo apt install php8.1-bcmath
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php8.1-bcmath : Depends: php8.1-common (= 8.1.2-1ubuntu2.14) but 8.1.18-1+ubuntu18.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.

I indeed have 8.1.18-1+ubuntu18.04.1 but see no way to upgrade to 8.1.2-1ubuntu2.14. I have run apt update and apt upgrade. When I try to reinstall php, I get this:

$ sudo apt reinstall php8.1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Reinstallation of php8.1 is not possible, it cannot be downloaded.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.  
Asked By: Hal Burgiss

||

You are using the deb.sury.org PHP repositories/PPAs.

The bcmath library is NOT available on the sury.org repositories, and is only available as part of the Ubuntu repositories. You cannot mix and match the PHP 8.1 packages in the Ubuntu repository with the deb.sury.org repositories’ core PHP libraries.

Either the deb.sury.org repositories need to provide an upgraded version of php8.1-bcmath, or you have to remove the deb.sury.org PHP repositories and revert to 8.1.2 PHP from the Ubuntu repositories.

There is no other ‘hybrid’ solution here.

Answered By: Thomas Ward
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.