Portage/Help/Circular dependencies
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:
media-libs/harfbuzz[truetype]
depends onmedia-libs/freetype
media-libs/freetype[harfbuzz]
depends onmedia-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
Try this first:
root #
USE="-harfbuzz" emerge --oneshot media-libs/freetype
If it fails, 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.
This will affect those who do not yet have e.g. Python 3.10 installed or are upgrading an older installation with no recent Pythons installed.
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
Error mentions one version not yet installed
If the error mentions Python versions not yet installed like Python 3.10 but you have some valid Pythons installed (like 3.9), please try emerge -a -uvDU @world --exclude python:3.10.
Error mentions default version not yet installed (old install)
If the error mentions Python versions that are installed that are the current default (Python 3.9 at time of writing in November 2021):
- Temporarily mask
virtual/libcrypt:0/2
in /etc/portage/package.mask. - Temporarily unmask the 'crypt' use flag for
>=sys-libs/glibc-2.33-r2
(in /etc/portage/profile/package.use.mask, add:>=sys-libs/glibc-2.33-r2 -crypt
) (do not forget the profile part of the path, create the directory if needed) - Temporarily unmask
virtual/libcrypt:0/1
in /etc/portage/package.unmask. - Attempt a world upgrade.
- Undo Step 1, Step 2, and Step 3.
- Attempt another world upgrade.
This process is temporarily delaying the libxcrypt migration to get a new version of each Python needed installed before it's queued to be rebuilt against the new libcrypt.
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:
dev-lang/python[bluetooth]
depends onnet-wireless/bluez
net-wireless/bluez
unconditionally needsdev-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
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:
# 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
- dev-ml/findlib and dev-ml/labltk when findlib has USE=tk, bug #831371, Onkobu (talk) 20:18, 17 January 2022 (UTC)