0
$\begingroup$

Rosanswers logo

I've been trying to understand what the setup.sh file does and how it changes my shell environment such that catkin builds correctly.

Simply to describe my motivation for understanding, there are times when I get into a dirty build state (genjava and rosjava freaking out about something), and I have to blow away build, devel directories, and maven repos and build from scratch. However if I naively call catkin_make, rosjava and genjava start breaking all over the place because I no longer have a setup.bash file to source other than the ros/indigo/setup.bash. So I end up in this weird place where my first build command has to be ROS_PACKAGE_PATH=/path/to/src:$ROS_PACKAGE_PATH catkin_make. Then I can source the proper setup.bash file, call catkin_make, and everything builds fine again.

I'd like to understand more about the env hooks because my hope is I can just prefix catkin_make with all the env variables to get an arbitrary set of troubled packages (i.e. rosjava and genjava) happy and have a single command to solve my problems.


Originally posted by blakejwc on ROS Answers with karma: 33 on 2017-02-03

Post score: 3


Original comments

Comment by William on 2017-02-03:
Have you seen https://catkin-tools.readthedocs.io/en/latest/mechanics.html#environment-setup-files? It does describe what an environment hook is, but it doesn't go into the technical mechanism which makes them work.

Comment by blakejwc on 2017-02-06:
I could only find mention of "env hooks" in the Quickstart and Workspace Mechanisms sections. They don't really describe what an "env hooks" are, just their existence and somehow helping define packages in a workspace.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Environment hooks are shell scripts provided by a ROS package. Whenever you source the setup file in a workspace those environment hooks are also being sourced. They are being used to set / extend environment variables. E.g. the ros package has an environment hook which set the environment variable ROSDISTRO_NAME (see https://github.com/ros/ros/blob/bf3e45955e5c8aac2ab276d6b956b21bc13ddccc/core/roslib/env-hooks/10.ros.sh.em#L16) and ROS_PACKAGE_PATH (see https://github.com/ros/ros/blob/bf3e45955e5c8aac2ab276d6b956b21bc13ddccc/core/roslib/env-hooks/10.ros.sh.em#L41).


Originally posted by Dirk Thomas with karma: 16276 on 2017-02-06

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by blakejwc on 2017-02-07:
What is the @(), @{}@, and @[if/else]@ syntax?

Comment by Dirk Thomas on 2017-02-07:
Files ending in .em are using the EmPy template engine, see http://www.alcyone.com/pyos/empy/

Comment by blakejwc on 2017-02-07:
oh wow! This is intense, and it explains a lot of what I am seeing. Thank you!

Comment by bluenote on 2019-01-16:
Is there an overview of what variables are defined by Catkin within EmPy templating? EDIT: I created a follow up question for that.

Comment by Dirk Thomas on 2019-01-16:
Existing question: https://answers.ros.org/question/312942/catkin-empy-variables/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.