Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing broken packages in Ubuntu [closed]

Tags:

ubuntu

apt

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 

Output:

(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 

Output: same as above

sudo dpkg -i --force-overwrite package 

Output:

dpkg: error processing archive rvm (--install):  cannot access archive: No such file or directory Errors were encountered while processing:  rvm 

Is there a way to force remove it, ignoring all errors? I'm using Ubuntu 16.04 on WSL.

like image 277
Leo Jiang Avatar asked Jan 24 '18 20:01

Leo Jiang


People also ask

How do you fix unable to correct problems you have held broken packages on Ubuntu 20.04 LTS?

First, try running sudo apt update to update the repository list. Then try installing the package again.


2 Answers

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.

Here are the steps.

  1. Find your package in /var/lib/dpkg/info, for example using: ls -l /var/lib/dpkg/info | grep <package>
  2. Move the package folder to another location, like suggested in the blog post I mentioned before.

    sudo mv /var/lib/dpkg/info/<package>.* /tmp/ 
  3. 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 
like image 200
emont01 Avatar answered Sep 18 '22 23:09

emont01


  1. Install synaptic package manager.

    sudo apt-get install synaptic 
  2. Open synaptic package manager and search for the package which you want to remove or install or change

Done!

like image 32
Ideacon Avatar answered Sep 19 '22 23:09

Ideacon