Circular dependencies

This article will describe what circular dependencies are, why they occur and how to deal with them.

What are they?
Put simply, a circular dependency occurs when two packages depend on each other in such a way that neither can be installed first. So, in other words, package A depends on package B which depends on package A.

How to resolve them
Circular dependencies are usually easily resolved by temporarily disabling a use flag, so that one of the packages doesn't depend on the other. Once one of the packages is installed, the circular dependency should not reoccur unless both packages are uninstalled.

A typical example:
 * 1) emerge -avt --alphabetical openldap

These are the packages that would be merged, in reverse order:

Calculating dependencies... done!

[nomerge     ] net-nds/openldap-2.4.19  USE="berkdb crypt -cxx -debug -experimental -gnutls -icu -iodbc ipv6 -kerberos -minimal -odbc -overlays -perl -samba sasl (-selinux) -slp -smbkrb5passwd ssl -syslog tcpd" [ebuild N    ]  dev-libs/cyrus-sasl-2.1.23-r1  USE="-authdaemond berkdb crypt gdbm -java -kerberos ldap -mysql -ntlm_unsupported_patch pam -postgres -sample -sqlite -srp ssl -urandom" [ebuild N    ]   net-nds/openldap-2.4.19  USE="berkdb crypt -cxx -debug -experimental -gnutls -icu -iodbc ipv6 -kerberos -minimal -odbc -overlays -perl -samba sasl (-selinux) -slp -smbkrb5passwd ssl -syslog tcpd"

* Error: circular dependencies:

('ebuild', '/', 'dev-libs/cyrus-sasl-2.1.23-r1', 'merge') depends on ('ebuild', '/', 'net-nds/openldap-2.4.19', 'merge') (buildtime) ('ebuild', '/', 'net-nds/openldap-2.4.19', 'merge') depends on ('ebuild', '/', 'dev-libs/cyrus-sasl-2.1.23-r1', 'merge') (buildtime)

* Note that circular dependencies can often be avoided by temporarily * disabling USE flags that trigger optional dependencies.

In the above example, openldap depends on cyrus-sasl, which depends on openldap.

Since both packages are optional dependencies of each other (via the and  use flags), we can disable either of these use flags temporarily to resolve the situation. Either way, if we want both flags enabled, we're going to have to compile one of the packages twice.

For the sake of simplicity, we'll choose to disable the use flag in the top-most package first. So:
 * 1) USE="-sasl" emerge -avt --alphabetical openldap

These are the packages that would be merged, in reverse order:

Calculating dependencies... done! [ebuild N    ] net-nds/openldap-2.4.19  USE="berkdb crypt -cxx -debug -experimental -gnutls -icu -iodbc ipv6 -kerberos -minimal -odbc -overlays -perl -samba -sasl (-selinux) -slp -smbkrb5passwd ssl -syslog tcpd" 0 kB

Total: 1 package (1 new), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No]

As you can see, Portage will now let us install openldap.

Once openldap is installed, we can proceed by running the original emerge command again:
 * 1) emerge -a openldap

These are the packages that would be merged, in reverse order:

Calculating dependencies... done! [ebuild  R   ] net-nds/openldap-2.4.19  USE="berkdb crypt -cxx -debug -experimental -gnutls -icu -iodbc ipv6 -kerberos -minimal -odbc -overlays -perl -samba sasl* (-selinux) -slp -smbkrb5passwd ssl -syslog tcpd" 0 kB [ebuild  N    ]  dev-libs/cyrus-sasl-2.1.23-r1  USE="-authdaemond berkdb crypt gdbm -java -kerberos ldap -mysql -ntlm_unsupported_patch pam -postgres -sample -sqlite -srp ssl -urandom" 0 kB

Total: 2 packages (1 new, 1 reinstall), Size of downloads: 0 kB

Would you like to merge these packages? [Yes/No]

Zapętlone zależności