Home > OS >  Cannot install php8.1-gd due do dependencies
Cannot install php8.1-gd due do dependencies

Time:09-22

It seems that due to a more advanced (???) dependncy it cannot install php8.1-gd. I tried adding "--no-install-recommends" but id didn't help.

In addition, I had ubuntu 18 and upgraded to 22 (through 20), maybe this is the root of the problem?

> sudo apt install php8.1-gd

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-gd : Depends: php8.1-common (= 8.1.2-1ubuntu2.4) but 8.1.8-1 ubuntu18.04.1 deb.sury.org 1 is to be installed
E: Unable to correct problems, you have held broken packages.

CodePudding user response:

Okay, I solved the issue after a few minutes that I posted the question.

I deleted the "php8.1-common" that I had a feeling it was bad (it referred to the package from ubuntu 18).

sudo apt remove php8.1-common

and php8.1 gd installed with no problem!

sudo apt install php8.1-gd

It also installed php8.1-common as a dependency.

CodePudding user response:

The problem here was that you (maybe inadvertently) told apt to NOT update the php8.1-common package. Since php-8.1-gd requires the newer version apt will check if it can download that newer version. But since it is not allowed to do so it ends up in a state where it can not both install a newer version and not install a newer package.

By telling apt to uninstall the package you remove the restriction on the package. Another option would have been to do sudo apt-mark unhold php-8.1-common (see the accepted answer here)

  • Related