0
$ 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.  

1 Answer 1

1

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.

2
  • Thank you Thomas, but I don't know how I got that repo. I have only installed Ubuntu, and its repos, and upgraded it in April. Can I uninstall it and reinstall Ubuntu based repos? Sep 15, 2023 at 20:41
  • @HalBurgiss you can but you can just run cd /etc/apt && grep -r 'sury' and remove the files that contain that line (EXCEPT sources.list, in which case edit that file and remove the lines referencing the sury repos). Then uninstall PHP, run sudo apt update && sudo apt clean and then reinstall your PHP, which will use the standard repositories. No need to reinstall the whole OS though.
    – Thomas Ward
    Sep 15, 2023 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .