User:Sam/Portage help/Circular dependencies

From Gentoo Wiki
Jump to:navigation Jump to:search

A circular dependency is where a cycle of packages depend on each other, e.g. libxcrypt -> perl -> libxcrypt.

Examples

harfbuzz and freetype

Background

On desktop profiles, USE=truetype is enabled which is needed for font rendering. But plenty of packages will require USE=harfbuzz to be enabled on media-libs/freetype for rendering.

This causes a circular dependency between media-libs/harfbuzz and media-libs/freetype. It appears there's discussion ongoing upstream as to how to resolve the issue (perhaps by embedding code from one into the other).

The cycle looks like this:

  1. media-libs/harfbuzz[truetype] depends on media-libs/freetype
  2. media-libs/freetype[harfbuzz] depends on media-libs/harfbuzz[truetype]


Given so many packages need media-libs/freetype[harfbuzz], it must be turned on in almost all situations - but it's frustrating as it's not immediately obvious from the two ebuilds themselves.

Portage output

root #emerge -p -uvDU @world
[...]
 * Error: circular dependencies:

(media-libs/harfbuzz-2.8.1:0/0.9.18::gentoo, ebuild scheduled for merge) depends on
 (media-libs/freetype-2.10.4:2/2::gentoo, ebuild scheduled for merge) (buildtime_slot_op)
  (media-libs/harfbuzz-2.8.1:0/0.9.18::gentoo, ebuild scheduled for merge) (buildtime)

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

Solution

The simplest solution which works for now is taking advantage of the fact that an older version of x11-libs/pango does not need freetype[harfbuzz]:

root #USE="-harfbuzz" emerge --oneshot media-libs/freetype media-libs/harfbuzz =x11-libs/pango-1.48.5-r1

If that fails, in almost all cases, the following should suffice,

root #USE="-harfbuzz" emerge --oneshot media-libs/freetype

If not, read on.

Sledgehammer

The following works although is a little bit convoluted:

root #USE=-* emerge --verbose --oneshot --nodeps media-libs/harfbuzz
root #USE=-* emerge --verbose --oneshot --nodeps media-libs/freetype
root #USE=-truetype emerge --verbose --oneshot --nodeps media-libs/harfbuzz
root #USE="-* truetype harfbuzz" emerge --verbose --oneshot media-libs/freetype
root #emerge --verbose --oneshot media-libs/freetype

Or for multilib, something like:

root #USE="abi_x86_32" emerge -v1 sys-libs/zlib
root #USE="-* abi_x86_32" emerge --verbose --oneshot --nodeps media-libs/harfbuzz
root #USE="-* abi_x86_32" emerge --verbose --oneshot --nodeps media-libs/freetype
root #USE="-* truetype harfbuzz abi_x86_32" emerge --verbose --oneshot media-libs/freetype
root #emerge --verbose --oneshot media-libs/freetype

Python and libcrypt

Background

See the libcrypt migration article. Occurs when upgrading from stable to ~arch. Temporary until migrated stages ship (once the libxcrypt migration hits stable).

Portage output

root #emerge -p -uvDU @world
[...]

* Error: circular dependencies:

(dev-lang/python-3.10.0_beta4:3.10/3.10::gentoo, ebuild scheduled for merge) depends on
 (virtual/libcrypt-2:0/2::gentoo, ebuild scheduled for merge) (buildtime_slot_op)
  (sys-libs/libxcrypt-4.4.23-r1:0/1::gentoo, ebuild scheduled for merge) (runtime)
   (sys-libs/glibc-2.33-r2:2.2/2.2::gentoo, ebuild scheduled for merge) (buildtime)
    (dev-lang/python-3.10.0_beta4:3.10/3.10::gentoo, ebuild scheduled for merge) (buildtime)

Solution

In this case, please try emerge -a -uvDU @world --exclude python:3.10.

Python and bluez

Background

Gentoo's desktop profiles enable USE=bluetooth which is handy for plenty of users. While it's useful for most packages, it's debatable whether or not it should apply to dev-lang/python as it seems not much uses its bluetooth support.

See bug #764623 for more discussion.

The cycle looks like this:

  1. dev-lang/python[bluetooth] depends on net-wireless/bluez
  2. net-wireless/bluez unconditionally needs dev-lang/python to build!

Portage output

root #emerge -p -uvDU @world
[...]

(sys-apps/dbus-1.12.20-r1:0/0::gentoo, ebuild scheduled for merge) depends on
 (x11-libs/libX11-1.7.0:0/0::gentoo, ebuild scheduled for merge) (buildtime)
  (x11-libs/libxcb-1.14:0/1.12::gentoo, ebuild scheduled for merge) (buildtime)
   (dev-lang/python-3.9.0-r1:3.9/3.9::gentoo, ebuild scheduled for merge) (buildtime)
    (net-wireless/bluez-5.55:0/3::gentoo, ebuild scheduled for merge) (buildtime)
     (sys-apps/dbus-1.12.20-r1:0/0::gentoo, ebuild scheduled for merge) (buildtime_slot_op)

It might be possible to break this cycle
by applying any of the following changes:
- net-wireless/bluez-5.55 (Change USE: -systemd)
- sys-apps/dbus-1.12.20-r1 (Change USE: -X)
- dev-lang/python-3.9.0-r1 (Change USE: -bluetooth)

Solution

Note
A helpful observation: bluez's dependency is build-time only.

In some cases, as a result of this observation, it's sufficient to run (adjust :3.9 to whichever new slot of Python is being pulled in):

root #emerge -p -uvDU @world --exclude dev-lang/python:3.9

Where this isn't enough, it's easiest to temporarily disable bluetooth support in dev-lang/python:

FILE /etc/portage/package.use
# Avoid a circular dependency between python and bluez
dev-lang/python -bluetooth

Then complete a world update, then delete the entry from the file.

TODO

[07:32:55]  <@juippis> sam_: are you collecting known circular dep cases?
[07:33:00]  <@juippis> sam_: there was one with mit-krb5
[07:35:33]  <@juippis> I _think_ mit-krb5[openldap] -> openldap[kerberos] -> mit-krb5. Also there was one with qemu where it depends on itself

mono and libgdiplus