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.
2
Answers
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).
and php8.1 gd installed with no problem!
It also installed php8.1-common as a dependency.
The problem here was that you (maybe inadvertently) told
apt
to NOT update thephp8.1-common
package. Sincephp-8.1-gd
requires the newer versionapt
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 dosudo apt-mark unhold php-8.1-common
(see the accepted answer here)