我在使用 Ubuntu 20.04,想做一些软件包更新。我突然收到此错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
libpcre2-dev : Depends: libpcre2-posix3 (= 10.39-3+ubuntu20.04.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).
所以我运行了命令:sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following package was automatically installed and is no longer required:
libpcre2-posix2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
libpcre2-posix3
The following NEW packages will be installed:
libpcre2-posix3
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
11 not fully installed or removed.
Need to get 0 B/8,068 B of archives.
After this operation, 34.8 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 130271 files and directories currently installed.)
Preparing to unpack .../libpcre2-posix3_10.39-3+ubuntu20.04.1+deb.sury.org+1_amd64.deb ...
Unpacking libpcre2-posix3:amd64 (10.39-3+ubuntu20.04.1+deb.sury.org+1) ...
dpkg: error processing archive /var/cache/apt/archives/libpcre2-posix3_10.39-3+ubuntu20.04.1+deb.sury.org+1_amd64.deb (--unpack):
trying to overwrite '/usr/lib/x86_64-linux-gnu/libpcre2-posix.so.3.0.1', which is also in package libpcre2-posix2:amd64 10.39-2+ubuntu20.04.1+deb.sury.org+1
Errors were encountered while processing:
/var/cache/apt/archives/libpcre2-posix3_10.39-3+ubuntu20.04.1+deb.sury.org+1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
但仍然失败。
有人能在这件事上帮助我吗?
答案1
通过运行修复了此问题:
sudo dpkg --purge libpcre2-posix2
由于 libpcre2-posix2 不再需要
进而
sudo apt --fix-broken install
发现 Linux 无法自行解决这个问题,这很奇怪。