ros2
build_error
ai_generated
true
colcon: packages have a circular dependency: pkg_a -> pkg_b -> pkg_a
ID: ros2/colcon-circular-dependency
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Two or more packages depend on each other forming a cycle. colcon cannot determine build order.
genericWorkarounds
-
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
-
88% success Visualize the dependency graph to find the cycle
colcon graph --dot | dot -Tpng -o deps.png
-
85% success Use build_depend vs exec_depend correctly in package.xml
Dead Ends
Common approaches that don't work:
-
Force build order with --packages-above/below
80% fail
Hides the cycle; one package will always build with stale dependencies
-
Copy shared headers directly between packages
88% fail
Creates undeclared dependencies; breaks on clean builds and CI