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

Revision history [back]

Yes, you need to source setup.bash every time you start a new shell and want to use ROS commands.

The "source" command runs the setup.bash script and copies any environment variables that setup.bash sets in its own environment into the environment of the shell where you ran the source command.

If you want to see what setup.bash is actually setting, do the following:

$ export COLCON_TRACE=1

Then when you do: "source setup.bash" it will display what it's actually doing, as it does it.

As mentioned in the other answer, it's easy to just add the source command to the end of your .bashrc file, which is run every time you start a new shell. More on that below.

By the way, source is also aliased to ".", so you can do this and it will have the same effect:

$ . setup.bash

The .bashrc file is located in your home directory. In Unix-derived systems like Linux and Ubuntu, your home directory is usually at the path /home/username, so you'll find .bashrc here:

$ ls -l /home/yourusername/.bashrc

The tilde character (~) is a standard abbreviation or alias for your home directory, so you can just write:

$ ls ~/.bashrc

Note that files prefixed with a period do not normally show up with the "ls" command, you have to either use the filename with ls or use "ls -a"