How to Completely Uninstall ROS 2

uninstall-ros2

In this tutorial, I will show you how to completely uninstall ROS 2 from your system.

Uninstall ROS 2

If you want to uninstall the current version of ROS 2 that you have on your computer, type the following commands in the terminal window:

sudo apt remove ~nros-${ROS_DISTRO}-* && sudo apt autoremove

Otherwise, if you want to completely uninstall ROS 2 from your system, type this command:

sudo apt remove ros-* && sudo apt autoremove

Remove ROS 2 References in the .bashrc

Remove all ROS 2-related lines from your ~/.bashrc file.

gedit ~/.bashrc

For example, you can remove:

source ~/ros2_ws/install/setup.bash

Save the file.

Delete the Workspace

Now delete your ROS 2 workspace. For example, if your workspace is named ros2_ws, type:

rm -rf ~/ros2_ws

Remove the Repository

Finally Remove the repository:

sudo apt-get update
sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt-get update
sudo apt autoremove
sudo apt-get upgrade

Reboot Your Machine

sudo reboot

That is it! Now you are back to a fresh system with no ROS 2 installed.

Keep building!