Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dependency export of pluginlib #293

Closed
ksuszka opened this issue Mar 6, 2023 · 5 comments
Closed

Incorrect dependency export of pluginlib #293

ksuszka opened this issue Mar 6, 2023 · 5 comments
Assignees
Labels
ros2 PR tackling a ROS2 branch

Comments

@ksuszka
Copy link

ksuszka commented Mar 6, 2023

A few days ago our code which uses diagnostic_aggregator stopped compiling. After some digging it seems that the latest release of humble pacakges (20230221) includes this change which breaks packages with a dependency on the diagnostic_aggregator.

Here is a command to reproduce this error using docker (it creates an empty package with a dependency on the diagnostic_aggregator loaded through ament_cmake_auto helpers):

cat <<END_OF_DOCKERFILE | DOCKER_BUILDKIT=1 docker build --build-arg ROS_VERSION=humble -
# syntax=docker/dockerfile:1
ARG ROS_VERSION
FROM ros:\$ROS_VERSION
ARG ROS_VERSION
RUN apt-get update && apt-get install -y ros-\$ROS_VERSION-diagnostic-aggregator
RUN mkdir -p /ws/src/xxx

RUN <<"EOF" cat >> /ws/src/xxx/package.xml
<package format="3">
  <name>xxx</name>
  <version>0.0.1</version>
  <description>x</description>
  <maintainer email="x@x.xx"></maintainer>
  <license>BSD</license>

  <buildtool_depend>ament_cmake_auto</buildtool_depend>

  <depend>diagnostic_aggregator</depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>
EOF

RUN <<"EOF" cat >> /ws/src/xxx/CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(xxx)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

ament_auto_add_library(${PROJECT_NAME}_lib SHARED test.cpp)

ament_auto_package()
EOF

RUN touch /ws/src/xxx/test.cpp

WORKDIR /ws
RUN . /opt/ros/\$ROS_VERSION/setup.sh && colcon build

END_OF_DOCKERFILE

Running this command fails with the error:

CMake Error at /opt/ros/humble/share/ament_cmake_auto/cmake/ament_auto_add_library.cmake:66 (add_library):
   Target "_lib" links to target "pluginlib::pluginlib" but the target was not
   found.  Perhaps a find_package() call is missing for an IMPORTED target, or
   an ALIAS target is missing?

Changing ROS_VERSION to galactic in the first line makes it finish successfully.

@ct2034 ct2034 self-assigned this Mar 7, 2023
@ct2034 ct2034 added the ros2 PR tackling a ROS2 branch label Mar 7, 2023
ct2034 added a commit to ct2034/ros-docker-playground that referenced this issue Mar 7, 2023
Signed-off-by: Christian Henkel <christian.henkel2@de.bosch.com>
@ct2034
Copy link
Collaborator

ct2034 commented Mar 7, 2023

Hi @ksuszka. Thanks for reporting the issue.
Since diagnostic_aggregator has no difference in the CMakeLists between humble and galactic, I assume the problem is ament_auto_find_build_dependencies not finding the pluginlib dependency
I was able to fix your problem by manually adding a dependency on pluginlib: ct2034/ros-docker-playground@ba90e15
Could you please let me know if this approach works for you?

@ksuszka
Copy link
Author

ksuszka commented Mar 7, 2023

Yes, adding pluginlib explicitly solves the problem.
However, your assumption that there is no difference between galactic and humble seems to be incorrect.
This code worked on humble with ros-humble-diagnostic-aggregator/jammy,now 3.0.0-1jammy.20230118.000027. The latest ros-humble-diagnostic-aggregator/jammy 3.1.0-2jammy.20230221.145107 broke it. Galactic is still on ros-galactic-diagnostic-aggregator/focal,now 2.1.3-1focal.20221208.065350 version, and it seems that CMakeLists.txt for galactic branch is 3 years old and CMakeLists.txt for humble was updated 4 months ago with this commit: c198897

And I've just checked that ros2 branch compiled on ros:rolling image is also affected (and it has the same commit).

ct2034 added a commit to ct2034/diagnostics that referenced this issue Mar 8, 2023
Signed-off-by: Christian Henkel <christian.henkel2@de.bosch.com>
@ct2034
Copy link
Collaborator

ct2034 commented Mar 8, 2023

You are absolutely right. 👍
I have looked into it again, and I think I have found a solution.
Just to clarify: Can you also reproduce this error with diagnostic_aggregator from source? If so, can you please verify that #294 fixes it.

@ksuszka
Copy link
Author

ksuszka commented Mar 8, 2023

Yes, I can confirm that #294 compiled on the latest ros:rolling and ros:humble images fixes the issue.

Thanks for addressing this!

@ct2034
Copy link
Collaborator

ct2034 commented Mar 8, 2023

Thanks for the confirmation

@ct2034 ct2034 closed this as completed in 1030799 Mar 8, 2023
ct2034 added a commit to ct2034/diagnostics that referenced this issue Mar 20, 2023
Signed-off-by: Christian Henkel <christian.henkel2@de.bosch.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ros2 PR tackling a ROS2 branch
Projects
None yet
Development

No branches or pull requests

2 participants