ros2 build_error ai_generated true

PackageNotFoundError: Packages not found: ['my_package']

ID: ros2/package-not-found

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

colcon build or ros2 run cannot locate the package. Usually the workspace is not sourced or the package name is misspelled.

generic

Workarounds

  1. 95% success Source the workspace overlay after building
    cd ~/ros2_ws && colcon build --packages-select my_package && source install/setup.bash
  2. 88% success Verify package.xml <name> matches the directory name and CMakeLists project() name
  3. 85% success Check that the package is listed in colcon list output
    cd ~/ros2_ws && colcon list | grep my_package

Dead Ends

Common approaches that don't work:

  1. Re-run colcon build without sourcing the workspace first 80% fail

    Building and running in the same terminal without sourcing install/setup.bash means the new package is invisible to ros2 CLI

  2. Manually copy the package into /opt/ros/humble/share/ 85% fail

    System install paths are managed by apt; manual copies get overwritten and break dependency resolution

  3. Add the package path to AMENT_PREFIX_PATH by hand 70% fail

    Does not persist across terminals and masks the real issue: the workspace overlay is not sourced