Purpose: If you are using Debian Lenny and are installing software packages using apt-get then you might have noticed the new version of apt-get in Lenny installs the “recommends” packages automatically thus increasing the number of packages installed on your computer. The “apt-get” in Debian Etch (4.0) did not use to install “recommends” packages.  In this post, we will see how we can permanently tell apt-get NOT to install “recommends” packages.  For those of you who are not sure about Debian’s “depends”, “recommends” and “suggested” packages, please refer to this doc. This is important if you have limited storage space on your system, say for example an embedded system.

The Problem:

Let’s see how to do this with an example. Suppose we need to install the perl package. If you do:
# apt-get update
# apt-get install perl

You will get something like this:

# apt-get install perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
perl-doc perl-modules
Suggested packages:
libterm-readline-gnu-perl libterm-readline-perl-perl groff
The following NEW packages will be installed:
perl perl-doc perl-modules
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.9MB of archives.
After this operation, 41.4MB of additional disk space will be used.
Do you want to continue [Y/n]?

Notice that if you go ahead with this (say Y) you will end up using 41.4 MB of disk space. However if you look here, you can see that the package perl-doc is optional because it is just a “recommends” package and not a “depends” package.

Red = Depends

Green = Recommends (optional)

Blue = Suggests (optional)

The Solution:

Create or Edit the file /etc/apt/apt.conf file and add the following contents to it:
// Recommends are as of now still abused in many packages
APT::Install-Recommends "0";
APT::Install-Suggests "0";

Now save the file and run:
#apt-get  update
# apt-get install perl

Now you should get something like this:

# apt-get install perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
perl-modules
Suggested packages:
libterm-readline-gnu-perl libterm-readline-perl-perl
Recommended packages:
perl-doc
The following NEW packages will be installed:
perl perl-modules
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 7731kB of archives.
After this operation, 27.5MB of additional disk space will be used.
Do you want to continue [Y/n]?

If you noticed now that the total size of the installation reduced from 41.4 MB to 27.5 MB i.e. almost 33% less disk space will be used now. This is very helpful if you storage space is a concern for you. Also you can see that “apt-get” now lists “recommended” package as a separate entity above (see green above).

Temporary Solution:

Also if you do not want to create the “apt.conf” file because you do want “apt-get” to install “recommends” package but sometime you don’t want to install the “recommends” packages selectively for a particular package install then you can give the following command:
# apt-get --no-install-recommends install perl

and it will have the same effect as having those lines “apt.conf” file but you will have to give the flag “–no-install-recommends” every time you use apt-get to install any package.

As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.

Also don’t forget to rate this post below.

Be Sociable, Share!