在 Ubuntu 中删除损坏的软件包 [英] Removing broken packages in Ubuntu
问题描述
当我尝试删除一个包时出现错误,因此它处于损坏状态.我尝试了以下方法:
There was an error when I tried to remove a package, so it was left in a broken state. I tried the following:
sudo dpkg --remove --force-remove-reinstreq rvm
输出:
(Reading database ... 41743 files and directories currently installed.)
Removing rvm (1.29.3-1) ...
bash: rvm: command not found
dpkg: error processing package rvm (--purge):
subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
rvm
.
sudo dpkg --purge rvm
输出:同上
sudo dpkg -i --force-overwrite package
输出:
dpkg: error processing archive rvm (--install):
cannot access archive: No such file or directory
Errors were encountered while processing:
rvm
有没有办法强制删除它,忽略所有错误?我在 WSL 上使用 Ubuntu 16.04.
Is there a way to force remove it, ignoring all errors? I'm using Ubuntu 16.04 on WSL.
推荐答案
我遇到了这个问题,因为包 rvm 损坏了.我尝试了很多东西,比如 sudo apt install -f
和 sudo dpkg --purge --force-all rvm
但没有任何效果.最后我找到了这篇博文,它解释了 如何删除损坏的Debian/Ubuntu 上的软件包.
I faced this problem with a broken package, rvm. I tried many things like sudo apt install -f
and sudo dpkg --purge --force-all rvm
but nothing worked. Finally I managed to find this blog post that explains how to remove broken packages on Debian/Ubuntu.
这是步骤.
- 在
/var/lib/dpkg/info
中找到您的包,例如使用:ls -l/var/lib/dpkg/info |grep <包>
将包文件夹移动到另一个位置,就像我之前提到的博客文章中所建议的那样.
- Find your package in
/var/lib/dpkg/info
, for example using:ls -l /var/lib/dpkg/info | grep <package>
Move the package folder to another location, like suggested in the blog post I mentioned before.
sudo mv /var/lib/dpkg/info/<package>.* /tmp/
运行以下命令:
Run the following command:
sudo dpkg --remove --force-remove-reinstreq <package>
例如,我通过在终端中执行以下命令解决了我的问题:
So as an example I solved my problem by executing the following commands in a terminal:
sudo mv /var/lib/dpkg/info/rvm.* /tmp/
sudo dpkg --remove --force-remove-reinstreq rvm
这篇关于在 Ubuntu 中删除损坏的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!