Ask Your Question

Local package path is not prioritized over installed package path

asked 2019-01-08 02:05:18 -0600

vandanamandlik gravatar image

updated 2019-01-08 07:31:28 -0600

jayess gravatar image

I have build one package locally in separate workspace and using that package path (install/setup.bash) to build my package. But when I try to build my package it doesn't take locally build package path but it takes path of installed package because same package is there in crystal setup.

Does any one know how to solve this issue ?


cd my_package_ws
source /opt/ros/crystal/setup.bash
source /opt/ros/locally_build_package/install/setup.bash
colcon build

As you said package used is depends on the order in which they appear in your environment variable. In my build steps, environment variable "/opt/ros/crystal/setup.bash" path appears first so colcon build finds package from installed packages.

Do you know how can I forcefully tell 'colcon build' to avoid using installed path ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-09-10 20:16:40 -0600

ALTinners gravatar image

updated 2019-09-10 20:19:42 -0600

From what I've found on my machines - this actually needs more definition than what it appears to. ROS_PACKAGE_PATH is not the only factor in play.

When a package is installed and ends up in /opt/ros/{distro}/include it becomes available for includeing via the CMake directive include_directories( ${catkin_INCLUDE_DIRS})

Say you've installed ros-{distro}-excellent-package but also have excellent_package in your workspace. You will need:

  • ROS_PACKAGE_PATH defined with your workspace appearing first (ie: /home/altinners/workspace_ws/src:/opt/ros/{distro}/share)
  • Your include_directories directives set up so that your _local_ packages appear first ie: include_directories( include ${excellent_package_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ) - this prioritises the local include files over the system installed ones

This is not really necessary if you don't ever need to reference header files - but in most cases where I think anyone would need to have local packages outside of the main /opt folder you'd want to reference the headers.

edit flag offensive delete link more

answered 2019-01-08 03:59:01 -0600

Reamees gravatar image

In Kinetic, which package is used depends on the order in which they appear in your environment variable ROS_PACKAGE_PATH=. Which ever package is found first will be used. You can check the variable with printenv | grep ROS. If your built workspace does not appear in the ROS_PACKAGE_PATH try sourcing your workspace again and launching it. Sourcing by default with kinetic would be something like source ~/catkin_ws/devel/setup.bash.

edit flag offensive delete link more


I also tried by giving locally_build_package path first and then /opt/ros/crystal/setup.bash path but still env command shows crystal path first and "colcon build" gives priority to installed package. Do you know how can I forcefully tell "colcon build" to use locally build package?

vandanamandlik gravatar image vandanamandlik  ( 2019-01-09 04:17:18 -0600 )edit

Well one thing you could try is to manually set the variable so your built package would appear first. export ROS_PACKAGE_PATH=/path_to/your_ws/your_package:${ROS_PACKAGE_PATH} should work I guess. If this works you can add it to .bashrc although this is deffinately not how to properly solve this.

Reamees gravatar image Reamees  ( 2019-01-09 04:31:40 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-01-08 02:05:18 -0600

Seen: 352 times

Last updated: Sep 10 '19