EQUIRED cmake build_error ai_generated true

CMake Error: find_package(ament_cmake REQUIRED) failed: ament_cmake not found

ID: cmake/ament-cmake-not-found

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3 active

Root Cause

CMake cannot find ament_cmake. ROS 2 environment not sourced or package not installed.

generic

Workarounds

  1. 95% success Source ROS 2 installation before cmake/colcon
    source /opt/ros/humble/setup.bash && colcon build

    Sources: https://cmake.org/cmake/help/latest/

  2. 90% success Install via apt
    sudo apt install ros-humble-ament-cmake
  3. 85% success Add source to shell profile
    echo 'source /opt/ros/humble/setup.bash' >> ~/.bashrc

Dead Ends

Common approaches that don't work:

  1. Install ament_cmake via pip 90% fail

    ament_cmake is CMake-based, distributed via apt, not pip

  2. Add ament_cmake as git submodule 82% fail

    Core ROS 2 infrastructure; source build causes version conflicts