How to Uninstall ROS2 Completely

In this short tutorial I will show you all the steps to do in order to completely uninstall ROS2 from Ubuntu. I will assume that you have installed ROS2 using apt (binary install).

>> Watch this video as an additional resource to this article:

After watching the video, subscribe to the Robotics Back-End Youtube channel so you don’t miss the next tutorials!

Find which ROS2 distribution you want to uninstall

First, you might want to check what ROS/ROS2 distributions you have installed.

Go in /opt/ros and you’ll see the list of distributions. You can then repeat the following steps for each distribution you want to completely remove.

You want to learn ROS2 efficiently?

Check out ROS2 For Beginners and learn ROS2 step by step, in 1 week.

Remove ROS2 packages

First we will remove all installed packages with apt.

$ sudo apt remove ros-*

For a specific distribution, use “ros-distribution-*” instead.

Once you’ve done that, you might also want to run an autoremove.

$ sudo apt autoremove

Finally, go in the /opt directory and check that the ROS2 distribution you wanted to remove is not here anymore. If you still have some stuff there, just remove with the rm command (using sudo).

Clean the environment

When you install ROS2, and when you setup a ROS2 workspace, you usually add some extra lines in your .bashrc file, in order to source the environment correctly for ROS2 anytime you open a new session.

As you just removed ROS2 packages, you need to clean that. Go to your .bashrc file and remove any line that has a reference to the global ROS2 installation, a ROS2 workspace, etc.

One extra thing you might want to do (optional): you could remove the ROS2 workspaces that you’ve created. Note that before doing this, it’s recommended to back them up, for example online with git. But you could also leave the workspaces on your computer, if you don’t mind the extra used space. As they are not sourced from the .bashrc anymore, they won’t be a problem.

Another extra thing: if you have used an IDE such as VS Code and have installed some ROS extensions, you might also want to remove them from the IDE.

Remove the ROS2 sources

Finally, if you want to remove all ROS2 traces from your computer, you also need to remove the ROS2 sources. When you installed ROS2, you ran some commands that added a new source repository for apt.

You can check that by running a simple sudo apt update. You’ll see a line that contains something like “”.

To remove this, just delete the ros2.list file that was added during the installation.

$ cd /etc/apt/sources.list.d/
$ sudo rm ros2.list

Now you can do sudo apt update again and you should not see the ROS2 source anymore.

Lastly, I would suggest to re-run an autoremove, and finally, reboot your computer.

sudo apt autoremove
sudo reboot

And that’s it! ROS2 should now be completely uninstalled.

Want to learn how to program with ROS2?

Don't miss this opportunity:

ROS2 For Beginners - Step by Step Course

[NEW] ROS 2 Book

Or, learn with a video course