ros2 build_error ai_generated true

colcon: packages have a circular dependency: pkg_a -> pkg_b -> pkg_a

ID: ros2/colcon-circular-dependency

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

Two or more packages depend on each other forming a cycle. colcon cannot determine build order.

generic

Workarounds

  1. 92% success Extract shared types/interfaces into a separate package
    Create pkg_interfaces with only .msg/.srv/.action files, depend on it from both packages
  2. 88% success Visualize the dependency graph to find the cycle
    colcon graph --dot | dot -Tpng -o deps.png
  3. 85% success Use build_depend vs exec_depend correctly in package.xml

Dead Ends

Common approaches that don't work:

  1. Force build order with --packages-above/below 80% fail

    Hides the cycle; one package will always build with stale dependencies

  2. Copy shared headers directly between packages 88% fail

    Creates undeclared dependencies; breaks on clean builds and CI