- How to fix a broken package, when «apt-get install -f» does not work? [duplicate]
- How to Fix Broken Packages in Ubuntu
- Check for Updates
- Force APT to Correct Missing Dependencies or Broken Packages
- Force Reconfigure or Remove Broken Packages with DPKG
- Resolve DPKG Lock Issue
- Use apt-get to fix missing and broken packages
- Using apt-get to fix missing and broken packages
- Other methods
- Method 2:
- About the author
- Karim Buzdar
How to fix a broken package, when «apt-get install -f» does not work? [duplicate]
I tried to install Scala with the typesafe stack and got into trouble. Now I cannot do much with apt (except update), the broken package seems to be impossible to remove/clean: Here’s the result of apt-get -f install :
$ sudo apt-get -f install Reading package lists. Done Building dependency tree Reading state information. Done Correcting dependencies. Done The following packages were automatically installed and are no longer required: gstreamer0.10-fluendo-mp3:i386 scala-library liboil0.3:i386 Use 'apt-get autoremove' to remove them. The following extra packages will be installed: scala The following NEW packages will be installed: scala 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. 4 not fully installed or removed. Need to get 21.5 MB of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue [Y/n]? Y Get:1 http://apt.typesafe.com/ unicorn/main scala all 2.9.2-400 [21.5 MB] Fetched 21.5 MB in 13s (1,567 kB/s) (Reading database . 329381 files and directories currently installed.) Unpacking scala (from . /scala_2.9.2-400_all.deb) . dpkg: error processing /var/cache/apt/archives/scala_2.9.2-400_all.deb (--unpack): trying to overwrite '/usr/share/java/scala-partest.jar', which is also in package scala-library 2.9.1.dfsg-3 dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/scala_2.9.2-400_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
$ apt-get autoremove E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? phdp@desktop:~/work/manuscripts/ideas/ibm_food_webs$ sudo apt-get autoremove Reading package lists. Done Building dependency tree Reading state information. Done You might want to run 'apt-get -f install' to correct these. The following packages have unmet dependencies: typesafe-stack : Depends: scala but it is not installed E: Unmet dependencies. Try using -f.
How to Fix Broken Packages in Ubuntu
Linux packages are compressed archives containing programs and files necessary to run them. The package distribution system is designed to be robust and simplify the application installation process.
However, a bad internet connection or misconfigured third-party installers can corrupt packages and cause problems on your system.
This article will show you how to troubleshoot and fix broken packages on Ubuntu using the available APT and DPKG tools.
Check for Updates
Start troubleshooting by rebuilding the list of dependencies. The —fix-missing option tells APT to ignore missing packages. The option ensures the update process is performed without APT returning an error.
sudo apt update --fix-missing
Force APT to Correct Missing Dependencies or Broken Packages
Missing package dependencies are a common reason for package-related errors.
1. Use apt install with the -f flag to tell APT to locate the missing packages and install them.
APT lists the missing packages on your system.
2. Press ENTER to start the installation.
Note: If troubleshooting has led to Ubuntu needing to be reinstalled, please refer to our reinstallation guide How to Reinstall Ubuntu.
Force Reconfigure or Remove Broken Packages with DPKG
Broken packages may cause package manager configuration problems.
1. Reconfigure DPKG, the base package management system, with the following command:
2. Check if DPKG marked some packages as needing a reinstall.
3. If the command above returns a list of one or more packages, try removing the packages by typing:
sudo dpkg --purge --force-all [package-name]
The example below shows how to remove the corrupted vlc-plugin-base package.
Warning: The dpkg —purge —force-all command removes a package even if the removal causes further dependency issues. Use the command with care.
4. After you finish troubleshooting, run the following command to clean up the system:
5. Then update the repositories again:
Resolve DPKG Lock Issue
The DPKG lock error appears when trying to install a package while another process is using DPKG.
However, sometimes the error occurs even if no other processes are using the package management system.
1. To fix the problem, remove the lock file manually:
sudo rm /var/lib/apt/lists/lock
2. Also, remove the lock in cache:
sudo rm /var/cache/apt/archives/lock
Deleting the lock enables you to use APT and DPKG again.
The article provided common ways of resolving problems caused by broken packages on Ubuntu.
For more information related to package management on Ubuntu, read:
Use apt-get to fix missing and broken packages
Package managers in Linux are the most useful programs that are used to add additional capabilities in a system. They can be used for installing, removing, updating, and upgrading the packages, also featuring the dependency resolution capabilities. However, like any other program, things can also go wrong with these package managers. Sometimes, while updating or installing a third-party program, installation goes wrong and results in errors that require you to install the missing dependencies and broken packages. This error may also occur because of improper package management, incorrect installation of packages, and installation of unnecessary packages. Whatever the reason may be, the problem is that you receive an error and left with a condition where you cannot add a new package nor update or delete the existing packages until you fix the problem.
In this article, we will learn how to fix the missing dependencies and broken packages using the apt-get command. Note that, we have run the commands and procedure mentioned in this article on a Debian 10 system. The same procedure can be followed in Ubuntu and older Debian versions.
We will use the command-line Terminal for trying the solutions and fixing the problem. To open the Terminal application in Debian, hit the super key on the keyboard and search for it using the search bar that appears. When the search result appears, click on the Terminal icon to open it.
Using apt-get to fix missing and broken packages
Apt-get is a Terminal based package management tool used for installing, upgrading, and removing packages. Along with these features, it also has flags that can be used for fixing missing dependencies and broken packages.
Use the “fix-missing” option with “apt-get update” to run the updates and ensure the packages are up to date and there is no new version available for the packages.
Once you are done with the update, execute the below command in order to force the package manager to find any missing dependencies or broken packages and install them.
Another approach to solving the broken package issue via apt-get is to edit the “/etc/apt/sources/list” file and adding sites with newer versions of packages available. Then running the “apt-get update” command to update the repository list.
If the above method does not fix the issue of broken dependencies and broken packages and still you are receiving the error, then try the following methods.
Other methods
In this method, we will use the “apt-get autoremove” and the “dpkg” in order to fix missing dependencies and broken packages.
1. Update the repository index by executing the below command in Terminal:
2. Next, execute the below command to clean out the local repository:
3. Execute the below command to remove all the unnecessary packages that are no longer needed:
The above command will display the unmet dependencies or broken package’s name.
4. Then try executing the below command in Terminal to force remove the broken package:
Method 2:
In the following method, we will use the “dpkg—configure” command in order to fix missing dependencies and broken packages.
Dpkg is a package management tool that can be used to install, remove and manage packages. Similar to apt-get, it can also help to fix broken packages and missing dependencies. If you receive some errors while installing or updating the packages, try the following solution with dpkg:
1. Execute the below command in the Terminal to reconfigure all the partially installed packages.
If the above command does not work, like in our case and you see similar results displaying the erroneous package, then try removing the package.
2. Execute the below command in Terminal in order to remove the erroneous package.
3. Then use the below command to clean out the local repository:
After trying any one of the above solutions, run the update command to ensure the dependencies are resolved and broken packages are fixed or removed.
Fixing the dependency and broken packages errors and then returning the system to the normal state may take hours. Sometimes it gets so complicated that when you finally fix it, you feel so lucky. We have presented some solutions regarding this error, so please give them a try. If you know some of the possible solutions we did not mention, please let us know in the comments.
About the author
Karim Buzdar
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.