How to reset catkin_ws (ROS catkin workspace) and start afresh

Upfront PS: This only applies to ROS1.

Sometimes your ROS workspace is messed up and no longer working as expected. Maybe because of over-tinkering or you just can’t find what’s wrong or whatever. You just want to reset and restore the workspace to “factory settings”.

Here’s how to do it. Let’s assume the following (if not, just adjust accordingly):

  • You named your workspace catkin_ws.
  • You created the workspace at /home/user/catkin_ws.

Then:

  1. IMPORTANT DISCLAIMER: backup any files or folders you don’t want to lose, as all files or folders will be cleaned out.
  2. Run the following commands from a terminal:
rm -rf /home/user/catkin_ws/src/
rm -rf /home/user/catkin_ws/build/
rm -rf /home/user/catkin_ws/devel/
mkdir -p /home/user/catkin_ws/src/
cd /home/user/catkin_ws/
catkin_make

And that’s it! Don’t forget to substitute /home/user/catkin_ws/ with the actual path to your workspace, if different.

Questions and comments are welcome.

Cheers.

i have accidentally clear my work space with the codes above without backing up my files, is there a way to retrieve my older files?

Hi @ROS4cube,

Are you talking about your local workspace or the one on Robot Ignite Academy? If the latter, we might be able to do something - please let me know which.

BR,