apt-get:“……但不会安装”的原因

apt-get:“……但不会安装”的原因

因此,apt-get 再次困扰我一个臭名昭著的消息,即软件包安装失败,因为依赖项“不会安装”:

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

据我了解,默认是安装所有缺少的依赖项以及请求的包。什么会导致 apt-get 拒绝安装某些依赖项? (如果有不止一件事导致这种情况,我怎样才能找出是哪一件事?)

答案1

长话短说: <foobar> is not going to be installed暗示<foobar>依赖本身具有某种依赖,由于某种原因无法满足。

重新运行apt-get并在命令行中显式包含有问题的依赖项应该可以让您更好地了解问题所在。


在上面的例子中,我得到了这个:

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

和:

~ $ 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

所以这里的问题是最初请求的包php-apcu依赖于php-apcu-bc,而包又依赖于phpapi-20151012。后者不是一个可直接安装的软件包,而是由多个软件包提供的功能,因此 apt-get 无法自动确定需要安装什么。

这个特定案例的根本原因是我尝试php-apcu在运行 PHP5 的系统上安装 PHP7 软件包,正确的软件包是php5-apcu.

相关内容