2

This question already has an answer here:

So once again apt-get bothered me with the infamous message that package installation failed because a dependency “is not going to be installed”:

~ $ sudo apt-get install php-apcu
Reading package lists... Done
Building dependency tree       
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:
 php-apcu : Depends: phpapi-20151012
            Recommends: php-apcu-bc but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

As I understand, default is to install all missing dependencies along with the requested packages. What would cause apt-get to refuse to install certain dependencies? (And if there is more than one thing leading to this, how can I find out which it is?)

marked as duplicate by Faheem Mitha, Stephen Rauch, Jeff Schaller, Anthon, GAD3R Sep 23 '17 at 19:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please add your linux distro and your sources.list – GAD3R Sep 23 '17 at 18:05
  • 1
    See the question at the bottom of unix.stackexchange.com/tags/apt/info. Namely unix.stackexchange.com/questions/121180/… – Faheem Mitha Sep 23 '17 at 18:06
  • @FaheemMitha Thanks for the pointer—this is even more detailed than what I found out by myself. IMHO the question really should quote the message “but it is not going to be installed”. Otherwise, it’ll drown in a flood of other answers which are all down the lines of “you installed the wrong package/from the wrong repo” without actually explaining the background. – user149408 Sep 23 '17 at 18:24
  • 1
    @GAD3R Not posting further details was intentional—for a moment I even thought about substituting the package names—because I’m not asking for anyone to troubleshoot this particular issue (and leave me equally helpless the next time I receive this message). What I was looking for was some insight into the possible causes for this message—which I now got. – user149408 Sep 23 '17 at 18:29
1

TL;DR: <foobar> is not going to be installed is a hint that the <foobar> dependency itself has some dependency which cannot be satisfied for some reason.

Re-running apt-get and explicitly including the problematic dependency in the command line should give you a better idea of where the issue is.


In the above case, I got this:

~ $ sudo apt-get install php-apcu php-apcu-bc
Reading package lists... Done
Building dependency tree       
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:
 php-apcu : Depends: phpapi-20151012
 php-apcu-bc : Depends: phpapi-20151012
E: Unable to correct problems, you have held broken packages.

and:

~ $ sudo apt-get install php-apcu php-apcu-bc phpapi-20151012
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package phpapi-20151012 is a virtual package provided by:
  php7.0-phpdbg 7.0.22-3
  php7.0-fpm 7.0.22-3
  php7.0-cli 7.0.22-3
  php7.0-cgi 7.0.22-3
  libphp7.0-embed 7.0.22-3
  libapache2-mod-php7.0 7.0.22-3
You should explicitly select one to install.

E: Package 'phpapi-20151012' has no installation candidate

So the issue here is that the originally requested package php-apcu depends on php-apcu-bc, which in turn depends on phpapi-20151012. The latter is not a directly installable package, but a feature provided by multiple packages, thus apt-get cannot automatically determine what it needs to install.

The root cause in this specific case is that I tried to install php-apcu, a PHP7 package, on a system running PHP5, for which the correct package would be php5-apcu.

Not the answer you're looking for? Browse other questions tagged or ask your own question.