ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to properly set AMENT_PREFIX_PATH?

asked 2019-03-11 05:00:08 -0500

alsora gravatar image

updated 2019-03-11 13:58:44 -0500


I have some doubts about how AMENT_PREFIX_PATH and CMAKE_PREFIX_PATH should be set.

According to the ament design documentation

Therefore ament uses a separate environment variable (AMENT_PREFIX_PATH) for that purpose which is used at runtime. At build time of CMake packages the CMake specific variable can be derived from the generic ament variable.

Now an example where I'm having issues.

I'm cross-compiling some ROS2 packages.

Thus I have a directory ~/sysroot which contains all the library/headers/binaries of my target system. This directory also contains a cross-compiled ROS2 SDK. The cross-compiled ROS2 libraries and headers are respectively located in ~/sysroot/usr/lib and ~/sysroot/usr/include together with the system ones.

I cross-compiled the ROS2 SDK, before adding it to the sysroot, without specifying the AMENT_PREFIX_PATH. In this way the compiler was able to correctly find the needed libraries in the sysroot (e.g. Python). When I want to cross-compile an additional package, I need to set AMENT_PREFIX_PATH=~/sysroot/usr to allow the compiler to find the already cross-compiled packages. Leaving this empty results in not finding the required ROS2 dependencies.

However, if my packages require Python, this is not found.

A solution I found is to set the path to the following


This works: both Python as well as the ROS2 dependencies are found. However I'm getting a warning:

[0.280s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/root/sysroot/bin' in the environment variable AMENT_PREFIX_PATH doesn't exist

My intuition is that there could be something strange going on between AMENT_PREFIX_PATH and how CMAKE_PREFIX_PATH is automatically set.

Do you have any idea about what's going on?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-11 13:10:58 -0500

Dirk Thomas gravatar image

You need to use a colcon (:) to separate both paths - not a semicolcon (;).

edit flag offensive delete link more


THIS IS WRONG I still have the same warning, I have updated with the exact message. ROS2 should support both : as well as ; as delimiters. I don't understand how can it work if I add a path which does not exists according to ROS2...

alsora gravatar image alsora  ( 2019-03-11 13:36:18 -0500 )edit

The environment variable AMENT_PREFIX_PATH defines where to find other ROS 2 packages. If the directory doesn't actually exist it doesn't make sence to add that path to it.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-03-11 13:37:52 -0500 )edit

Ok sorry, ignore my previous message. The directory exists. Using : as delimiter the warning disappears, but I get again the error that Python is not found. The same I get if I set AMENT_PREFIX_PATH without that directory.

alsora gravatar image alsora  ( 2019-03-11 13:45:37 -0500 )edit

I might want to include more information (like your CMake toolchain file, exact steps to reproduce the problem) for others to be able to provide valuable feedback.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-03-11 18:14:18 -0500 )edit

Hello ! I am also getting a similar error. I am not getting how to set AMENT_PREFIX_PATH properly. I tried using ':' delimiter but getting the same Python error: ModuleNotFoundError: No module named 'ament_package I have opened my issue in ModuleNotFound

Do we have some progress in this?

petal gravatar image petal  ( 2019-06-09 23:50:17 -0500 )edit

Question Tools



Asked: 2019-03-11 05:00:08 -0500

Seen: 19,767 times

Last updated: Mar 11 '19