380

After upgrading from 10.04 to 12.04 I am trying to install different packages. For instance ia32-libs and skype (4.0).

When trying to install these, I am getting the 'Unable to correct problems, you have held broken packages' error message.

Output of commands:

sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

After running this:

sudo dpkg --configure -a
foo@foo:~$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
6
  • 4
    It may help if you showed us the command you are actually trying (such as sudo apt-get install ia32-libs) and the output from that command. Also, does sudo apt-get dist-upgrade show any available updates? Commented Nov 29, 2012 at 1:59
  • 3
    I don't know what's wrong with your question, I don't see any actual error, nor the one you describe in your title.
    – Braiam
    Commented Sep 10, 2014 at 14:20
  • Related: E: Unable to correct problems, you have held broken packages
    – Melebius
    Commented Jul 25, 2018 at 11:18
  • Possibly there are packages preventing package manager from working properly which is listed in your terminal error line(in may case: git-man is a dependency for git). sudo apt-get remove git-man next sudo apt-get purge git-man then sudo apt-get install git. It installed git-man again and everything seems working.
    – Siamak
    Commented Mar 30, 2020 at 15:16
  • 1
    I totally misinterpreted the meaning of "you have held broken packages". It does not mean that I did something to hold a package, as I at first thought. (I was running non-interactively with -y so didn't know what questions might have been asked.) It means that the package manager is holding a package that can't be installed because it is broken.
    – msc
    Commented Feb 28, 2021 at 12:37

16 Answers 16

372

That particular error message may indicate that you have held packages, but it may also indicate a different problem.

You can get a list of actual held packages with:

dpkg --get-selections | grep hold

If there are none, or none look related, then it's probably something else. Check carefully the output of the command you were trying when you got the error message, as there may be other clues in the full output from that command, aside from the error message.

Another method of troubleshooting may be to use aptitude rather than apt-get to try to install your package:

sudo aptitude install <packagename>

Aptitude will give up less easily and will attempt to find solutions that may involve modifying other packages. It may give you more explanation of the problem and options for fixing it.

Occasionally aptitude will be too eager to remove or downgrade large numbers of packages to satisfy your request, in which case retrying with -f changes its priorities and helps it come up with solutions that involve removing/downgrading fewer packages even if it means not all changes you requested can go ahead:

sudo aptitude -f install <packagename>

Edit: this is an old answer, and since it was written a newer APT front end, simply titled apt, has become the preferred command line APT interface for end-users. It is still not the Swiss army knife that aptitude is, but it's a bit more human-oriented than apt-get. I haven't taken the time to investigate how it would help in the above scenario, but it's worth using.

21
  • 10
    Any idea how to unhold a package? :-) Commented Apr 17, 2013 at 14:24
  • 10
    That is a separate question. Commented Apr 20, 2013 at 13:58
  • 104
    Aptitude was more helpful to me than apt-get, thanks for the hint.
    – szx
    Commented Oct 27, 2013 at 15:20
  • 21
    One thing to note is that aptitude may make it easier to do more damage to your system. For example, if apt-get fails to install something because of conflicting dependencies it will give up. However, aptitude might offer to go ahead, but uninstall a whole bunch of other packages in order to satisfy those conflicts - or even downgrade packages. You simply have to be aware of what it's suggesting and proceed only if it is a good idea. Commented Mar 12, 2014 at 3:23
  • 5
    The "on hold" packages has nothing to do with the message, just that the conflict was avoided by holding them down (not installing, upgrading, downgrading, or removing).
    – Braiam
    Commented Aug 23, 2014 at 2:50
49

That happened to me too. All I did was sudo apt-get update and that fixed my issue. Good luck.

3
  • 6
    Before running this command there has to be at least a process to investigate the cause. add flag -o Debug::pkgProblemResolver=true -o Debug::Acquire::http=true to apt-get install command to get more info.
    – snowpeak
    Commented Dec 8, 2020 at 14:40
  • Thank you @sushilinux. This tip helped me identify the problem I was having as well as the actual meaning of "you have held broken packages".
    – msc
    Commented Feb 28, 2021 at 12:37
  • I used the slightly different sudo apt update and then sudo apt upgrade, which fixed the problem. I had most automatic updates on, but not -updates, -proposed nor -backports. Commented Jun 18, 2023 at 18:20
47

I had a similar scenario in a fresh install of 14.04, with no files listed in dpkg --get-selections | grep hold, and no joy after sudo apt-get update.

What did fix it for me was a simple

sudo apt-get autoremove

When I tried to reinstall the failing package it worked fine. Yay!

2
  • 1
    This worked for me. I was trying to remove VLC nightly & install the stable version. But nightly version left from unused libraries. This was conflicting with the stable version dependencies. Commented Feb 17, 2021 at 0:57
  • This works for me, i have an unsuccessful installation of ffmpeg 6 and want to rollback to ffmpeg 4. Commented May 26, 2023 at 5:07
33

A Unable to correct problems, you have held broken packages error message often occurs because you are trying to install or have installed a package that you're not supposed to install. These are some fast and easy ways to fix the you have held broken packages error.

  • Open your sources.list file in /etc/apt/sources.list and check that there aren't any software sources for a different Ubuntu release than the Ubuntu release that you are currently using. If you find any incorrect release lines in sources.list, open the sources.list file with sudoedit /etc/apt/sources.list, comment out the incorrect lines in sources.list by preceding them with a # character, save the sources.list file, and run sudo apt update to update the list of available software packages.

  • If you have manually downloaded a .deb file simulate installing it by running apt install --simulate ./downloaded-deb-file.deb. If downloaded-deb-file.deb cannot be installed because of unmet dependencies the results of apt install --simulate ./downloaded-deb-file.deb will list these unmet dependencies. Since the command is a simulation you don't need and shouldn't use sudo or run it as root. Note the version requirements of each unmet dependency and search the web for a .deb file(s) that meets these version requirements. If you have found a .deb file that meets its version requirements, download it and run apt install --simulate ./new-downloaded-deb-file.deb to check if the newly downloaded .deb file has any unmet dependencies of its own.

  • Select the Fix Broken Packages option in Synaptic package manager. Run the following commands to install Synaptic.

      sudo apt update  
      sudo apt upgrade   
      sudo apt install synaptic  
    

    Open Synaptic and in Synaptic select Edit -> Fix Broken Packages and then repeat Edit -> Fix Broken Packages a second time.

    In Synaptic in the left pane click the Custom Filters button which is marked by the mouse cursor in the below screenshot. From the list in the top left corner select Broken. In the center pane will be listed any broken packages that still need to be repaired.

    show broken packages in Synaptic

    Select the broken packages one at a time. Select a broken package, and then open the terminal and run apt policy <package-name>. The results of this command will tell you if that broken package was installed from the default Ubuntu repositories or from some other source. If the broken package was installed from some other source, maybe that package can be removed along with its software source and replaced by a different version of the same package from the default Ubuntu repositories. Usually this means fixing a broken package by downgrading that package to an older version.

  • If you get this error message:

      Try 'apt-get -f install' with no packages (or specify a solution)  
    

    Run the following commands:

      sudo apt update  
      sudo apt upgrade   
      sudo apt-get -f install   
    
  • Manually remove a broken package.

    1. Find your package in /var/lib/dpkg/info

       ls -l /var/lib/dpkg/info | grep <package>
      
    2. Move the package folder to another location.

       cd /tmp && sudo mkdir new-package-location  
       sudo mv /var/lib/dpkg/info/<package>.* /tmp/new-package-location/    
      
    3. Run the following command:

       sudo dpkg --remove --force-remove-reinstreq <package>  
      

If all of these methods don't work it is possible that the broken packages are caused by something that is embedded so deeply in the operating system that none of these methods have any effect on it. The first obvious place to look for this deeply embedded "something" is in the software sources in /etc/apt/sources.list. Check the sources.list file to see if it contains any non-standard lines that may be causing a broken packages error. A standard Ubuntu sources.list file looks like the sources.list files in this answer.

The correct way to remove a suspicious line from sources.list is to comment it out by preceding it with a # character. Then run sudo apt update to refresh the list of available software.

3
  • 2
    Editing a ppa file at sources.list.d was the culprit for me. It was a ppas that provided the same package as one provided by the standard Ubuntu repos, but obviously the ppa was more frequently updated with newer dependencies. After removing the ppa and its primary package, its dangling dependencies raised this error, when I've attempted to install the same package from the default Ubuntu repos. Interestingly enough, when i've tried your apt policy [package-name] command on one of the dependencies, it reported /var/lib/dpkg/status rather than the now-removed old ppa.
    – xquilt
    Commented Sep 8, 2022 at 3:08
  • 1
    Uninstalling the remaining dependencies of the old ppa, then installing the main package again along with its dependencies, all from within the same repo source, worked just fine. I'd recommend sudo apt autoremove instead of sudo apt update then reinstalling the desired package. Alternatively, inspect the package's required problematic dependencies' versions using apt install [package-name] | grep Depends, verify the availability of these versions with apt list -a [dependency-name] then reinstall the required version via sudo apt install --reinstall [packagename]=[version]
    – xquilt
    Commented Sep 8, 2022 at 4:02
  • 1
    Thanks. I had the Ubuntu backports repository enabled and I was getting conflicting dependency resolution. Disabling the backports repository fixed it.
    – daviewales
    Commented Mar 13, 2023 at 2:03
14

I ran into a similar scenario regarding missing dependencies. In my case I was trying to install curl on ubuntu saucy salamander 13.10...

The error stated that the dependency required an earlier version of the curl3 library.

I was able to degrade to the earlier version by trying to install curl using aptitude.

When it noted the missing dependency, and the reason (required an earlier version of the library file), it gave me several options in how to respond... y//n/q

Y would have aborted the install, N would look for another option, and Q would simply quit and do nothing more, leaving a broken package.

I selected N, and it gave me the option to downgrade the library file to an earlier version. So that's what I did, and curl finished installing with no more errors.

  • I may look into upgrading the library file again after the install, but hey, so far so good.
11

I have tried all the methods mentioned on this page. Somehow it did not work for me.

This is how I fixed it: Track the broken package and reinstall it.

Here is an example:

I am trying to install aptitude.

sudo apt install aptitude

sudo apt install aptitude

It could not install libcwidget3v5

sudo apt install libcwidget3v5

sudo apt install libcwidget3v5

Try installing libncursesw5

sudo apt install libncursesw5

sudo apt install libncursesw5

Try installing libtinfo5

sudo apt install libtinfo5

sudo apt install libtinfo5

Bingo, this guy is the culprit libtinfo5, it already there, remove and reinstall.

Remove or purge libtinfo5.

apt purge libtinof5 would be better as it removes the configuration files as well.

sudo apt remove libtinfo5

sudo apt install libtinfo5

Reinstall libtinfo5 again

sudo apt install libtinfo5

reinstall libtinfo5

Now try installing aptitude

sudo apt install aptitude

aptitude install success

2
  • 2
    I did not examine this solution, but it looks logically pretty well.
    – SaidbakR
    Commented May 5, 2021 at 18:35
  • 2
    @SaidbakR only if it would use text instead of images for the command outputs ...
    – Jakuje
    Commented Nov 26, 2021 at 14:01
8

Had the same problem, I ran that package check command from the other answer (dpkg --get-selections | grep hold) and saw

tomcat7                                         deinstall
tomcat7-common                                  install

so I used "apt-get remove tomcat7-common"

Then I could install Tomcat 6 (I was removing Tomcat 7 and installing Tomcat 6 as you do).

2
  • 1
    The "on hold" packages has nothing to do with the message, just that the conflict was avoided by holding them down (not installing, upgrading, downgrading, or removing)
    – Braiam
    Commented Aug 23, 2014 at 2:51
  • add the flag purge: apt-get remove --purge packet Commented Jan 5, 2017 at 11:22
6

The error message is misleading.

It says "you held packages", while oftentimes there will be no packages held by you:

$ apt-mark showhold

Would print nothing.

What actually happens is the packages are held by apt itself while running dependency analysis. So for example you could see output like this:

$ apt-get install gcc:i386
<...skip...>
The following packages have unmet dependencies:
 gcc:i386 : Depends: cpp:i386 (= 4:9.3.0-1ubuntu2) but it is not going to be installed
            Depends: gcc-9:i386 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Clearly that's not very helpful...

So to debug this further, run apt with the flag -o Debug::pkgProblemResolver=yes

$ apt-get -o Debug::pkgProblemResolver=yes install gcc:i386

Now that would print a bunch of lines like

Investigating (0) gcc:amd64 < 4:9.3.0-1ubuntu2 @ii mK Ib >
Broken gcc:amd64 Conflicts on gcc:i386 < none -> 4:9.3.0-1ubuntu2 @un puN Ib >
  Considering gcc:i386 9999 as a solution to gcc:amd64 3
  Removing gcc:amd64 rather than change gcc:i386
Investigating (0) binutils:amd64 < 2.34-6ubuntu1.1 @ii mK Ib >
Broken binutils:amd64 Conflicts on binutils:i386 < none -> 2.34-6ubuntu1.1 @un uN Ib >
  Considering binutils:i386 0 as a solution to binutils:amd64 1
  Added binutils:i386 to the remove list
  Conflicts//Breaks against version 2.34-6ubuntu1 for binutils but that is not InstVer, ignoring
  Fixing binutils:amd64 via keep of binutils:i386
Investigating (0) cpp:amd64 < 4:9.3.0-1ubuntu2 @ii mK Ib >
Broken cpp:amd64 Depends on cpp-9:amd64 < 9.3.0-17ubuntu1~20.04 @ii mR > (>= 9.3.0-3~)
  Considering cpp-9:amd64 -1 as a solution to cpp:amd64 1
  Added cpp-9:amd64 to the remove list
Broken cpp:amd64 Conflicts on cpp:i386 < none -> 4:9.3.0-1ubuntu2 @un uN Ib >
  Considering cpp:i386 0 as a solution to cpp:amd64 1
  Added cpp:i386 to the remove list
  Fixing cpp:amd64 via keep of cpp-9:amd64
  Fixing cpp:amd64 via keep of cpp:i386
. . .

The bottom line is gcc:i386 can't coexist with gcc:amd64. That's all apt could say really.

6

Let's understand this error with an example:

Assume this is the error message:

The following packages have unmet dependencies:
 nginx-module-brotli : Depends: nginx (= 1.17.3-2-ppa7~bionic)
E: Unable to correct problems, you have held broken packages.

Let's break it down into variables:

X=nginx-module-brotli
Y=nginx
Z=1.17.3-2-ppa7~bionic

Here X is the package you are trying to install. Y is the package, which is causing dependency troubles (there may be multiple Ys) and Z is the version that is required.

So in a summary:

X needs the package Y with the version Z to work.

However, apt is facing troubles while finding the version Z for Y.

So, let's check if version Z is available for the package Y. We can use apt-cache policy <package_name> to find the available versions for the package. For example:

 $ apt-cache policy nginx
libasound2:
  Installed: nginx_1.20.2-1~bionic
  Candidate: 1.2.2-2.1ubuntu2
  Version table:
 *** nginx_1.20.2-1~bionic 100
        100 /var/lib/dpkg/status
     1.17.3-2-ppa7~bionic 500
        500 http://br.archive.ubuntu.com/ubuntu focal/main amd64 Packages

Here, you can see two versions for the package nginx is available. The version required by X is Z. According to the version table, version Z for the package Y is available. But apt always installs the latest version. So there are two ways to fix this:

  1. Install the correct package version.
  2. Increase the aptitude of apt.

To install the correct package version use:

sudo apt update
sudo apt install <Y>=<Z>

Where is the package causing dependency troubles and is the version needed by X. Now, the installation should be successful.

To increase the aptitude of your package manager:

sudo apt update
sudo apt install aptitude
sudo aptitude -f install <Z>

Where is the package you are trying to install. Some useful tips with aptitude:

  • -f option will do advance troubleshooting. It's pretty useful!

  • selecting n for a solution will make aptitude propose more solutions!

  • Running man aptitude will show a detailed manual for using aptitude. Online manual.

The required version isn't available.

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

Still not available?

You have two options:

  1. Search for the package in https://packages.ubuntu.com/ and restore the default repositories.

  2. Add custom PPAs to satisfy dependencies.

Searching package and restoring default repositories:-

  1. Go to https://packages.ubuntu.com

  2. Scroll down to the Search section.

  3. In the Keyword column, enter the name of the package.

  4. In the Distribution column, select the code name of your Ubuntu version (lsb_release -c).

  5. Click on search! Search!

  6. Select the Exact Hit. Exact

  7. Check the version and repository for the package. Carefully check

Check if the version needed and version available matches. If yes then refer to How do I restore the default repositories?

Adding a custom PPA.

You have to take help from Google for that. Just google up the package and version and hopefully you'll find a PPA.

Some helpful commands:

  • sudo apt -f install <package> to force install package.
  • sudo aptitude -f install <package> To force install package.
  • sudo add-apt-repository whatever/ppa to add a PPA.
  • sudo apt purge <package> to remove a package.

I'm asking a new question, what information should I provide?

Information such as:

  • Your Ubuntu version (output of lsb_release -d.
  • Output of sudo apt install <package>
  • Output of apt policy <package> and apt policy <package's dependency>

Other details should be provided when asked.

4

For me, none of the above worked because my system wasn't updated. I did

Home Key > Software Updater > Install

and updated my system; afterwards, I could install my package normally with apt.

2
  • 1
    How can I give double vote up to you :) Commented Apr 2, 2021 at 13:02
  • 1
    For me, none of the above worked either. This was the solution. I was having trouble using a secondary monitor after running apt update & upgrade. Running sudo ubuntu-drivers autoinstall was giving the broken packages thing.
    – Diego Lima
    Commented Mar 1, 2022 at 13:05
2

I just ran into the same issue with Ubuntu Mate and I found this thread. My issue was trying to chain the update command together like this...

sudo apt update && sudo apt upgrade -y && sudo apt autoremove

Which should have worked. It didn't give me any errors, but it ran quick and gave me a list of packages that aren't ready for release yet. The result was I couldn't install my additional drivers.

I fixed it by running the update / upgrade / autoremove commands separately...

sudo apt update
sudo apt upgrade -y
sudo apt autoremove

That took the normal long time - especially upgrade - and now my installers work fine. I still don't know why chaining those commands together into one didn't work.

#head-scratcher

Here's my driver install running finally.

Additional Drivers Installation Running. Good luck!

Update: After thinking about it for a bit, I think the warnings I was getting about the packages that aren't ready to be installed yet, were being treated as errors, and breaking the && chain from continuing. Probably had I just chained the commands together with ; it would have worked.

sudo apt update ; sudo apt upgrade -y ; sudo apt autoremove
2

I had the same problem reinstalling xsane after a failed ppa installation. As happened to yochannah (now called 'StackExchange What The Heck'), "no files listed in dpkg --get-selections | grep hold, and no joy after sudo apt-get update".

The hint that apt-get gave me is

xsane : Depends: libsane (>= 1.0.24) but it is not going to be installed

Because of yochannah's answer, I had the feeling I must remove some previously installed packages. And it was so, I had to manually remove all related packages to sane, amongst others xsane-common and libsane, which was still installed as the ppa version.

Therefore, watch out what you have previously installed and tidy up!

1

I was facing the same issue while upgrading from 14.04 LTS to 16.04 LTS. You need to track the broken package and recursively try re-installing or upgrading it.

First, remove all dependent libraries (autoremove) and install all missing libraries using sudo apt-get -f install (-f means --fix-missing)

sudo apt-get autoremove
sudo apt-get -f install
sudo apt-get update
sudo apt-get upgrade 

Install ubuntu toolchain from PPA

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

Then install aptitude.

sudo apt install aptitude

aptitude package manager is a much more handy installer than apt-get. It also suggests resolving conflicting dependencies and broken packages. The following were the conflicts in my system. They may differ from yours but the high-level method to resolve them would be the same.

$ sudo aptitude -f install build-essential
The following NEW packages will be installed:
  build-essential cpp{a} cpp-5{a} g++{a} g++-5{a} gcc{a} gcc-5{a} libasan2{a} libcc1-0{ab} 
  libcilkrts5{a} libgcc-5-dev{a} liblsan0{ab} libmpx0{a} libstdc++-5-dev{a} 
The following packages will be upgraded:
  gcc-5-base libstdc++6{b} 
2 packages upgraded, 14 newly installed, 0 to remove and 5 not upgraded.
Need to get 29.6 MB of archives. After unpacking 100 MB will be used.
The following packages have unmet dependencies:
 liblsan0 : Depends: gcc-9-base (= 9.3.0-10ubuntu2~16.04) but 9.3.0-11ubuntu0~14.04 is installed.
 libcc1-0 : Depends: gcc-9-base (= 9.3.0-10ubuntu2~16.04) but 9.3.0-11ubuntu0~14.04 is installed.
 libstdc++6 : Depends: gcc-9-base (= 9.3.0-10ubuntu2~16.04) but 9.3.0-11ubuntu0~14.04 is installed.

Aptitude gives sometimes provides a viable potential solution. Such as upgrading or downgrading other libraries to solve the conflict. In my case, there was no solution. Hence I need to further track down the dependencies.

As build-essential needs gcc-5.

$ sudo apt-get -f install gcc-5

The following packages have unmet dependencies:
 gcc-5 : Depends: cpp-5 (= 5.5.0-12ubuntu1~16.04) but it is not going to be installed
         Depends: gcc-5-base (= 5.5.0-12ubuntu1~16.04) but 5.4.0-6ubuntu1~16.04.12 is to be installed
         Depends libcc1-0 (>= 5.5.0-12ubuntu1~16.04) but it is not going to be installed
         Depends libgcc-5-dev (= 5.5.0-12ubuntu1~16.04) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

But gcc-5 in turn depends on cpp-5

$ sudo apt-get -f install cpp-5

The following packages have unmet dependencies:
 cpp-5 : Depends: gcc-5-base (= 5.5.0-12ubuntu1~16.04) but 5.4.0-6ubuntu1~16.04.12 is to be installed

cpp-5 depends on gcc-5-base. Here you can see there is a specific conflict. Aptitude gives multiple choices to solve the conflict. In my case upgrading the libstdc++6 solved the problem.

$sudo aptitude -f install gcc-5-base
The following packages will be REMOVED:  
  gcc-5-base{u} 
0 packages upgraded, 0 newly installed, 1 to remove, and 6 not upgraded.
Need to get 0 B of archives. After unpacking 67.6 kB will be freed.
The following packages have unmet dependencies:
 libstdc++6 : Depends: gcc-5-base (= 5.4.0-6ubuntu1~16.04.12) but it is not going to be installed.
open: 115; closed: 488; defer: 35; conflict: 58                                                          .The following actions will resolve these dependencies:

     Keep the following packages at their current version:                        
1)     gcc-5-base [5.4.0-6ubuntu1~16.04.12 (now, xenial-security, xenial-updates)]

Accept this solution? [Y/n/q/?] n
The following actions will resolve these dependencies:

      Upgrade the following packages:                                                                     
1)      libstdc++6 [5.4.0-6ubuntu1~16.04.12 (now, xenial-security, xenial-updates) -> 9.3.0-10ubuntu2~16.0

Finally, now the conflict is resolved try installing build-essentials again.

$ sudo aptitude -f install build-essential
1

I had this problem in 2021 too, with Ubuntu 20.04 LTS. Maybe for some people in the future: It helped me to check the "Application & Update" panel!

Because I changed just a few minutes before the position: "For other packages, subscribe to:" I changed it from "all updates" to "only security patches/updates"- and when I changed it back to "all updates"- I could finally install everything.

1

If you are unable to install/remove any new packages using package managers, and seemingly there is no other option than to backup your data and do a clean install of the system, you may try this first:

sudo dpkg -l | grep -v '^ii'

Then for each packages which have something other than ii in the first and second column, or an ..R in the third column, remove them using:

sudo dpkg --purge package_name1 package_name2 ...

or

sudo dpkg --purge --force-depends package_name1 package_name2 ...

(Instead of --force-all you may use one or combine more as described in dpkg --force-help . e.g. for rc you do not need to --force-... anything, for iHR it is enough to use --force-remove-reinstreq , etc.)

sudo apt-get clean
sudo apt-get update
sudo apt-get --fix-broken install

Hopefully, this should fix the broken package.

The i character is usually installed state or desired state. There is a description at: How to interpret the status of dpkg (–list)

The first column in the output of sudo dpkg -l | grep '^.[^i]' represents the status of a package and represented by two or three characters. e.g. ii, rc, iU, etc. Below is a list of the possible characters and their meaning:

First character: This specified the desired state. The possible values are:

  • u : Unknown (an unknown state)
  • i : Install (marked for installation)
  • r : Remove (marked for removal)
  • p : Purge (marked for purge)
  • h : Hold (held package)

Second character: This specified the current state (whether it is installed or not). The possible values are:

  • n : Not (the package is not installed)
  • i : Installed (the package is successfully installed)
  • c : Configuration files (Configuration files are present)
  • u : Unpacked (the package is unpacked)
  • f : Failed-Cfg (failed to remove configuration files)
  • h : Half-Installed (the package is only partially installed)
  • W : trig-aWait
  • t : trig-pend

Third character: This specified the error state. The possible values are:

  • R : Reinstall-required (the package must be reinstalled)

An example:

To demonstrate a broken package, I downloaded a bunch of .deb packages required for npm package. I then removed two of the packages there and installed the rest in the directory with sudo dpkg -i * and hence a broken package dependency situation was created. Then I did as stated above.

The following was the result of sudo dpkg -l | grep '^.[^i]' command:

iU  node-cacache                               15.0.5+~cs13.9.21-3                     all          fast, fault-tolerant, disk-based, data-agnostic, content-addressable cache
iU  npm                                        8.5.1~ds-1                              all          package manager for Node.js

I then purged all those marked other than ii e.g. the iUs using commands:

sudo dpkg --purge --force-all npm
sudo dpkg --purge --force-all node-cacache

And then followed the rest of the procedure.

And, lastly having synaptic package manager beforehand in your system is a lot helpful in resolving broken packages, among other benefits. You can install synaptic with sudo apt-get install synaptic .

0
0

Remove any non-standard repository sources.

Check in /etc/apt/sources.list, and comment out as needed.

I had added Universe (sudo add-apt-repository universe). Once removed from sources, everything updated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .