Run the following command from your terminal:

sudo apt-get purge ruby

Usually works well for me.

(caution: this can delete essential system files related to GRUB and other components)

Answer from theamoeba on Stack Overflow
Discussions

How to remove Ruby from Ubuntu - Stack Overflow
I want to remove Ruby, so I try this. How can I remove this? sudo apt-get autoremove ruby Reading package lists... Done Building dependency tree Reading state information... Done Package 'r... More on stackoverflow.com
🌐 stackoverflow.com
How to uninstall ruby on ubuntu 10.10 - rubyonrails-talk - Ruby on Rails Discussions
I decided to learn Ruby on Rails recently, and I am configuring a virtual machine with Ubuntu 10.10. however I am having trouble installing ruby and rails. This is because when running the gem install rails I am informed that the zlib not found. I would uninstall and try to use the ruby by RVM. More on discuss.rubyonrails.org
🌐 discuss.rubyonrails.org
0
September 25, 2010
any way to uninstall ruby using rbenv
Didn't find any way on readme to remove ruby installed with rbenv. More on github.com
🌐 github.com
4
October 13, 2015
How to uninstall / remove Ruby Gems (on Ubuntu)? « Aslam Najeebdeen
Please disregard this post. Its from 2009. Ruby gems are managed by "GEM"... To install gem install [gem_name] To remove gem uninstall [gem_name] Add sudo in front if you're using system ruby. If you're using any type of version manager, don't use sudo. If you ever find you need a specific set of gems for a project and a different one for other project, check out a ruby version manager such as RVM More on reddit.com
🌐 r/ruby
2
0
August 20, 2014
People also ask

Why would I need to uninstall Ruby or Rails?
There could be multiple reasons, such as needing to install a different version, troubleshooting issues, or freeing up system resources.
🌐
webhostinggeeks.com
webhostinggeeks.com › home › ubuntu › how to uninstall ruby and ruby on rails on ubuntu
How to Uninstall Ruby and Ruby on Rails on Ubuntu | Linux Tutorials ...
Can I reinstall Ruby or Rails after uninstallation?
Yes, you can always reinstall Ruby or Rails using your preferred installation method.
🌐
webhostinggeeks.com
webhostinggeeks.com › home › ubuntu › how to uninstall ruby and ruby on rails on ubuntu
How to Uninstall Ruby and Ruby on Rails on Ubuntu | Linux Tutorials ...
Is it necessary to remove both Ruby and Rails?
No, you can choose to remove only one of them. However, Rails is a framework built on Ruby, so if you remove Ruby, Rails will not function.
🌐
webhostinggeeks.com
webhostinggeeks.com › home › ubuntu › how to uninstall ruby and ruby on rails on ubuntu
How to Uninstall Ruby and Ruby on Rails on Ubuntu | Linux Tutorials ...
🌐
GitHub
github.com › postmodern › ruby-install › issues › 135
Uninstalling a ruby version · Issue #135 · postmodern/ruby-install
March 23, 2014 - Well well, it may sound like a simpleton's question but how do i uninstall a ruby version that have been installed with ruby-install? I'm using a ubuntu server on a VM and i just rm -rf the ruby dir inside /home/vagrant/.rubies that i wanted to uninstalled.
Author   jeanmichelcote
Top answer
1 of 3
8

If your package manager installed Ruby to begin with, then something on your system needs it.

The easiest way to find out what needs it is to test an attempt to remove the package. For instance:

# yum remove ruby
...
================================================================================
 Package         Arch      Version                Repository               Size
================================================================================
Removing:
 ruby            x86_64    1.8.7.352-12.el6_4     @updates                1.8 M
Removing for dependencies:
 facter          x86_64    1:1.7.3-1.el6          @puppetlabs-products    235 k
 hiera           noarch    1.2.1-1.el6            @puppetlabs-products     46 k
 puppet          noarch    3.3.0-1.el6            @puppetlabs-products    3.5 M
 ruby-irb        x86_64    1.8.7.352-12.el6_4     @updates                1.0 M
 ruby-rdoc       x86_64    1.8.7.352-12.el6_4     @updates                1.3 M
 ruby-rgen       noarch    0.6.5-1.el6            @puppetlabs-deps        315 k
 rubygem-json    x86_64    1.5.5-1.el6            @puppetlabs-deps        989 k
 rubygems        noarch    1.3.7-1.el6            @base                   711 k

Transaction Summary
================================================================================
Remove        9 Package(s)

Installed size: 9.9 M
Is this ok [y/N]: n
Exiting on user Command

So on my system, I see that it's needed by puppet. Since I actually need puppet, I will not remove ruby.

Similarly on Debian-based systems:

# apt-get remove ruby
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libshadow-ruby1.8 irb1.8 libaugeas0 rdoc libruby ruby1.8 rdoc1.8
  libaugeas-ruby1.8 puppet-common libruby1.8 libopenssl-ruby1.8
  libreadline-ruby1.8 libreadline5 libopenssl-ruby augeas-lenses
  libxmlrpc-ruby
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  facter puppet ruby
0 upgraded, 0 newly installed, 3 to remove and 48 not upgraded.
After this operation, 983kB disk space will be freed.
Do you want to continue [Y/n]? n
Abort.
2 of 3
1

Removing ruby, on its own, isn't going to have much impact on security. If you aren't using it, how is an attacker going to exploit something in it? They would have to have a shell and be able to invoke the ruby interpreter, and if they have a shell there are a billion and one better ways for them to use it than running ruby (for what, to get a shell they already have?).

If you happen to have any SUID executables with ruby as their interpreter, that might give you security trouble (depending), or if ruby is in sudoers and the hypothetical attacker could run it that way (don't let anyone sudo an interpreter unless you are comfortable giving them root; don't ever let service accounts sudo interpreters), that would be a security issue. However, the security hole wouldn't result from ruby being installed, but from misconfiguration of your system in general.

Your approach is wrong. Remove unnecessary services, not unnecessary packages.

🌐
Larrysanger
larrysanger.org › 2019 › 01 › how-to-delete-ruby-and-rails-and-other-gems-from-ubuntu-18-04
How to delete Ruby and Rails (and other gems) from Ubuntu 18.04 – LarrySanger.org
January 23, 2019 - # HOW TO DELETE RUBY AND RAILS (AND OTHER GEMS) apt-get purge ruby2.5 aptitude purge ruby rm -rf /usr/local/lib/ruby rm -rf /usr/lib/ruby rm -f /usr/local/bin/ruby rm -f /usr/bin/ruby rm -f /usr/local/bin/irb rm -f /usr/bin/irb rm -f /usr/local/bin/gem rm -f /usr/bin/gem rm -rf /home/globe...
Find elsewhere
🌐
Ruby on Rails
discuss.rubyonrails.org › rubyonrails-talk
How to uninstall ruby on ubuntu 10.10 - rubyonrails-talk - Ruby on Rails Discussions
September 25, 2010 - I decided to learn Ruby on Rails recently, and I am configuring a virtual machine with Ubuntu 10.10. however I am having trouble installing ruby and rails. This is because when running the gem install rails I am informed that the zlib not found. I would uninstall and try to use the ruby by RVM.
🌐
GitHub
github.com › rbenv › rbenv › issues › 797
any way to uninstall ruby using rbenv · Issue #797 · rbenv/rbenv
October 13, 2015 - Didn't find any way on readme to remove ruby installed with rbenv.
Author   pulkitnandan
🌐
Reddit
reddit.com › r/ruby › how to uninstall / remove ruby gems (on ubuntu)? « aslam najeebdeen
r/ruby on Reddit: How to uninstall / remove Ruby Gems (on Ubuntu)? « Aslam Najeebdeen
August 20, 2014 - Ruby gems are managed by "GEM"... To install gem install [gem_name] To remove gem uninstall [gem_name] Add sudo in front if you're using system ruby. If you're using any type of version manager, don't use sudo.
🌐
Shorttutorials
shorttutorials.com › apt-get-commands › remove-ruby.html
apt-get remove ruby | How to Uninstall ruby in Linux with ...
Here is the tutorial to learn how to uninstall ruby with apt-get command. Step 1: Open a terminal with 'su' access and enter the command as shown below. apt-get remove ruby -y Step 2: The command reads the package lists and proceeds with the uninstallation.
🌐
Reddit
reddit.com › r/ruby › why uninstall ruby?
r/ruby on Reddit: Why Uninstall Ruby?
June 5, 2021 -

I recently wrote Uninstall Ruby for my guide Install Ruby on Mac. I added it just for completeness not expecting much traffic but now it is getting a lot of visits. Like, really a lot.

Why would a developer need to remove Ruby? Any insights? I'd like to better understand why people are visiting the page.

🌐
Steptoinstall
steptoinstall.com › uninstall-ruby-ruby-gems-ubuntu.html
Steptoinstall
January 29, 2015 - We are giving simple steps to Install Software and all. We are providing related Links and Images too.
🌐
Revo Uninstaller
revouninstaller.com › home › logs preview – en
Uninstall Ruby with Revo Uninstaller
September 29, 2025 - Note: If you see Ruby listed in the "All programs" tab, another approach is to start the uninstall from there and if Revo Uninstaller Pro detects an appropriate log from its database it will be automatically used for the uninstall.
🌐
Ruby on Rails
discuss.rubyonrails.org › rubyonrails-talk
How to remove RUBY, GEM, RVM completely in ubuntu? - rubyonrails-talk - Ruby on Rails Discussions
July 8, 2011 - Hi, guys , i installed several version of the ruyb, gem, i want to remove all of them, and install just one version, how to do that ? many thanks, welcome any advises.
🌐
candokendo
candokendo.wordpress.com › 2020 › 08 › 25 › install-and-uninstall-ruby-sass-with-ubuntu-18-04-lts
Install and Uninstall ruby-sass with Ubuntu 18.04 LTS – candokendo
August 25, 2020 - $ sudo apt-get remove ruby-sass $ sudo apt-get remove --auto-remove ruby-sass $ sudo apt-get purge ruby-sass $ sudo apt-get purge --auto-remove ruby-sass We use purge options to be removed ruby-sass package all the configuration and dependent ...
🌐
Vultr
docs.vultr.com › how-to-install-ruby-on-ubuntu-24-04
How to Install Ruby on Ubuntu 24.04 - Complete Guide | Vultr Docs
January 31, 2025 - Uninstall Ruby using APT. ... You have installed Ruby on Ubuntu 24.04 using rbenv and RVM. You can use rbenv and RVM to install multiple Ruby versions to run different projects on your server.