Skip to content

[Bug]: Missing package.xml installation causes ros2 doctor --report to fail #125

@mini-1235

Description

@mini-1235

Before proceeding, is there an existing issue or discussion for this?

OS and version

24.04

Open-RMF installation type

Binaries

Other Open-RMF installation methods

No response

Open-RMF version or commit hash

latest commit

ROS distribution

Rolling

ROS installation type

Binaries

Other ROS installation methods

No response

Package or library, if applicable

No response

Description of the bug

Hi, I am running ros2 doctor --report and encountered the following warning:

opt/ros/rolling/lib/python3.12/site-packages/ros2doctor/api/__init__.py: 262: UserWarning: Fail to call PackageReport class functions.

After some investigation, I found that the issue appears to be related to several RMF-related packages that do not properly install their package.xml files. The affected packages include (but may not be limited to):

Steps to reproduce the bug

  1. Install any of the packages listed above
  2. Run ros2 doctor --report

Expected behavior

Able to list versions

Actual behavior

opt/ros/rolling/lib/python3.12/site-packages/ros2doctor/api/init.py: 262: UserWarning: Fail to call PackageReport class functions.

Fails to report version information for any of the packages

Additional information or screenshots

As described in the tutorial https://docs.ros.org/en/rolling/How-To-Guides/Ament-CMake-Documentation.html

The project setup is done by ament_package() and this call must occur exactly once per package. ament_package() installs the package.xml, registers the package with the ament index, and installs configuration (and possibly target) files for CMake so that it can be found by other packages using find_package. Since ament_package() gathers a lot of information from the CMakeLists.txt it should be the last call in your CMakeLists.txt.

Adding ament_package() at the end of the CMakeLists.txt resolves the issue. However, I noticed that the package currently exports the ament index manually, which can alternatively be handled by ament_package() or other ament_* commands. Is there a specific reason for avoiding the ament_* syntax in these repos?

# Export ament index path
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} "")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} DESTINATION share/ament_index/resource_index/packages)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv "prepend-non-duplicate;AMENT_PREFIX_PATH;")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/${PROJECT_NAME}/hook/ament_prefix_path.dsv DESTINATION share/${PROJECT_NAME}/hook)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions