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.

This question is similar to How can I find out why a package was installed?, but in my case I'd like to know before actually installing a package, why it will install a particular dependency.

So for example I might run

sudo apt-get install superfoo

and the output will say something like:

The following extra packages will be installed:
  foo bar baz ... libderp libjunk

And this might be a really huge list. In some instances I'll see something that is going to be installed that doesn't really make sense to me given what I'm installing, so I want to know why that particular dependency is going to be installed.

In the above example let's say I'd like to understand why libderp would get installed. I know that somehow there is a chain of dependencies between superfoo and libderp but the huge list of packages to be installed makes it hard to see what this chain is.

Once I know the dependency chain, I can decide whether I really want to install the original package or not, and/or whether I should get in touch with the maintainer of that package to see if they really need to have those dependencies there.

share|improve this question
    
If someone's answer was helpful to you, then please consider marking it as the accepted answer so others may more easily find it in the future. This is also a polite way to thank the person answering your question for helping you out. –  Danatela yesterday
add comment

3 Answers

There may be an easier way to do this, but it can be done if you use reverse-depends. You will need to install the ubuntu-dev-tools package by doing

apt-get install ubuntu-dev-tools

Or by clicking this button:

Install via the software center

Once installed, you can then use reverse-depends to see what depends on a specific package. For example, if you try to install something that wants to install a bunch of extra packages and you want to see why "libsmpeg0" is being installed, you run

reverse-depends libsmpeg0

Which would output the following.

Reverse-Recommends
==================
* sandboxgamemaker

Reverse-Depends
===============
* btanks
* fenix-plugin-mpeg [armel armhf i386 powerpc]
* fillets-ng
* gltron [amd64 armel i386 powerpc]
* libalien-sdl-perl
* libsdl-perl [i386]
* libsmpeg-dev
* libtaoframework-sdl1.2-cil
* python-pygame
* ruby-sdl
* sdlbrt
* smpeg-gtv
* smpeg-plaympeg
* tdfsb

Packages without architectures listed are reverse-dependencies in: amd64, armel, armhf, i386, powerpc

Take a look and see if the package you want to install is in that list. If not, then another one of the packages that is being pulled in during that initial install will show up in that list, and you will need to run reverse-depends on that package. Eventually you will see the initial package you want to install in that list. At that point, you should have a chain showing exactly why that package was installed.

As an added note, I believe recommends is on by default, so if something is set as a recommends it will get pulled in to. Suggests if off, but reverse-depends can show that info as well.

share|improve this answer
    
While I'm sure this answer would work, it personifies the issue the OP is trying to avoid. ubuntu-dev-tools results in the following packages being installed. bzr bzr-builddeb dctrl-tools debian-archive-keyring debian-keyring debootstrap devscripts diffstat distro-info distro-info-data dput genisoimage gettext hardening-includes intltool-debian libapt-pkg-perl libarchive-zip-perl libasprintf-dev libassuan0 libauthen-sasl-perl libautodie-perl libclone-perl libcommon-sense-perl libcroco3 libdigest-hmac-perl libdistro-info-perl libemail-valid-perl libencode-locale-perl liberror-perl –  Fake Name yesterday
    
[continued] libexporter-lite-perl libfile-basedir-perl libfile-listing-perl libfont-afm-perl libgettextpo-dev libgettextpo0 libgpgme11 libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libio-html-perl libio-pty-perl libio-socket-inet6-perl libio-socket-ssl-perl libio-stringy-perl libipc-run-perl libipc-system-simple-perl libjs-jquery libjson-perl libjson-xs-perl liblist-moreutils-perl liblwp-mediatypes-perl liblwp-protocol-https-perl –  Fake Name yesterday
    
[continued] libmailtools-perl libnet-dns-perl libnet-domain-tld-perl libnet-http-perl libnet-ip-perl libnet-smtp-ssl-perl libnet-ssleay-perl libparse-debcontrol-perl libperlio-gzip-perl libsocket6-perl libsub-identify-perl libtext-levenshtein-perl libtie-ixhash-perl libunistring0 liburi-perl libwww-perl libwww-robotrules-perl libxdelta2 lintian patchutils pbuilder pbzip2 pristine-tar python-bzrlib python-dbus python-dbus-dev python-debianbts python-distro-info python-dns python-fpconst python-gi python-gpgme python-httplib2 python-keyring –  Fake Name yesterday
    
[continued] python-launchpadlib python-lazr.restfulclient python-lazr.uri python-oauth python-paramiko python-reportbug python-secretstorage python-simplejson python-soappy python-support python-wadllib python3-debian python3-magic quilt reportbug t1utils unzip wdiff xdelta (Note: The above was just the required packages from sudo apt-get install ubuntu-dev-tools on a fairly clean ubuntu server instance). If you're trying to avoid installing huge amounts of cruft, this is probably the worst solution possible. –  Fake Name yesterday
    
@FakeName Use a pastebin service - something like paste.ubuntu.com and then provide the link. Posting all those in comments just clutters it. (So, please delete those comments, rerun the command, paste and provide the link). –  Aditya 23 hours ago
show 3 more comments

What you really seem to be asking is "How do I diagram dependencies?" so you can see which packages pull in which dependencies.

You get both text and diagrammed dependencies from the apt-cache command (included in the apt package, part of the default install).

Here's an example of apt-cache for listing dependencies of the 'hello' package in text format. Text output will always be only one level.

$ apt-cache depends hello
hello
  Depends: libc6
 |Depends: dpkg
  Depends: install-info

You can read the diagram using any dotfile viewer, such as dotty (included in the graphviz package, also part of the default install)

Here's an example of getting the full dependency tree in graphical format, then displaying it. Graphical output will always be the full tree.

$ apt-cache dotty hello > dotfile
$ dotty dotfile

Looking it over, you can see that the 'hello' package pulls in a ton of Perl packages...and which dependency does it.

share|improve this answer
    
While that would work, it would be some serious work to do it this way to see what was pulling in a certain package if the package was a dependency of a dependency. –  tgm4883 May 6 '12 at 23:51
    
Not at all. Merely look at the dotfile picture. –  user535733 Jan 20 '13 at 3:57
add comment

apt-rdepends does this, without installing 50+ libraries of cruft like ubuntu-dev-tools.

durr@scraper:~$ apt-rdepends mercurial
Reading package lists... Done
Building dependency tree
Reading state information... Done
mercurial
  Depends: libc6 (>= 2.14)
  Depends: mercurial-common (= 2.8.2-1ubuntu1)
  Depends: python (<< 2.8)
  Depends: ucf (>= 2.0020)
libc6
  Depends: libgcc1
libgcc1
  Depends: gcc-4.9-base (= 4.9-20140406-0ubuntu1)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
gcc-4.9-base
multiarch-support
  Depends: libc6 (>= 2.3.6-2)
mercurial-common
  Depends: python (<< 2.8)
  Depends: python:any (>= 2.7.1-0ubuntu2)
python
  Depends: libpython-stdlib (= 2.7.5-5ubuntu3)
  Depends: python-minimal (= 2.7.5-5ubuntu3)
  Depends: python2.7 (>= 2.7.5-1~)
libpython-stdlib
  Depends: libpython2.7-stdlib (>= 2.7.5-1~)
libpython2.7-stdlib
  Depends: libbz2-1.0
  Depends: libc6 (>= 2.15)
  Depends: libdb5.3
  Depends: libexpat1 (>= 2.1~beta3)
  Depends: libffi6 (>= 3.0.4)
  Depends: libncursesw5 (>= 5.6+20070908)
  Depends: libpython2.7-minimal (= 2.7.6-8)
  Depends: libreadline6 (>= 6.0)
  Depends: libsqlite3-0 (>= 3.5.9)
  Depends: libssl1.0.0 (>= 1.0.0)
  Depends: libtinfo5
  Depends: mime-support
libbz2-1.0
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
libdb5.3
  Depends: libc6 (>= 2.17)
  PreDepends: multiarch-support
libexpat1
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libffi6
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libncursesw5
  Depends: libc6 (>= 2.15)
  Depends: libtinfo5 (= 5.9+20140118-1ubuntu1)
  PreDepends: multiarch-support
libtinfo5
  Depends: libc6 (>= 2.15)
  PreDepends: multiarch-support
libpython2.7-minimal
libreadline6
  Depends: libc6 (>= 2.15)
  Depends: libtinfo5
  Depends: readline-common
  PreDepends: multiarch-support
readline-common
  Depends: dpkg (>= 1.15.4)
  Depends: install-info
dpkg
  PreDepends: libbz2-1.0
  PreDepends: libc6 (>= 2.14)
  PreDepends: liblzma5 (>= 5.1.1alpha+20120614)
  PreDepends: libselinux1 (>= 2.1.0)
  PreDepends: tar (>= 1.23)
  PreDepends: zlib1g (>= 1:1.1.4)
liblzma5
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libselinux1
  Depends: libc6 (>= 2.14)
  Depends: libpcre3
  PreDepends: multiarch-support
libpcre3
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
tar
  PreDepends: libacl1 (>= 2.2.51-8)
  PreDepends: libc6 (>= 2.17)
  PreDepends: libselinux1 (>= 1.32)
libacl1
  Depends: libattr1 (>= 1:2.4.46-8)
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libattr1
  Depends: libc6 (>= 2.4)
  PreDepends: multiarch-support
zlib1g
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
install-info
  Depends: libc6 (>= 2.14)
  PreDepends: dpkg (>= 1.16.1)
libsqlite3-0
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
libssl1.0.0
  Depends: debconf (>= 0.5)
  Depends: debconf-2.0
  Depends: libc6 (>= 2.14)
  PreDepends: multiarch-support
debconf
  PreDepends: perl-base (>= 5.6.1-4)
perl-base
  PreDepends: dpkg (>= 1.14.20)
  PreDepends: libc6 (>= 2.14)
debconf-2.0
mime-support
python-minimal
  Depends: dpkg (>= 1.13.20)
  Depends: python2.7-minimal (>= 2.7.5-1~)
python2.7-minimal
  Depends: libpython2.7-minimal (= 2.7.6-8)
  Depends: zlib1g (>= 1:1.2.0)
  PreDepends: libc6 (>= 2.15)
python2.7
  Depends: libpython2.7-stdlib (= 2.7.6-8)
  Depends: mime-support
  Depends: python2.7-minimal (= 2.7.6-8)
python:any
ucf
  Depends: coreutils (>= 5.91)
  Depends: debconf (>= 1.5.19)
coreutils
  PreDepends: libacl1 (>= 2.2.51-8)
  PreDepends: libattr1 (>= 1:2.4.46-8)
  PreDepends: libc6 (>= 2.17)
  PreDepends: libselinux1 (>= 1.32)

On my clean ubuntu server install, apt-rdepends only required libapt-pkg-perl for installation. It's much lighter then ubuntu-dev-tools, and yet is still recursive, so you get all the dependencies, rather then just the first-order dependencies, like apt-cache depends returns.

share|improve this answer
add comment

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.