ros2 build_error ai_generated true

colcon build: CMake Error at CMakeLists.txt: find_package(catkin) failed

ID: ros2/colcon-build-catkin-package-not-found

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2023-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
ROS2 Humble (Ubuntu 22.04) active
ROS2 Iron (Ubuntu 22.04) active
ROS2 Rolling (Ubuntu 24.04) active

Root Cause

A ROS1 (catkin) package is being built in a ROS2 workspace, but catkin is not available or the workspace is not configured for mixed builds.

generic

中文

在ROS2工作空间中构建ROS1(catkin)包,但catkin不可用或工作空间未配置为混合构建。

Official Documentation

https://docs.ros.org/en/humble/Tutorials/Intermediate/URDF/URDF-Main.html

Workarounds

  1. 90% success Remove the catkin package from the workspace or migrate it to ament_cmake. If you need ROS1 compatibility, use a separate catkin workspace and source it before building the ROS2 workspace.
    Remove the catkin package from the workspace or migrate it to ament_cmake. If you need ROS1 compatibility, use a separate catkin workspace and source it before building the ROS2 workspace.
  2. 70% success Use colcon's --merge-install or --cmake-args to include the catkin workspace: colcon build --cmake-args -DCATKIN_DEVEL_PREFIX=/path/to/catkin_ws/devel
    Use colcon's --merge-install or --cmake-args to include the catkin workspace: colcon build --cmake-args -DCATKIN_DEVEL_PREFIX=/path/to/catkin_ws/devel

中文步骤

  1. 从工作空间中移除catkin包,或将其迁移到ament_cmake。如果需要ROS1兼容性,请使用单独的catkin工作空间,并在构建ROS2工作空间前source它。
  2. 使用colcon的--merge-install或--cmake-args包含catkin工作空间:colcon build --cmake-args -DCATKIN_DEVEL_PREFIX=/path/to/catkin_ws/devel

Dead Ends

Common approaches that don't work:

  1. Install catkin via apt and rebuild 90% fail

    catkin is not a ROS2 package; even if installed, colcon won't find it without ROS1 bridge setup.

  2. Manually set CMAKE_PREFIX_PATH to catkin workspace 85% fail

    colcon ignores manual CMAKE_PREFIX_PATH overrides for workspace isolation.