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.

Running sudo apt-get install <PACKAGE> will install the package, its dependencies, and any other recommended packages.

However, there does not seem to be a way to install only the dependencies of a package and exclude the package itself.

How would one go about doing this?

share|improve this question
    
Just curious, why do you want to do this? –  Kris Harper Nov 1 '11 at 18:01
    
@root45: Well it's a bit of a unique situation: I have the source code to a Python package in the repos. and it isn't starting. I need to install the dependencies for the package without installing the package itself (since I already have the code). –  Nathan Osman Nov 1 '11 at 18:04
1  
Couldn't you just do a dry-run of apt-get install and look at what is going to get installed, then just install everything but the app you are compiling? –  duffydack Nov 1 '11 at 18:11
1  
Or just install it and then remove the application (but not its dependencies). And/or install an updated/fixed package after building it. –  JanC Nov 1 '11 at 18:27
    
I need the ability to do this so I can build and install a source package that isn't already built for my architecture. apt-get build-dep installs build dependencies, so apt-get -b source works, but runtime dependencies aren't installed, so dpkg -i *.deb fails. –  Trevor Robinson Jan 26 '12 at 22:03
show 1 more comment

5 Answers

up vote 9 down vote accepted

This will install all packages in the package's Depends and PreDepends field:

sudo apt-get install $(apt-cache depends <PACKAGE> | grep Depends | sed "s/.*ends:\ //" | tr '\n' ' ')

Basically you ask for all dependencies, filter out the (Pre)Depends, and format that output for apt-get.

One problem are dependencies like

Depends: pulseaudio
  pulseaudio:i386

or virtual packages like

Depends: <java6-runtime-headless>
  default-jre-headless
  openjdk-6-jre-headless

So: use with care - it doesn't work in all cases!

share|improve this answer
1  
There are a lot of cases this doesn't handle, e.g. it will completely break on virtual packages (which are printed in angle brackets). See here for examples: askubuntu.com/questions/25361/… –  Trevor Robinson Jan 26 '12 at 22:06
    
Thanks for the hint, though I'm not really sure how the handle all those issues. :-( –  htorque Jan 26 '12 at 22:10
add comment

apt-get build-dep <package> will do the trick.

share|improve this answer
4  
That won't work because the package has runtime dependencies that won't be installed with apt-get build-dep. –  Nathan Osman Sep 19 '12 at 1:35
add comment

If you don't mind copy/past, just simulate an apt-get install with -s. That way you will see which other packages will get installed and/or upgrade, then you just remove the package name you don't want to install from that list and voila.

sudo apt-get install -s <package>

share|improve this answer
add comment

I installed a vendor supplied vagrant from a .deb, and it didn't list its dependencies, so I went into aptitude, ignored the installed .deb and went to the older one that ubuntu supplied, then added all those deps and installed them from there.

share|improve this answer
    
You need to add more details than that. –  RolandiXor Nov 22 '13 at 4:20
add comment

To install dependencies only you can use apt-cache show package | grep Dendends, it will give you a list of dependencies:

apt-cache show apache2 | grep Depends
Depends: apache2-mpm-worker (= 2.2.22-6ubuntu5.1) | apache2-mpm-prefork (= 2.2.22-6ubuntu5.1) | apache2-mpm-event (= 2.2.22-6ubuntu5.1) | apache2-mpm-itk (= 2.2.22-6ubuntu5.1), apache2.2-common (= 2.2.22-6ubuntu5.1)

then you can decide what package install with apt-get. There is also aptitude in the interactive mode, you look for the package select it and then install it's dependencies:

enter image description here

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.