Ubuntu – The difference between dependencies and pre-depends


What is meant by "depends" and "pre-depends", and the difference between those 2 types of package requirements when I am installing something in Ubuntu?

Best Answer

  • As taken from this link: https://www.debian.org/doc/debian-policy/#document-ch-relationships

    There are 5 types of dependencies:

    The meaning of the five dependency fields is as follows:


    • This declares an absolute dependency. A package will not be configured unless all of the packages listed in its Depends field have been correctly configured. The Depends field should be used if the depended-on package is required for the depending package to provide a significant amount of functionality. The Depends field should also be used if the postinst or prerm scripts require the depended-on package to be unpacked or configured in order to run. In the case of postinst configure, the depended-on packages will be unpacked and configured first.

    • In the case of prerm or other postinst actions, the package dependencies will normally be at least unpacked, but they may be only "Half-Installed" if a previous upgrade of the dependency failed. Finally, the Depends field should be used if the depended-on package is needed by the postrm script to fully clean up after the package removal. There is no guarantee that package dependencies will be available when postrm is run, but the depended-on package is more likely to be available if the package declares a dependency (particularly in the case of postrm remove). The postrm script must gracefully skip actions that require a dependency if that dependency isn't available.


    • This declares a strong, but not absolute, dependency. The Recommends field should list packages that would be found together with this one in all but unusual installations.


    • This is used to declare that one package may be more useful with one or more others. Using this field tells the packaging system and the user that the listed packages are related to this one and can perhaps enhance its usefulness, but that installing this one without them is perfectly reasonable.


    • This field is similar to Suggests but works in the opposite direction. It is used to declare that a package can enhance the functionality of another package.


    • This field is like Depends, except that it also forces dpkg to complete installation of the packages named before even starting the installation of the package which declares the pre-dependency, It works like this, when a package declaring a pre-dependency is about to be unpacked the pre-dependency can be satisfied if the depended-on package is either fully configured, or even if the depended-on package(s) are only unpacked or in the "Half-Configured" state, provided that they have been configured correctly at some point in the past (and not removed or partially removed since).

    • In this case, both the previously-configured and currently unpacked or "Half-Configured" versions must satisfy any version clause in the Pre-Depends field. When the package declaring a pre-dependency is about to be configured, the pre-dependency will be treated as a normal Depends. It will be considered satisfied only if the depended-on package has been correctly configured. However, unlike with Depends, Pre-Depends does not permit circular dependencies to be broken. If a circular dependency is encountered while attempting to honor Pre-Depends, the installation will be aborted.

    • Pre-Depends are also required if the preinst script depends on the named package. It is best to avoid this situation if possible. Pre-Depends should be used sparingly, preferably only by packages whose premature upgrade or installation would hamper the ability of the system to continue with any upgrade that might be in progress.

    Smaller Version:

    • Both depends and pre-depends mention the dependencies a package needs before installing but pre-depends forces the installation and configuration of the dependency packages before even starting with the package that needs the dependencies. dpkg will not even unpack the main package until all pre-depend packages have been dealt with. With depends, the order of the dependency packages and the main one is not important. With pre-depends it takes into consideration this and also the verification if the pre-depends packages are configures and installed or not. Without this, the main package will not even be unpacked, configured or installed. You must either have the dependencies installed before starting the process of working with the main package. If not, they have to be downloaded/configured/installed first before proceeding. pre-depends are normally used in cases where the stability of the package is important and would not affect the system or program in a very bad way but this cases are avoided with several norms also mentioned in the link above.