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

ament_export_interfaces uses absolute path / not being relocatable #173

Closed
crdelsey opened this issue May 31, 2019 · 11 comments
Closed

ament_export_interfaces uses absolute path / not being relocatable #173

crdelsey opened this issue May 31, 2019 · 11 comments
Labels
enhancement New feature or request

Comments

@crdelsey
Copy link

When trying to find_package(rviz_common), I get the following error

CMake Error in CMakeLists.txt:
  Imported target "rviz_common::rviz_common" includes non-existent path

    "/home/jenkins-agent/workspace/packaging_linux/ws/install/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

This happens when I try to build using osrf/ros2:nightly docker image or just use https://ci.ros2.org/view/packaging/job/packaging_linux/lastSuccessfulBuild/artifact/ws/ros2-package-linux-x86_64.tar.bz2 directly.

I believe the problem is that the binary packages are built in a certain location on the CI machine. When they get extracted to the new location in the docker image or on my local machine, the path is now incorrect. It seems there is a variable used in the setup scripts (COLCON_CURRENT_PREFIX) that is supposed to override the as-built path, but it doesn't seem to work for the INTERFACE_INCLUDE_DIRECTORIES variable.

@dirk-thomas
Copy link
Contributor

ament doesn't know anything about the build tool (colcon) being used. You could simply build each package with cmake / make / make install. Therefore it also doesn't know about COLCON_CURRENT_PREFIX.

Please provide more context what exactly you are trying to do, steps to reproduce, etc.

@dirk-thomas dirk-thomas added more-information-needed Further information is required question Further information is requested labels May 31, 2019
@crdelsey
Copy link
Author

In our CI, we're building the navigation2 stack against the osrf/ros2:nightly image. The procedure at a high level is to copy our repo into the docker image, source /opt/ros2/dashing/setup.sh, and then run colcon build on our repo.

At that point we get the error mentioned above.

I believe this is the first time we've tried to find a package that has had an ament_export_interfaces call in the package, so I suspect the problem has something to do with the way that macro is implemented.

Here's our dockerfile for exact details (https://github.com/ros-planning/navigation2/blob/master/Dockerfile)

@dirk-thomas
Copy link
Contributor

Please post the complete error message (e.g. which package does this happen).

@crdelsey
Copy link
Author

Here's the complete output

[connext_cmake_module] Warning: The location at which Connext was found when the workspace was built [[/opt/rti.com/rti_connext_dds-5.3.1]] does not point to a valid directory, and the NDDSHOME environment variable has not been set. Support for Connext will not be available.
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.
building navstack_dependencies_ws
[0.317s] WARNING:colcon.colcon_core.package_selection:ignoring unknown package 'ros1_bridge' in --packages-skip
Starting >>> cv_bridge
Starting >>> camera_calibration_parsers
Starting >>> gazebo_dev
Starting >>> gazebo_msgs
Starting >>> image_transport
Starting >>> image_geometry
Starting >>> angles
Starting >>> behaviortree_cpp
Finished <<< gazebo_dev [1.80s]                                
Finished <<< angles [1.79s]
Finished <<< image_geometry [4.26s]                            
Finished <<< camera_calibration_parsers [4.41s]                
Finished <<< behaviortree_cpp [4.68s]
Finished <<< image_transport [5.03s]                               
Starting >>> camera_info_manager
Finished <<< cv_bridge [7.33s]                                        
Starting >>> opencv_tests
Starting >>> vision_opencv
Finished <<< camera_info_manager [2.61s]                            
Finished <<< opencv_tests [0.84s]                                   
Finished <<< vision_opencv [1.60s]                                  
[Processing: gazebo_msgs]                                
Finished <<< gazebo_msgs [47.3s]
Starting >>> gazebo_ros
Finished <<< gazebo_ros [9.28s]                          
Starting >>> gazebo_plugins
Finished <<< gazebo_plugins [14.0s]                                
Starting >>> gazebo_ros_pkgs
Finished <<< gazebo_ros_pkgs [1.11s]                          

Summary: 14 packages finished [1min 12s]
  2 packages had stderr output: behaviortree_cpp gazebo_msgs
ROS_DISTRO was set to 'dashing' before. Please make sure that the environment does not mix paths from different distributions.
[connext_cmake_module] Warning: The location at which Connext was found when the workspace was built [[/opt/rti.com/rti_connext_dds-5.3.1]] does not point to a valid directory, and the NDDSHOME environment variable has not been set. Support for Connext will not be available.
ROS_DISTRO was set to 'melodic' before. Please make sure that the environment does not mix paths from different distributions.
building navigation2_ws
[0.365s] WARNING:colcon.colcon_core.package_selection:ignoring unknown package 'ros1_bridge' in --packages-skip
Starting >>> nav2_common
Starting >>> nav_2d_msgs
Finished <<< nav2_common [0.67s]                                   
Starting >>> nav2_msgs
Starting >>> nav2_voxel_grid
Finished <<< nav2_voxel_grid [2.76s]                                 
Finished <<< nav_2d_msgs [11.9s]
Starting >>> dwb_msgs
Finished <<< dwb_msgs [16.1s]
Finished <<< nav2_msgs [33.9s]
Starting >>> nav2_util
Starting >>> nav_2d_utils
Finished <<< nav_2d_utils [2.46s]                                   
Finished <<< nav2_util [3.84s]                         
Starting >>> nav2_robot
Starting >>> nav2_lifecycle_manager
Starting >>> nav2_map_server
Starting >>> nav2_amcl
Starting >>> nav2_dynamic_params
Finished <<< nav2_robot [4.27s]                                         
Starting >>> nav2_tasks
Starting >>> nav2_navfn_planner
Finished <<< nav2_dynamic_params [4.27s]
Finished <<< nav2_lifecycle_manager [4.48s]
Starting >>> nav2_rviz_plugins
Finished <<< nav2_map_server [4.66s]                                          
Starting >>> nav2_costmap_2d
Finished <<< nav2_amcl [5.13s]                                          
Finished <<< nav2_tasks [3.09s]                                          
Starting >>> nav2_bt_navigator
Starting >>> nav2_mission_executor
Starting >>> nav2_motion_primitives
Finished <<< nav2_navfn_planner [3.63s]                                        
--- stderr: nav2_rviz_plugins                                            
CMake Error in CMakeLists.txt:
  Imported target "rviz_common::rviz_common" includes non-existent path

    "/home/jenkins-agent/workspace/packaging_linux/ws/install/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Error in CMakeLists.txt:
  Imported target "rviz_common::rviz_common" includes non-existent path

    "/home/jenkins-agent/workspace/packaging_linux/ws/install/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Error in CMakeLists.txt:
  Imported target "rviz_common::rviz_common" includes non-existent path

    "/home/jenkins-agent/workspace/packaging_linux/ws/install/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



CMake Error in CMakeLists.txt:
  Imported target "rviz_common::rviz_common" includes non-existent path

    "/home/jenkins-agent/workspace/packaging_linux/ws/install/include"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.



---
Failed   <<< nav2_rviz_plugins	[ Exited with code 1 ]
Aborted  <<< nav2_bt_navigator                     
Aborted  <<< nav2_mission_executor
Aborted  <<< nav2_motion_primitives                
Aborted  <<< nav2_costmap_2d                                           

Summary: 14 packages finished [50.8s]
  1 package failed: nav2_rviz_plugins
  4 packages aborted: nav2_bt_navigator nav2_costmap_2d nav2_mission_executor nav2_motion_primitives
  4 packages had stderr output: dwb_msgs nav2_msgs nav2_rviz_plugins nav_2d_msgs
  9 packages not processed

I see that in rviz_commonExport.cmake, where the INTERFACE_INCLUDE_DIRECTORIES variable is set, most of the paths are hard-coded. Just the first one adds an ${_IMPORT_PREFIX} to the path. Maybe there was supposed to be a loop where this prefix gets added to every path in the variable

@crdelsey
Copy link
Author

I'm assuming that rviz_commonExport.cmake gets generated by ament. Maybe it's a cmake bug.

@crdelsey
Copy link
Author

crdelsey commented Jun 3, 2019

I don't fully understand the details of ament yet, so this may not be relevant. But when comparing ament_export_interfaces.cmake to ament_export_include_directories.cmake, the include_directories macro has some code to avoid absolute paths. The export_interfaces file does not have the equivalent, that I can see.

It seems like this may be the cause of the issue we are seeing.

@dirk-thomas
Copy link
Contributor

Neither of the two files generated by ament_cmake (ament_export_include_directories.cmake and ament_export_interfaces.cmake) do contain absolute paths as far as I can see. And that is intentional since they are supposed to be relocatable.

The problem might be coming from the file rviz_commonExport.cmake. That one does contain absolute paths. It is generated by CMake using information passed as interface properties: https://github.com/ros2/rviz/blob/a20152c290739c4cf2ef5af06a7e498a744162ac/rviz_common/CMakeLists.txt#L239-L273

Within ament_target_dependencies the recursive information of each passed package name are being used:

list_append_unique(include_dirs ${${package_name}_INCLUDE_DIRS})
list(APPEND libraries ${${package_name}_LIBRARIES})

And these information are certainly not relocatable.

@dirk-thomas dirk-thomas added enhancement New feature or request and removed more-information-needed Further information is required question Further information is requested labels Jun 3, 2019
@crdelsey
Copy link
Author

crdelsey commented Jun 5, 2019

It doesn't look like this issue exists in the released rviz_common package.

I think the problem comes down to an incompatibility between the way the OSRF build farm builds the nightly binaries and the way they are deployed in the osrf/ros2 docker image. CI installs the binaries in the local workspace, but the docker image installs them under /opt/ros instead.

From CMake's perspective, all the rviz_common's external dependencies have been relocated, and that doesn't seem to be supported by CMake.

Given that, I think you can close this issue here. The problem more appropriately belongs with the Dockerfile, I believe.

@dirk-thomas
Copy link
Contributor

Given that, I think you can close this issue here. The problem more appropriately belongs with the Dockerfile, I believe.

That conclusion is incorrect.

The problem is that the resulting CMake code for the imported target isn't relocatable. In the case of Docker I assume the files aren't being relocated hence it works. The packages in the archive are certainly built in a different location than the user unpacks them to and therefore are relocated. Since the generated CMake code contains absolute paths that will break.

@crdelsey
Copy link
Author

crdelsey commented Jun 5, 2019

It seems the generated CMake code allows rviz_common to be relocated. It just doesn't allow rviz_common's dependencies to be relocated. Those are the hard-coded paths. But those dependencies have been relocated in this case, because the dependencies are other ros packages.

The actual paths in the generated CMake code are a mix of system dependencies and other ros packages. To make this truly relocatable, CMake would need to be informed which dependencies should be specified with relative paths and which with absolute. That might be possible in CMake, but I haven't found a way to do that yet.

@dirk-thomas dirk-thomas changed the title ament_export_interfaces not respecting COLCON_CURRENT_PREFIX ament_export_interfaces uses absolute path / not being relocatable Jun 6, 2019
@dirk-thomas
Copy link
Contributor

After having recently worked on interface targets (#231, #232, #235) I am pretty certain that exported interface targets (the modern CMake way) are relocatable if and only if they only use interface targets from dependencies. If at least one of the dependencies doesn't support interface targets but only provides <depname>_INCLUDE_DIRS (the classic CMake way) then that absolute paths gets embedded in the interface target which makes the result not relocatable.

So the actual bug in this case is that rviz_common exports an interface target even though its dependencies still use classic CMake variables. I don't think there is anything in ament_cmake which can resolve this. Either rviz_common needs to be updated to not export interface targets or all of its recursive dependencies need to be updated to use modern CMake. @wjwwood FYI since you are the maintainer of rviz_common.

Therefore I will go ahead and close this ticket. Please feel free to continue commenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants