由于我意外删除了 /usr/include/stdio.h,因此我尝试重新安装 libc6-dev,并且收到以下消息:
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu artful-updates/main amd64 libc6-dev amd64 2.26-0ubuntu2.1 [2,526 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu artful-updates/main i386 libc6-dev i386 2.26-0ubuntu2.1 [2,144 kB]
Fetched 4,669 kB in 1s (4,293 kB/s)
(Reading database ... 910409 files and directories currently installed.)
Preparing to unpack .../libc6-dev_2.26-0ubuntu2.1_amd64.deb ...
Unpacking libc6-dev:amd64 (2.26-0ubuntu2.1) over (2.26-0ubuntu2.1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-dev_2.26-0ubuntu2.1_amd64.deb (--unpack):
trying to overwrite shared '/usr/include/stdlib.h', which is different from other instances of package libc6-dev:amd64
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../libc6-dev_2.26-0ubuntu2.1_i386.deb ...
Unpacking libc6-dev:i386 (2.26-0ubuntu2.1) over (2.26-0ubuntu2.1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-dev_2.26-0ubuntu2.1_i386.deb (--unpack):
trying to overwrite shared '/usr/include/stdlib.h', which is different from other instances of package libc6-dev:i386
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/libc6-dev_2.26-0ubuntu2.1_amd64.deb
/var/cache/apt/archives/libc6-dev_2.26-0ubuntu2.1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
我已经搜索过解决方案,但那些解决方案涉及使用apt install -f
,而不是重新安装包。
答案1
如果你确定这确实是你想做的(见上面的评论),你可以这样做
sudo apt-get -o Dpkg::Options::="--force-overwrite" install libc6-dev-amd64 libc6-dev-i386
这会将 --force-overwrite 标志传递给 dpkg,从而允许一个包覆盖另一个包的文件。当然,如果您有 deb 文件,您可以dpkg
直接使用底层命令:
sudo dpkg -i --force-overwrite libc6-dev-amd64 libc6-dev-dev-i386