ros2
build_error
ai_generated
true
colcon build: CMake Error at CMakeLists.txt: find_package(ament_cmake) failed
ID: ros2/colcon-build-cmake-error
88%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
colcon build fails because ament_cmake is not found. ROS 2 environment is not sourced.
genericWorkarounds
-
95% success Source the ROS 2 installation before building
source /opt/ros/humble/setup.bash && cd ~/ros2_ws && colcon build
-
90% success Install missing packages via apt
sudo apt install ros-humble-ament-cmake
-
88% success Use rosdep to install all dependencies
cd ~/ros2_ws && rosdep install --from-paths src --ignore-src -y
Dead Ends
Common approaches that don't work:
-
Install ament_cmake via pip
90% fail
ament_cmake is a CMake package, not Python; pip install does nothing useful
-
Build ament_cmake from source in your workspace
80% fail
ament_cmake is core ROS 2 infrastructure; building from source causes version conflicts