Recently I ran into a problem while setting up an application on my local machine with composer install. The problem ?
composer install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for php-amqplib/php-amqplib v2.7.2 -> satisfiable by php-amqplib/php-amqplib[v2.7.2]. - php-amqplib/php-amqplib v2.7.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system. Problem 2 - php-amqplib/php-amqplib v2.7.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system. - php-amqplib/rabbitmq-bundle v1.14.2 requires php-amqplib/php-amqplib ^2.6 -> satisfiable by php-amqplib/php-amqplib[v2.7.2]. - Installation request for php-amqplib/rabbitmq-bundle v1.14.2 -> satisfiable by php-amqplib/rabbitmq-bundle[v1.14.2]. To enable extensions, verify that they are enabled in your .ini files: - /etc/php/7.2/cli/php.ini ...
This was a fairly common problem recently, I faced this while running composer, so finally I decided to figure out what exactly was the issue. I am running php7.2 on Ubuntu 19.10 and I actually downgrade it from php7.3 because of some apps i have been working on were not really doing well with 7.3 and It was not my choice to upgrade them, open source things may take sweet time to move. Anyhow, I decided to check what was the issue and first instinct was to install it simply using install command.
sudo apt-get install php7.2-bcmath
and crash.. what i got was something weird..
sudo apt install php7.2-bcmath Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package php7.2-bcmath E: Couldn't find any package by glob 'php7.2-bcmath' E: Couldn't find any package by regex 'php7.2-bcmath'
My next move to see if the extension exists in the apt cache and perhaps i can see which version so I ran following command with result:
apt-cache search php | grep bcmath php-bcmath - Bcmath module for PHP [default] php7.3-bcmath - Bcmath module for PHP
So, it exists but not for 7.2 so what do I do ?
I googled and came across several posts telling me to run apt for 7.2 but what do I do if it doesn’t exists with that version. So here is how i solved it. I decided to add repository for php 7.2 and then try again. And as you can see the result below:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.2-bcmath Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libapache2-mod-php7.2 libpcre3 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-zip The following NEW packages will be installed: php7.2-bcmath The following packages will be upgraded: libapache2-mod-php7.2 libpcre3 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-zip 14 upgraded, 1 newly installed, 0 to remove and 102 not upgraded. Need to get 5,004 kB of archives. After this operation, 109 kB of additional disk space will be used. Do you want to continue? [Y/n] y
So I just wanted to share the result because there were lot of repetitive answers all over stack overflow and google but I had to compile a common result for myself after trying out everything. I am putting it out there in hope that it will help someone.