Ubuntu 上的 libpcre2-dev 依赖项未满足问题

libpcre2-dev dependencies unmet problem on Ubuntu

我的问题是我想在 ubuntu 上安装 OwnCloud,长话短说,我不得不将 PHP 从 v8 降级到 v7.2,我发现了问题

老实说,我真的不太清楚这个问题,但是当我 运行 升级命令时,例如,我得到这个错误

You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libpcre2-dev : Depends: libpcre2-posix2 (= 10.39-2+ubuntu21.10.1+deb.sury.org+1) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

即使我 运行 apt --fix-broken install 命令,我也收到此消息:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
  libpcre2-posix3
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libpcre2-posix2
The following NEW packages will be installed:
  libpcre2-posix2
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
12 not fully installed or removed.
Need to get 0 B/8,300 B of archives.
After this operation, 33.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 251030 files and directories currently installed.)
Preparing to unpack .../libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre2-posix2:amd64 (10.39-2+ubuntu21.10.1+deb.sury.org+1) ...
dpkg: error processing archive /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.
org+1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/x86_64-linux-gnu/libpcre2-posix.so.3', which is also in package libpcre
2-posix3:amd64 10.37-0ubuntu2
Errors were encountered while processing:
 /var/cache/apt/archives/libpcre2-posix2_10.39-2+ubuntu21.10.1+deb.sury.org+1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我想解决这个问题,但最重要的是,我想了解更多有关 Linux 的信息,因此欢迎任何解释。谢谢!

早些时候我想降级时遇到了同样的问题 php8.0 -> php7.4.

以下命令解决了问题:

 srcFile="/etc/apt/sources.list.d/ondrej-ubuntu-php-impish.list"

 sed -i 's/# //g' ${srcFile}
 apt update
 apt autoclean
 apt autoremove -f -y 
 

如果一切顺利,您仍然需要 php7.2,请参阅下文:


  1. 如果使用php-gearman,需要添加ppa:ondrej/pkg-gearman
  2. 如果你使用的是apache2,建议添加ppa:ondrej/apache2
  3. 如果你使用的是nginx,建议添加ppa:ondrej/nginx-mainline

安装php7.2:

 LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php <<< "2"
 apt install php7.2 -y

我遇到了相反的情况(posix3 而不是 posix2):

The following package was automatically installed and is no longer required:
  libpcre2-posix2
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
  libpcre2-posix3
The following NEW packages will be installed:
  libpcre2-posix3

这对我有用。 (对你来说是 libpcre2-posix3

sudo dpkg --purge libpcre2-posix2
sudo apt --fix-broken install

之后一切都很好。

希望对您有所帮助。