Ask Your Question
2

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

2 Answers

Sort by ยป oldest newest most voted
5

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.

STEPS:

  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

Explanation:

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

Tnx again to @SAI KISHOR KOTHAKOTA :)

edit flag offensive delete link more

Comments

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 imageneuronet ( 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 imagekosmastsk ( 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 imageaskkvn ( 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 imageMetalzero2 ( 2019-05-08 03:36:55 -0500 )edit

thanks for explanation, got it :)

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 14,313 times

Last updated: Apr 09 '15