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

[SOLVED] Problem sourcing my workspace setup.bash via SSH

asked 2017-02-22 17:02:05 -0600

updated 2017-03-15 09:14:06 -0600

Dear ROS community,

I have a problem working with ROS via SSH: I'm using ROS Indigo and Ubuntu 14.04.

Initially I found that launching some ROS commands (like rosrun) via SSH results in command not found. After a quick search on this site I found that the

source /opt/ros/indigo/setup.bash

must be moved at the beginning of my .bashrc fine instead, as I did, at the end. After this change commands become available again.

Now I have the same problem when sourcing setup.bash of my development workspace: also moving it at beginning of .bashrc file some ROS command results in unknown command.

Any helps will be appreciated!


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-03-15 09:13:34 -0600

Finally I solved!

My SSH was not using bash as shell.

For other users this can be simply verified starting SSH and typing

echo $0

the result should be


if bash is used. If you are using another shell type you change it editing /etc/passwd following this sample john:x:1000:1000:john,,,:/home/john:/bin/bash (john is a fake user, you should have your username here ;-) ). The /bin/bash specify the shell type.

In my case a rebuild of the workspace (clean and make) was needed too to make it working...

edit flag offensive delete link more


I may be misunderstanding you, bu isn't that exactly what I wrote in my answer?

[..] .bashrc is not loaded (as bash is not started)

btw, the env-loader script is meant to make editing /etc/passwd unnecessary, and is probably a bit more maintainable.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-15 13:49:44 -0600 )edit

If you feel you have answered your own question, please just accept your own answer by ticking the checkmark to the left of it. Closing questions is something we rarely do here on ROS Answers.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-15 13:50:57 -0600 )edit

Dear gvchoorn,

you are right: the cause of my problem was that bash was not started. Anyway your solution is perfect for starting nodes but fixing the shell type in /etc/passwd allow me to run also other ROS command (like rostopic etc...) in terminal and this is useful for me in debugging phase.

afranceson gravatar image afranceson  ( 2017-03-16 03:57:30 -0600 )edit

answered 2017-02-23 00:40:45 -0600

gvdhoorn gravatar image

updated 2017-02-23 00:42:22 -0600

I think the main point here is that if SSH is asked to remotely run a command, .bashrc is not loaded (as bash is not started). So any source lines in there are not executed -> no ROS.

To work around this, the machine tag supports the env-loader attribute, which points to a file (typically a sh or bash script) that gets executed instead of the actual rosrun or roslaunch commands.

The env-loader is supposed to source your workspace (and potentially do some other things) and then pass control over to whatever roslaunch wanted to remotely execute in the first place.

tl;dr: leave your source /opt/ros/.. in the normal place in your .bashrc, and make sure to use an env-loader script whenever you want to run something remotely over SSH.

See #q255223 for a related question (which includes an example of an env-loader script).

edit flag offensive delete link more

Question Tools



Asked: 2017-02-22 17:02:05 -0600

Seen: 1,648 times

Last updated: Mar 15 '17