Rospack can't find catkin built package with install flag

asked 2022-06-16 08:20:57 -0600

Firrel gravatar image

Trying to install a custom package into the workspace's install folder so that another package can find it. However I encountered a problem where after setting catkin config install flag, rospack can no longer find any of the packages built in that workspace. Could not find any info about this issue, am I doing something wrong?

Using newest version of ROS Melodic on Ubuntu 18.04 desktop PC with kernel 5.4.0-117-generic.

Starting from clean catkin workspace without setting install flag, everything works as intended: (using publicly accessible package for showing the issue)

  1. mkdir -p catkin_test/src
  2. cd catkin_test
  3. catkin init
  4. cd src && git clone
  5. catkin build
  6. source ../devel/setup.bash
  7. rospack find octomap_msgs -> success

The same steps taken, but install flag is set. The rospack can no longer find the package:

  1. 1-4 as above
  2. catkin config --install
  3. catkin build
  4. source ../devel/setup.bash
  5. rospack find octomap_msgs -> [rospack] Error: package 'nodelet_sample' not found
edit retag flag offensive close merge delete


abhishek47 gravatar image abhishek47  ( 2022-06-16 11:18:13 -0600 )edit

Thanks, it clarified some misunderstandings. I did not find a nice way of exporting header files in devel space, so this is what I ended up with for anyone interested:

# Create dummy custom target that will be always rebuilt
add_custom_target(dummy_target ALL DEPENDS dummy_output)

# Depend on dummy_target to always run this custom command
        OUTPUT dummy_output
        COMMAND ${CMAKE_COMMAND} -E copy
        DEPENDS dummy_target)
Firrel gravatar image Firrel  ( 2022-06-17 05:33:44 -0600 )edit

AFAIK, if you have an install space, you must source /path/to/install/setup.bash, not/path/to/devel/setup.bash.

Unless you're auto-generating code, or do some other weird things, you should not need any tricks when switching to an install space.

You just need to make sure to source the correct setup.bash.

gvdhoorn gravatar image gvdhoorn  ( 2022-06-18 04:07:13 -0600 )edit