当尝试安装某个软件包的较新或较旧版本时,为什么会出现 APT 错误“您持有损坏的软件包”?

当尝试安装某个软件包的较新或较旧版本时,为什么会出现 APT 错误“您持有损坏的软件包”?

我目前有一个 Debian 9 系统,并从官方存储库安装了 LAMP 堆栈(Apache 2.4.25、PHP 7.0.33、MariaDB 10.1.38)

我需要安装 PHP 7.3,因为应用程序需要它。所以我按照本教程它基本上包括添加一个包含 PHP 7.3 软件包的 Stretch 存储库。

但是,运行时apt install php7.3,我得到以下信息:

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:
 php7.3 : Depends: libapache2-mod-php7.3 but it is not going to be installed or
                   php7.3-fpm but it is not going to be installed or
                   php7.3-cgi but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

如果我尝试运行apt install libapache2-mod-php7.3,我会得到:

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:
 libapache2-mod-php7.3 : Depends: php7.3-cli but it is not going to be installed
                         Depends: libpcre2-8-0 (>= 10.32) but 10.22-3 is to be installed
E: Unable to correct problems, you have held broken packages.

此时,我猜最好不要尝试强制安装软件包——如果没有问题,安装就会顺利进行。

我尝试使用 aptitude 卸载当前版本的 PHP 和 Apache,但似乎没有什么能真正帮助我。但是,当我在全新安装上执行本教程并运行上述命令时,一切似乎都运行正常。

然而,这远非我第一次遇到此错误;当我尝试安装某些软件包的旧版本时,我经常遇到此错误,并且我不得不寻找解决方法,例如重新安装整个旧系统。

所以这让我觉得我不了解 APT 的工作原理。我从来没有像消息所暗示的那样“保留”过软件包,那么究竟是什么导致了这个错误?这是因为所有存储库中都缺少一些依赖项吗?还是因为一些软件包相互冲突?由于所有软件包都标有其版本,除了旧版本/新版本之外,它们不能单独安装吗?

答案1

您是从 packages.sury.org 安装的,对吗?

对我来说这有帮助

编辑 /etc/apt/preferences

Package: *
Pin: release a=stable
Pin-Priority: 1001

Package: *
Pin: origin packages.sury.org
Pin-Priority: 1010

嗯,老实说,起初我把文件移走了,然后安装了 libpcre3,然后从 sury.org 安装,然后我将文件移回来并添加了 sury 的 Pins。

相关内容