Ask Your Question

How often do I need to source "setup.bash" ??

asked 2015-04-08 09:35:34 -0500

Metalzero2 gravatar image

Hello all,

I know this is really noob question but here it goes.

I saw (while studying the tutorials) that I need to source the devel/setup.bash at every new shell. I would like to ask, what exactly does that mean? I need to source the setup.bash file with every new terminal? If not, then how oftern?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2015-04-09 17:00:37 -0500

Metalzero2 gravatar image

updated 2015-04-09 17:01:16 -0500

Yes, with every new shell/terminal that is opened, I need to source my file. (terminal = shell ... in some way).

So how can this become automatically? The answer that @SAI KISHOR KOTHAKOTA was correct. But because I am a noob, it took me some time and research to find out what exactly he meant and what I needed to do. So I will write down here, in a step-by-step way, how I did it and then some explanation.


  1. Open your terminal
  2. Write the command --> gedit ~/.bashrc
  3. I file will open on gedit
  4. Go to the bottom (my last line was "source /opt/ros/indigo/setup.bash" , for others it may differ)
  5. Go under that line and write --> source [YOUR PATH]/catkin_ws/devel/setup.bash
  6. Save and exit
  7. Now with every new shell you open, it will source automatically


So, from what I know, the .bashrc file runs automatically for every new shell you open. So now, every time you open a shell, all of those command run plus the new command you added (the source command).


edit flag offensive delete link more


Thanks for this helpful explanation. It wasn't explained clearly in my Gentle Introduction to ROS book, which just says you need to source setup.bash once in each terminal (which frankly isn't all that clear: you don't need to do it in your roscore terminal, for instance).

neuronet gravatar image neuronet  ( 2016-07-25 19:05:13 -0500 )edit

Apart from this, in order to source more workspaces in the same .bashrc file do not forget to add the --extend flag in the end. E.g. [ANOTHER PATH]/catkin_ws/devel/setup.bash --extend

kosmastsk gravatar image kosmastsk  ( 2018-12-13 07:22:04 -0500 )edit

But question still remains open, Why do we need to source, what is the need of that file?

askkvn gravatar image askkvn  ( 2019-05-08 00:03:31 -0500 )edit

@askkvn I found out that this is a question related to how Linux works then ROS. When ever you open a new shell (that is a new terminal window) it will look only is some specific parts of your whole file system for commands. In other words, if you write the command "cd" it will look in some pre-defined locations to find if that is an actual command. Now, if you want to add new commands to your shell you need to tell it where to find them. This is basically what the file devel/setup.bash. So, when you source this, the file will tell the shell where to find all the ROS executable (including the programs that you have compiled). That is basically the need for it, at least to my understanding. Hope it helps. :)

Metalzero2 gravatar image Metalzero2  ( 2019-05-08 03:36:55 -0500 )edit

thanks for explanation, got it :)

askkvn gravatar image askkvn  ( 2019-05-09 09:22:12 -0500 )edit

answered 2015-04-08 09:39:25 -0500

saikishor gravatar image

updated 2015-04-08 09:40:10 -0500

hmm everytime when you want to use the catkin workspace and the best option is to place it in .bashrc

just open .bashrc and in the bottom you will find

source /opt/ros/indigo/setup.bash

below that just place the below line then that's it no need to do anymore:

source ~/catkin_ws/devel/setup.bash

edit flag offensive delete link more

answered 2022-05-23 03:59:48 -0500

baselink gravatar image

Every time when you establish a new workspace, you need to source the setup.bash as the followings:

  1. echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
  2. source ~/.bashrc

note that the above mentioned "catkin_ws" should be changed to the new workspace name each time.

edit flag offensive delete link more

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: 2015-04-08 09:35:34 -0500

Seen: 38,614 times

Last updated: May 23