Rosanswers logo

Hi, I've read that $ source devel/setup.bash is the same as $ .devel/setup.bash and that it reads and executes setup.bash script in the current shell. Opposite to this $ ./devel/setup.bash what would run the same script but launching new shell.

So we want to run $ source command everytime we open new terminal.

Following questions are:

  1. Its not clear to me what actually am I doing with the source command. Where can I find this bash file that contains these enviroment variables, so I can track what's going on?
  2. Can I permanently add required enviromental variables so I don't have to do it manually every time I open a terminal? What are pros and cons of doing such.
  3. I followed tutorial. Entered this:

$ source devel/setup.bash


Which gave me:


Then I entered this:

$ source /opt/ros/indigo/setup.bash


Which gave me:


Why such sequence erased my ~/home... path from bash??

Originally posted by Tomaszz on ROS Answers with karma: 33 on 2014-07-30

Post score: 3


1 Answer 1


Rosanswers logo

When you "source" something in bash, it will execute each line of the file as is it were typed into the current shell. This is contrasted to actually executing the script, which will be run in a new shell.

The setup.bash file is merely adding environment variables to your path to allow ROS to function.

You can add the source setup.bash command to your ~/.bashrc file, so that it will be executed every time that you open a new shell.

Your third sequence shows you first using a local workspace, which is overlaying the system indigo installation. When you source the /opt/ros/indigo/setup.bash file, you are no longer using the local workspace, but rather only the system installation, which is why the local workspace variables are no longer available.

You should always source your local workspace setup last.

Originally posted by mjcarroll with karma: 6414 on 2014-07-30

This answer was ACCEPTED on the original site

Post score: 12

Original comments

Comment by BennyRe on 2014-07-30:
Well explained. I started to answer to early.

Comment by bonzi on 2017-03-17:
how do i remove /opt/ros/indigo/stacks


Your Answer

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