How to Fix the Circular Dependency Between GLib and GObject-Introspection on FreeBSD
Updating ports on FreeBSD, you might hit a frustrating wall with devel/glib20 and devel/gobject-introspection. You try to update glib, but it fails because it requires a newer gobject-introspection. However, updating gobject-introspection fails because it needs a newer glib.
Welcome to the classic chicken-and-egg (circular dependency) problem.
The Root Cause
- gobject-introspection requires a current version of glib to build.
- glib (in its default configuration) requires gobject-introspection to generate introspection data.
When both ports fall out of sync, neither can compile first.
The Solution: Using the bootstrap Flavor
Fortunately, the FreeBSD devel/glib20 port includes a bootstrap flavor. This flavor builds a minimal version of GLib without depending on gobject-introspection, allowing you to break the loop cleanly.
Here is the step-by-step procedure to resolve it:
Step 1: Build GLib in Bootstrap Mode
First, switch to the glib20 directory and reinstall it using the bootstrap flavor. This installs the core GLib libraries without requiring gobject-introspection:
cd /usr/ports/devel/glib20
make FLAVOR=bootstrap clean reinstall cleanStep 2: Rebuild GObject-Introspection
Now that your system has the updated core GLib binaries, you can successfully rebuild gobject-introspection:
cd /usr/ports/devel/gobject-introspection
make clean reinstall cleanStep 3: Restore GLib to the Default Flavor
Finally, rebuild glib20 using its default flavor so you get the full package with complete introspection support:
cd /usr/ports/devel/glib20
make FLAVOR=default clean reinstall cleanTL;DR / Quick Commands
# 1. Break the cycle with bootstrap GLib
cd /usr/ports/devel/glib20 && make FLAVOR=bootstrap clean reinstall clean
# 2. Upgrade gobject-introspection
cd /usr/ports/devel/gobject-introspection && make clean reinstall clean
# 3. Rebuild full GLib
cd /usr/ports/devel/glib20 && make FLAVOR=default clean reinstall cleanThat's it! Your ports system is back in sync without having to force-delete packages or break system dependencies.