11

It turns out that removing a virtual package with apt-get only remove the package itself, leaving behind the real packages that were installed by it

So how do you remove a virtual package, along with all the real packages that it installs?

7 Answers 7

9

Use apt-cache depends to find a list of packages that the virtual package "contains" and then remove all of those in order to remove the virtual package. For example:

$ sudo apt-cache depends mono-complete
mono-complete
  Depends: mono-runtime
  Depends: mono-runtime-sgen
  Depends: libmono-2.0-1
  Depends: libmono-profiler
  Depends: mono-utils
  Depends: mono-jay
  Depends: mono-devel
  Depends: mono-mcs
  Depends: mono-csharp-shell
  Depends: mono-4.0-gac
  Depends: mono-4.0-service
  Depends: monodoc-base
  Depends: monodoc-manual
  Depends: libmono-cil-dev
  Depends: ca-certificates-mono

Now all you have to do is sudo apt-get remove all of the packages listed after Depends: and once done, the virtual package mono-complete will be removed automagically.

Run sudo apt-cache depends command first to take a look at all the dependent packages, and then, if the list of packages looks to you that it is ok to be removed, you can use this to remove them all:

$ sudo apt-get remove `apt-cache depends mono-complete | grep Depends | cut -d : -f 2`

Once the job is done, you can check virtual package status with:

$ dpkg -l mono-complete

It should be marked as (n)ot installed.

1
  • 13
    When I run sudo apt-cache depends wine, all it prints is <wine>. (I use KUbuntu 18.04.) Jul 1, 2019 at 18:31
4

'Virtual' packages are packages that only contain references to other packages, or packages that only contain customized configuration files.

Therefore you cannot remove virtual packages, you need to remove the real packages from which the 'virtual' ones was referenced or created from.

2
  • 9
    Is it possible to find the real packages from which the virtual packages were created? If so, how? Feb 4, 2013 at 23:31
  • @AndersonGreen , I add an answer using aptitude. If you are looking for other options see the reference there.
    – user.dz
    Apr 29, 2020 at 21:39
2

You cannot remove virtual packages individually . When you remove the real packages completely, virtual packages are automatically removed. Remove configuration file with removing packages you have to use apt-get purge command.

1
  • I think you misunderstood my question. I'm actually asking about virtual packages.
    – Flint
    Oct 28, 2012 at 6:44
2

You mistaken meta-package for virtual-package. You have uninstalled a meta-package. Virtual package can't be removed directly, only by removing the package that provide it.

  1. Look for them using:

    aptitude search '~i~P<vitual-package>'
    

    and change <vitual-package> with the one you are looking for.

  2. Verify using dry-run (simulation) of remove

    aptitude -s remove '~i~P<vitual-package>'
    #or
    aptitude -s purge '~i~P<vitual-package>'
    
  3. It it does not break any thing, carry on and uninstall them.

    sudo aptitude remove '~i~P<vitual-package>'
    #or
    sudo aptitude purge '~i~P<vitual-package>'
    

    Otherwise, it it tried to remove important packages too. Look and install replacements before that.

References:

1
  • 1
    You saved me a lot of time. This works like a charm and should be accepted answer. Note In debian when first time it asks for accepting the situation you should choose 'NO' to continue. Jul 3, 2023 at 6:19
1

These answers didn't solve the question. The question is "can I remove them" The answers were yes, but didn't give the commands to remove them. They only refer to computers terminals problems having installed them it cannot remove them? Then this is a bug or this question is unanswered.

I have the same problem-

I followed the prompts to apt-get purge then purge -f and got the following:

The following packages have unmet dependencies:

      google-chrome-stable:i386 : Depends: libasound2:i386 (>= 1.0.23) but it is not installed

                         Depends: libatk1.0-0:i386 (>= 1.12.4) but it is not installed

                         Depends: libcairo2:i386 (>= 1.6.0) but it is not installed

                         Depends: libcups2:i386 (>= 1.4.0) but it is not installed

                         Depends: libfontconfig1:i386 (>= 2.8.0) but it is not installed

                         Depends: libgconf-2-4:i386 (>= 2.31.1) but it is not installed

                         Depends: libgcrypt11:i386 (>= 1.4.5) but it is not installed

                         Depends: libgdk-pixbuf2.0-0:i386 (>= 2.22.0) but it is not installed

                         Depends: libglib2.0-0:i386 (>= 2.18.0) but it is not installed

                         Depends: libgtk2.0-0:i386 (>= 2.24.0) but it is not installed

                         Depends: libnspr4:i386 (>= 1.8.0.10) but it is not installed

                         Depends: libnss3:i386 (>= 3.14.3) but it is not installed

                         Depends: libpango1.0-0:i386 (>= 1.22.0) but it is not installed

                         Depends: libudev0:i386 (>= 147) but it is not installed or

                                  libudev1:i386 (>= 198) but it is not installable

                         Depends: libxcomposite1:i386 (>= 1:0.3-1) but it is not installed

                         Depends: libxi6:i386 (>= 2:1.2.99.4) but it is not installed
                         Depends: libxss1:i386 but it is not installed
                         Depends: libxtst6:i386 but it is not installed
                         Depends: libcurl3:i386 but it is not installed
                         Depends: xdg-utils:i386 (>= 1.0.2) but it is not installable

E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by    held packages.        

E: Unable to correct dependencies

Is there an answer to removing the virtual packages so that another chrome package can be installed?

This isn't the original question; but, since he had tried and failed to resolve his problem of how to completely remove virtual packages, this is about the same.

I had already installed Aptitude and Aptitude's suggestion was removal of Chromium. Chromium is a Virtual package; and Aptitude removed Chromium and it's virtual remainder so I could reinstall.

So I would suggest installing Aptitude, and using Package Resolver by typing sudo aptitude into terminal, choosing Package Resolver>Remove>"package name".

1
  • I copied your remove line and I suppose it's so early that I forgot to replace mono-complete with the package I needed to remove. Whoops..
    – Jacksonkr
    Apr 30, 2016 at 13:04
0

If you installed the virtual environment (ie. wine) from the Ubuntu app store, then you may want to remove such installations from the Ubuntu app store as well. It makes the process a bit easier.

0

Sometimes apt-cache depends <package> outputs:

<package>

That means it has no dependencies. If you cant remove it using apt remove <package> it means it has configuration files remaining on the disk. You can remove the package using apt purge <package> which will remove the configuration file.

In my case, the package had no dependency but because it had configuration, it wasn't getting remove. Purging did the trick

You must log in to answer this question.

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