Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I want to compile something from source in Ubuntu/Debian, I usually get build-dependencies by running "sudo apt-get build-dep PACKAGE_NAME" in the terminal.

They are (usually) useless once the compilation job is done.

So, how do I remove all build-dependencies for a particular package?

share|improve this question
up vote 3 down vote accepted

To find out the build-dependencies of a program you can run apt-cache showsrc pkgname and that will list, amongst other information the Build-Depends, which are often files ending in -dev; although it is worth checking if any of the files (particularly those not marked -dev) are required by other programs. You could find this out by using apt-cache depends file and apt-cache rdepends file. The following example is for Shotwell:

apt-cache showsrc shotwell

Build-Depends: debhelper (>= 7.0.50~), m4, valac-0.16 (>= 0.15), libgee-dev (>= 0.5.0), libgtk-3-dev (>= 3.0.11), libexif-dev (>= 0.6.16), libsqlite3-dev (>= 3.5.9), libgexiv2-dev (>= 0.4.1-1build1), libgnomevfs2-dev (>= 2.24.2), libgphoto2-2-dev (>= 2.4.2), libsoup2.4-dev (>= 2.26.0), libxml2 (>= 2.6.32), libunique-3.0-dev (>= 1.0.0), libwebkitgtk-3.0-dev (>= 1.1.5), libgudev-1.0-dev (>= 145), libdbus-glib-1-dev (>= 0.80), libraw-dev (>= 0.13.1-2), libusb-dev, libjson-glib-dev (>= 0.7.6), libgstreamer0.10-dev (>= 0.10.28), libgstreamer-plugins-base0.10-dev (>= 0.10.32), python-scour, libunity-dev, liblaunchpad-integration-3.0-dev (>= 0.1.36), librest-dev

There is a command to do it all in one go at the webupd8 site, but I have found that it doesn't seem to work reliably with the current version of Ubuntu in that it seems to remove too much. I tried it with Pinta and it suggested removing the entire mono library. There is discussion of such problems with using commands like the webupd8 one at Launchpad. Be very careful when experimenting with any 'solutions' you might find.

It is a shame that there is no autoremove command for build-dep installed packages.

share|improve this answer
I tried aptitude method & yes, you are right , it removes too much...may because of cross-dependencies. One another mothod i found is to pass the following option (while using build-dep command): sudo apt-get build-dep -o APT::Get::Build-Dep-Automatic=true PACKAGE_NAME. Now they can be removed with apt-get autoremove. But this works only after removing the main package. – Khurshid Alam Aug 26 '12 at 10:26
Anyway, I just learned that the proper-way to do it, is using pbuilder. So no-one has to worry about installing/uninstalling dependencies. – Khurshid Alam Aug 26 '12 at 10:28

Option 1:

Remember which packages were installed by sudo apt-get build-dep PACKAGE_NAME and remove them after building.

Option 2:

apt-cache showsrc gives a great deal of information about source packages, including a list of build-depends.

apt-cache showsrc PACKAGE_NAME

For example:

$ apt-cache showsrc pithos
Package: pithos
Binary: pithos
Version: 0.3.17~git07dcbd86a1
Section: python
Maintainer: Kevin Mehall <>
Build-Depends: cdbs (>= 0.4.43), debhelper (>= 6), python, python-central (>= 0.6.11), python-distutils-extra (>= 2.10)
Architecture: all
Standards-Version: 3.8.2
Format: 1.0
Directory: pool/main/p/pithos
 cdf2129923e62bb62c246965453b40bd 2023031 pithos_0.3.17~git07dcbd86a1.tar.gz
 97689e8ada8be527d689f2c83415d3b0 1544 pithos_0.3.17~git07dcbd86a1.dsc
Python-Version: current
Checksums-Sha1: 35cbf3ae52922e50a0b81afcce2cd97a86afb254 2023031 pithos_0.3.17~git07dcbd86a1.tar.gz
Package-List: pithos deb python extra
Checksums-Sha256: 2b704d86f3dc1d36d180177d11e578bdcf74ea97b09b530144afe754e570b262 2023031 pithos_0.3.17~git07dcbd86a1.tar.gz
$ sudo apt-get remove cdbs debhelper python python-central python-distutils-extra

The risk with this option is that you may remove a package that is important for something besides building PACKAGE_NAME. Just read through the list of packages to be removed before going ahead.

share|improve this answer

Your Answer


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.