Ask Your Question

ROSCD goes to wrong workspace - ROS Melodic

asked 2020-11-28 15:07:25 -0500

liamr0y gravatar image

updated 2020-11-30 02:33:00 -0500

gvdhoorn gravatar image

At present, I have two ROS workspaces on my Ubuntu 18.04 system.

One is the root, located at: /opt/ros/melodic

The other is the workspace I actually use for my projects, located at: ~/catkinws_melodic

Whenever I use roscd, it brings me to the first workspace (/opt/ros/melodic), and I can only get to the second workspace ~/catkinws_melodic if I specify a package along with roscd (ex. roscd tbot brings me to ~/catkinws_melodic/src/tbot)

Is there a way to make roscd by itself bring me to the workspace I use regularly, rather than the one located in the /opt directory?

In my .bashrc I have these two lines:

source /opt/ros/melodic/setup.bash
source /home/parallels/catkinws_melodic/devel/setup.bash

Also, here are my present environment variables:


Thanks for the help!!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-11-30 02:28:34 -0500

mgruhler gravatar image

updated 2020-11-30 04:23:38 -0500

The issue is with your ROS_PACKAGE_PATH. roscd brings you to the first workspace on the path. So they should be the other way around on you package path.

I highly discourage from manually fiddling with the ROS_PACKAGE_PATH variable (if you've done that or plan on doing that). Also note that you don't need to have multiple source statements for workspaces in your .bashrc. With catkin, the last setting wins.

I suggest you

  1. clean your workspace (i.e. remove build, devel and logs folder, if they exist; if you've built with catkin-tools, you can use the catkin clean command)
  2. clean the bashrc (i.e. remove all source commands that source a ROS workspace)
  3. start a new terminal (without any ROS environment sourced)
  4. manually source /opt/ros/melodic/setup.bash
  5. build your workspace again and source the workspaces setup.bash

I'm assuming the package path is then in the correct order and your roscd should work the way you want. If you want your workspace to be automatically sourced, put only the source command of your workspace into the bashrc.

edit flag offensive delete link more


I suggest you clean your workspace, clean the bashrc [..]

These are the steps I would also take, but please add a little bit more detail: what does "clean your workspace" mean exactly? Same for .bashrc.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-30 02:31:44 -0500 )edit

agreed and done.

mgruhler gravatar image mgruhler  ( 2020-11-30 04:23:53 -0500 )edit

Your Answer

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

Add Answer

Question Tools



Asked: 2020-11-28 15:07:25 -0500

Seen: 182 times

Last updated: Nov 30 '20