Broken packages is a common problem in Ubuntu and other similar distros. Sometimes when you install a new application or update the system, you will encounter the error ‘Sub-process /usr/bin/dpkg returned an error code 1’ as happened with a user here :
It may also occur when a package installation becomes corrupted.
In this article, we will try to fix this issue using different solutions.
After every solution provided below, you would need to update the package list and then, when appropriate, install the new package or upgrade.
Read: How to Fix : dpkg was interrupted, you must manually run ‘dpkg –configure -a’ to correct the problem
Solution 1 :Reconfigure Package Database
This solution consists in trying to re-configure the package database. Most likely, it could be that while installing a package, the database got corrupted. Reconfiguring solves the issue is most cases.
Open up your terminal and type in the command below :
sudo dpkg –configure -a
Solution 2: Removing the inconvenient package
Sometimes the package would need to be removed manually. Run the command below for the troublesome package :
$ sudo apt-get remove –purge package_name
This will help in removing all traces of the offensive application.
Solution 3: Corrupted sources file
It could be that the your sources file is corrupted along with some broken packages. In this case, try to remove the corrupted source file by typing in the command below in the terminal:
sudo rm /etc/apt/sources.list
Then, run :
sudo software-properties-gtk
This will open software and updates window and a new sources.list file will be created automatically.
Go ahead and change the server to any other server that suits you. In order to create a new sources.list file, you would need to enable repositories (second box above, i.e. Community-maintained free and open-source software(universe)) .
Check all the boxes shown above and then click on Revert. Finally press the Close button.
Now open up the terminal and type in the command :
sudo apt-get remove –purge your_problematic_package
Then run
sudo apt-get update && sudo apt-get dist-upgrade -y
Finally install your_problematic_package
You may be interested to read : How to install and uninstall applications on Ubuntu ? A Beginner’s guide
Solution 4 : Force install the software
Sometimes, a package installation might have been interrupted previously and could not therefore be resumed. You may try to carry out a force install attempt by running the command below :
sudo apt-get install –f
Solution 5: Remove post info files of the troublesome package
Another solution would be to remove all files associated with the package that is causing problem.Usually, the installation files are located in the file /var/lib/dpkg/info.
sudo ls –l /var/lib/dpkg/info | grep –i package_name
This in turn will generate a list of all references to the package you installed.
Now you would need to delete them by entering the command :
sudo mv /var/lib/dpkg/info/package_name.* /tmp
The files will be removed to the /tmp directory .Now, run a sudo apt the update in order to be able to install the software again on a clean slate :
sudo apt-get update
Solution : 6 : Clean up unused Software Packages
Try to remove unused application packages by running the command :
sudo apt autoremove
For more on the cleanup solution, you may want read our article: How to keep Ubuntu clean.
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.
For what it’s worth. I had the same error but for emby specifically. For some odd reason it didn’t like the username I used so I logged that user out everywhere and it ran fine afterward.