我在 Ubuntu 22.04 中更新软件时出现错误提示。我该如何修复错误:“尝试覆盖与软件包 NAME 的其他实例不同的共享文件”。示例如下:
trying to overwrite shared '/usr/lib/llvm-14/lib/libunwind.so.1.0',
which is different from other instances of package libunwind-14:i386
...
本问题底部的完整终端输出
Errors were encountered while processing:
/var/cache/apt/archives/libunwind-14_1%3a14.0.0-1ubuntu1_i386.deb
/var/cache/apt/archives/libc++abi1-14_1%3a14.0.0-1ubuntu1_i386.deb
/var/cache/apt/archives/libc++1-14_1%3a14.0.0-1ubuntu1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
屏幕 1
屏幕 2
屏幕 3
完整输出:
lis@lenovo:~$ sudo apt-get install -f
[sudo] password for lis:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
libc++1-14:i386 libc++abi1-14:i386 libunwind-14:i386
Suggested packages:
clang:i386
The following NEW packages will be installed:
libc++1-14:i386 libc++abi1-14:i386 libunwind-14:i386
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 0 B/391 kB of archives.
After this operation, 1 475 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 215160 files and directories currently installed.)
Preparing to unpack .../libunwind-14_1%3a14.0.0-1ubuntu1_i386.deb ...
Unpacking libunwind-14:i386 (1:14.0.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libunwind-14_1%3a14.0.0-1ubuntu1_i386.deb (--unpack):
trying to overwrite shared '/usr/lib/llvm-14/lib/libunwind.so.1.0', which is different from other instances of package libunwind-14:i386
Preparing to unpack .../libc++abi1-14_1%3a14.0.0-1ubuntu1_i386.deb ...
Unpacking libc++abi1-14:i386 (1:14.0.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libc++abi1-14_1%3a14.0.0-1ubuntu1_i386.deb (--unpack):
trying to overwrite shared '/usr/lib/llvm-14/lib/libc++abi.so.1.0', which is different from other instances of package libc++abi1-14:i386
Preparing to unpack .../libc++1-14_1%3a14.0.0-1ubuntu1_i386.deb ...
Unpacking libc++1-14:i386 (1:14.0.0-1ubuntu1) ...
dpkg: error processing archive /var/cache/apt/archives/libc++1-14_1%3a14.0.0-1ubuntu1_i386.deb (--unpack):
trying to overwrite shared '/usr/lib/llvm-14/lib/libc++.so.1.0', which is different from other instances of package libc++1-14:i386
Errors were encountered while processing:
/var/cache/apt/archives/libunwind-14_1%3a14.0.0-1ubuntu1_i386.deb
/var/cache/apt/archives/libc++abi1-14_1%3a14.0.0-1ubuntu1_i386.deb
/var/cache/apt/archives/libc++1-14_1%3a14.0.0-1ubuntu1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
您应该删除缓存的版本并重试,因为它们有冲突。
第一的,删除缓存的版本:
sudo rm /var/cache/apt/archives/*.deb
sudo rm -R /var/cache/apt/archives/partial
下一个, 再试一次:
sudo apt update
sudo apt -f install
sudo apt dist-upgrade
如有任何错误,请发布。
编辑(见下面的解决方案):
每个有问题的软件包都是 i386 版本。每个软件包的 amd64 和 i386 版本都包含一个位于相同位置的同名文件,但文件的哈希值不同。对于这些特定的软件包,amd64 和 i386 版本不能共存。
解决方法是删除 i386 版本,除非绝对有必要安装 i386 版本。
只要小心在接受 Y 之前,请务必检查要删除的软件包列表运行后:
sudo apt remove libc++1-14:i386 libc++abi1-14:i386 libunwind-14:i386
在这种特殊情况下,OP 报告说libc++1-14:i386
仅删除即可解决问题。