Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I just installed a package (dansguardian in this case) and apt told me that I had unmet dependencies.

# sudo apt-get install dansguardian
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  clamav clamav-base clamav-freshclam libclamav6 libtommath0
Suggested packages:
  clamav-docs squid libclamunrar6
The following NEW packages will be installed:
  clamav clamav-base clamav-freshclam dansguardian libclamav6 libtommath0
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,956 kB of archives.
After this operation, 14.4 MB of additional disk space will be used.
Do you want to continue [Y/n]?

So I installed it and the dependencies. So far so good.

Later on, I decide that this package just isn't the package for me, so I want to remove it and all of the other junk it installed with it since I'm not going to be needing any of it:

# sudo apt-get remove --auto-remove --purge dansguardian
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  dansguardian
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,816 kB disk space will be freed.
Do you want to continue [Y/n]?

However it is only removing that one specific package. What about clamav clamav-base clamav-freshclam libclamav6 libtommath0? Not only did it not remove them, but clamav was actually running a daemon that loads every time the computer boots. I thought that --auto-remove would remove not only the packages, but also the dependencies that were installed with it.

So basically, without going through the apt history log file (if I even remember to do so, or if I even remember that a specific package I installed 3 months ago had dependencies along with it), is there a way to remove a package and all of the other dependencies that were installed like in this case?

share|improve this question
    
Can you still remove other packages with dependencies with --auto-remove switch? –  Anwar Shah Jun 24 '12 at 3:41

2 Answers 2

up vote 2 down vote accepted

As izx said, in his general answer, the first point, can be the cause of this sort of things.

Those dependencies are now also required/recommended by some other package(s) which are still installed on your system.

This is the most probable and valid reason for this kind of situation,But I am thinking that, the other packages named with clamav clamav-base clamav-freshclam libclamav6 libtommath0 most likely only associated with their mother package clamav. So, the first point, may not be the case in this particular situation.

The most likely cause of this problem, which seems to be the cause is, after installing the dansguardian package, you later installed all it's dependency packages by doing this kind of command below:

sudo apt-get install clamav clamav-base clamav-freshclam dansguardian libclamav6 libtommath0

If this is indeed the case, you can't uninstalled them by removing their mother package dansguardian. since in APT's language, they are installed "manually" as you explicitly installed these packages by feeding their name to the apt-get command, so must also uninstall them with explicitly stating their package name

You can check this, if it is the case by viewing /var/log/apt/history.log files.

To remove:

You must remove the installed packages by explicitly naming their name.So, in your specific situation it is

sudo apt-get purge clamav clamav-base clamav-freshclam dansguardian libclamav6 libtommath0

To see the dependent packages

You can find all the dependent packages with the below command:

apt-cache depends -i dansguardian | cut -f 2 -d ':' | tr '\n' ' '.

Note that, dansguardian depends on package libc6. while that package is very very essential one in your system. So, you can't remove all the dependency of dansguardian by generating their dependency package list with apt-cache command, hence it is not recommended. (actually, it is highly recommended to avoid doing that, unless you are happy with a broken system)

share|improve this answer
    
depends also shows suggests, etc. so I'd suggest filtering for "Depends" before piping to cut, etc. :) Good answer. –  izx Jun 24 '12 at 4:16
    
@izx Thanks, i think it shows dependent and recommended packages, but not suggested packages. and the default policy of APT in Ubuntu is to consider recommended packages as dependency, as far as i know ,Apt does not install suggested packages –  Anwar Shah Jun 24 '12 at 4:26
    
Please see this paste. Thanks! –  izx Jun 24 '12 at 4:39
    
Thanks @izx, i was wrong in telling that, "it shows only deps and recommends" while i was willing to tell "apt-get only install deps and recommends". just mixing the things. (may be cause of yesterdays' bad sleep). very very thanks. I will update the answer –  Anwar Shah Jun 24 '12 at 4:46
    
Anwar - you're not wrong, apt is "lying" --- what "depends" shows as "suggests" are actually "recommends!" - so make sure the answer reflects that. –  izx Jun 24 '12 at 4:48

Specific answer:

This is not normal behavior:

izx@preciseunity:~$ sudo apt-get remove --auto-remove --purge dansguardian
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  clamav* clamav-base* clamav-freshclam* dansguardian* libclamav6*
  libtommath0* python-gpgme*
0 upgraded, 0 newly installed, 7 to remove and 91 not upgraded.
After this operation, 14.7 MB disk space will be freed.
Do you want to continue [Y/n]? 

See general answer no. 1 below for the most probable reason why.


General answer:

This can happen for multiple reasons. The most common ones are:

  1. Those dependencies are now also required/recommended by some other package(s) which are still installed on your system.
  2. The original package was a meta-package, i.e. a shortcut to install multiple packages in one swift stroke. Removing a metapackage only removes the shortcut itself, not all the packages it installed. Common examples are the various umbrella desktop packages, eg ubuntu-desktop.

To remove, use apt-cache depends package-name to get its dependencies, and feed those to apt-get remove. Double check the list shown to make sure you don't lose anything important!

You can do this in one step with the following command (again, don't press Y unless you've read the list!):

sudo apt-get remove `apt-cache depends dansguardian | grep Dep | cut -d: -f2 | tr '\n' ' '`
share|improve this answer
    
but i thought a metapackage should not be of that big size. Yes, first point is very good –  Anwar Shah Jun 24 '12 at 3:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.