Как исправить сломанные пакеты в ubuntu
Перейти к содержимому

Как исправить сломанные пакеты в ubuntu

  • автор:

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.

How to fix broken packages in Ubuntu

  • An account with sudo privileges
  • An Ubuntu system

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.

The --fix-missing option tells APT to ignore the missing packages

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.

The apt install tells APT to locate the missing packages and install them

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:

The example below shows how to remove the corrupted vlc-plugin-base package.

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.

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:

2. Also, remove the lock in cache:

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.

Fixing "Unable to correct problems, you have held broken packages" Error in Ubuntu and other Linux Distributions

While there are various ways to install applications in Ubuntu, I prefer to use the apt command in the terminal for installing software.

If you do the same, you may come across a dependency error like this:

Usually on It’s FOSS, you’ll find simple and easy to follow solutions to complicated problems. Unfortunately, this one is not that straightforward.

In this troubleshooting article, I’ll tell you why this error occurs and give some pointers on how to go about solving this issue.

Why do you see the “you have held broken packages” error?

Broken Package Error Ubuntu

You were trying to install an application package, most probably from a PPA or third-party repository.

Applications often need specific versions of libraries and software component (called dependencies). These dependencies may not be part of the application package itself, but they are expected to either be installed on your system already or installed during the installation of the application.

Your Linux system tries to install these dependencies on its own. But if the dependency package version is not available on your system, it gets confused as it has no way to solve this dependency problem.

This is why it informs you that the software you were trying to install depends on XYZ but this XYZ cannot be installed.

Another usecase is when your package can be held is when you try to install two versions of the same software. Say you are installing a specific version of Wine when you have another one installed already.

How to go about fixing the “Unable to correct problems, you have held broken packages” error

You can try a few things to make things work. You need to have some ideas on installing/removing packages in Linux command line to work things out here.

Make sure that your system’s package cache is updated

First, make sure that local package cache is updated. Your system checks this cache for the available packages. It’s possible (but not certain) that the dependency package is seen by the system after the cache update.

Try installing the troublesome package again and see if it fixes the problem.

Install the dependency

If you try to install the troublesome package again and it still complains about the same dependency error than perhaps that dependency is not available for distribution version.

You may use the apt search command see if you could this library from some other package or name:

If the package is available, is it the same version as requested by the package you were trying to install?

Try to install the dependency package and see what happens:

You may encounter a dependency chain. You try to install dependency A but it complains of B. Then you try installing B and it complains of C.

It may also happen that when you try to install package C, it is already installed. Check the version of package C. Is it the same version as required by package B? If yes, then removing C and installing it again could help.

Can you get the missing dependency package from some other source?

If the missing dependency package cannot be found on your system (no results in apt search), you may try to get the dependency package from some place else. I know that’s not very convenient thing to do but you don’t have many options here.

For example, in the case of installing shutter, it complained about libgoo-canvas-perl and this library is no more available on Ubuntu system.

However, since it was available in the previous versions of Ubuntu, I looked for this package on Ubuntu’s package archive and found it under the listing of Ubuntu 14.04 here. I downloaded the .DEB file and installed it.

Now that this dependency package is installed, trying to install the original application (shutter in this case) should not complain about at least this package anymore.

If you cannot find the dependency package anywhere, install the troublesome package from some other source

So in the example above, I tried to install Green Recorder application using its PPA. This application needs python-urllib3 library but unfortunately, this library is not available in my Ubuntu 20.04 system.

Clearly, this is a poorly packaged application. The developer made it available for Ubuntu 20.04 without realizing that Ubuntu 20.04 doesn’t support Python 2 anymore and all the Python libs now start with python3 prefix. So the python-urllib3 should be python3-urllib3.

If you are in such a situation, maybe check the project’s homepage or search on the internet for an alternate source for installing it. Perhaps there is a Snap/Flatpak version or some user created a PPA for it? If nothing else, you may go with source code option as well.

If you see the held broken package error during update try this

Most of the discussion so far assumed that you see this error while installing a new application. That may not always be the case.

If you see this error when you try updating your system with sudo apt update command, then you’ll have to take a slightly different approach.

First, check which package is being held with this command:

If you see some packages being held, remove them and then go on updating your system or installing the software.

You may also use Synaptic package manager for fixing the broken packages.

Did you manage to fix the issue?

As I had mentioned earlier, there is no straightforward fix for this problem. You’ll have to investigate on your own and see if it can be fixed or not.

Please share in the comments if your problem gets fixed. If not, I may try to help you out.

E: Unable to correct problems, you have held broken packages

I am using Ubuntu 13.04 which I installed few days back. I am trying to install nodejs and npm . I tried to install from command line first and then uninstalled it. Then something broke.

The output of /etc/apt/sources.list is below:

The output of /etc/apt/sources.list.d/* is below:

fosslinux's user avatar

4 Answers 4

Use aptitude instead of apt-get. It is more intelligent. It not only will handle downgrading conflicting packages for you, but will make a series of recommendations asking you which of many possible suggested working scenarios you would like.

If you don’t have aptitude on your machine yet, get it with

You should be able to see the list of held packages by:

and then un-hold them by

After that, you should be able to remove the conflicting package (it seems to be npm ) and then reinstall all.

If this fail, you can try the aptitude way — often it’s able to disentangle dependency trees better.

In both cases, be careful when applying commands, and check carefully the list of packages that are marked for remove.

[Fixed] “You have held broken packages” Error

HOW TO FIX You Have Held Broken Packages ERROR IN LINUX

One of the best things about Linux is the apt command which lets you install applications and software effortlessly. Using apt, you don’t have to go through downloading the software, then going through the installer and clicking ‘Next’ a dozen times. It makes sure that every software is installed with just one terminal command.

But, just like any other program, things can go wrong. The error that we will be talking about in this write-up looks something like the following:

This error may occur when you are trying to install something via the apt utility. Let us look into the error in detail and try to solve the problem.

What causes this error?

Some of the software (mostly third-party ones) do not come with compatible dependencies and apt expects that your system already has those components. In case the required components aren’t found on your system, apt throws an error related to broken packages which means that the package you are trying to install is incomplete.

Outdated repositories, problems with the ‘sources.list‘ file, or an old/unsupported version of Linux might be the cause of this problem.

Methods to fix this problem

Before moving to the advanced methods, let us try a few quick tricks that can potentially help:

Method 1: Update the repositories

The apt update is a well-known command which instantly updates the list of packages and their dependencies. As the problem we are facing is due to missing dependencies, there is a good chance that this command will fix the error.

If the problem persists, try this command:

This will update the existing packages on your system to the latest version.

Method 2: Use aptitude instead of apt

Aptitude is also a package manager like apt and it surprisingly works in some situations where apt doesn’t! all you need to do is use aptitude instead of apt.

For example, suppose you want to install BIND9 using aptitude , you will have to enter the following command:

If you don’t have aptitude installed, run the following commands:

Method 3: Use autoremove to get rid of unnecessary packages

Sometimes, unnecessary packages stay behind even after uninstalling their parent application. These residual packages might interfere with installation of new applications or libraries. To get rid of these unnecessary residual packages, just enter the following command into the terminal:

There’s no need to worry as autoremove will only handle the leftover packages and dependencies.

Now with the basics out of the way, we will look at some more advanced methods to solve this problem.

Method 4: Look for held packages and unhold them

As the error message suggests, the problem is caused by packages on hold. The term ‘held package’ means that it can’t be upgraded, removed, or modified in any way.

To get a list of held packages, you need to enter the following command:

To unhold a specific package, enter:

To unhold all held packages, enter:

Method 5: Use the synaptic package manager to fix broken packages

Originally, Linux doesn’t have an inbuilt graphical package manager like Windows. This is why the synaptic package manager became immensely popular on Debian-based distributions made for personal computers as it provided a lightweight and robust GUI package manager.

One of the key features of this utility is that you can fix broken packages very easily. Follow the steps below:

1. First, install the synaptic package manager:

3. Go to Edit > Fix Broken Packages

Fix Broken Packages In Synaptic

Fix Broken Packages In Synaptic

It will take some time if there are broken packages present. Check if the problem is resolved.

References

Summary

In this article, we saw five different methods to fix the error “Unable to correct problems, you have held broken packages.” All the methods discussed were easy to execute and I hope you were able to fix the problem on your system. If you are still facing the same issue even after trying all the above methods, it can be because of using an unsupported Linux distribution, in which case, you will have to consider upgrading to a newer version of it.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *