ruby: Fix mutually dependent links edge-case

Fixes #28759.
Closes #29600.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>