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

Do I really need to $ source ~/catkin_ws/devel/setup.bash ?

asked 2016-03-17 11:48:19 -0500

thepirate16 gravatar image

Novice question:

I've created a custom message, package, etc as the official tutorial does. But when i do:

$ rosrun pkg_test1 pkg_test1_node

it gives me: [rospack] Error: package 'pkg_test1' not found

Indeed, if i do: $ source ~/catkin_ws/devel/setup.bash the problem is fixed. But do i really need to do that every time i want to use my custom programs? Is there any simple way to mantain them in the ROS path (i think that is what i am doing when i call these commands).

Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-17 12:00:05 -0500

Yes, you really do need to source a setup.bash file in every single terminal that you want to use ROS in. These scripts control many important ROS environment variables and non-ROS environment variables (PYTHONPATH, CMAKE_PREFIX_PATH, etc.). The setup.bash scripts provide a convenient way to control which version of ROS is "active" and which workspaces are "active" (see page on overlaying workspaces).

If you want every terminal to automatically "source" a particular setup.bash script, you could put that command in your ~/.bashrc. See the Environment Setup section of the ROS installation instructions.

edit flag offensive delete link more


Ok! Now i understand it! Thanks for the reply!

thepirate16 gravatar image thepirate16  ( 2016-03-17 13:50:53 -0500 )edit

Shouldn't source /opt/ros/kinetic/setup.bash be enough? Do I really need to do source ~/catkin_ws/devel/setup.bash every single time that I want to use my custom packages?

cartucho gravatar image cartucho  ( 2020-03-25 01:57:40 -0500 )edit

@cartucho: no, it cannot be enough.

/opt/ros/kinetic/setup.bash only "knows about" the packages installed under /opt/ros/kinetic. It contains no references to your own, custom packages in your catkin_ws. So if you source /opt/ros/kinetic/setup.bash, you only get access to the packages installed there.

What you don't need to do is sourceboth the setup.bash in /opt/ros/kineticand your catkin_ws. Just sourceing your catkin_ws should be sufficient to get you access to both sets of packages (provided you have setup your own workspace correctly).

gvdhoorn gravatar image gvdhoorn  ( 2020-03-25 05:14:48 -0500 )edit

thank you @gvdhoorn it worked!

cartucho gravatar image cartucho  ( 2020-03-25 08:52:45 -0500 )edit

answered 2019-11-23 17:40:35 -0500

aknuclear gravatar image

. ~/catkin_ws/devel/setup.bash Replace the "catkin_ws" with your workspace name and run the command in your terminal window (as mentioned in this link text gazebo tutorial documentation).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-17 11:48:19 -0500

Seen: 9,194 times

Last updated: Mar 17 '16