Rosanswers logo

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?

Originally posted by Metalzero2 on ROS Answers with karma: 293 on 2015-04-08

Post score: 6


2 Answers 2


Rosanswers logo

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

Originally posted by saikishor with karma: 228 on 2015-04-08

This answer was NOT ACCEPTED on the original site

Post score: 13


Rosanswers logo

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).


Originally posted by Metalzero2 with karma: 293 on 2015-04-09

This answer was ACCEPTED on the original site

Post score: 11

Original comments

Comment by neuronet on 2016-07-25:
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).

Comment by kosmastsk on 2018-12-13:
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

Comment by askkvn on 2019-05-08:
But question still remains open, Why do we need to source, what is the need of that file?

Comment by Metalzero2 on 2019-05-08:
@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. :)

Comment by askkvn on 2019-05-09:
thanks for explanation, got it :)


Your Answer

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