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 OverflowRun 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)
This command should do the trick (provided that you installed it using a dpkg-based packet manager):
aptitude purge ruby
If you're using Ubuntu Packages run sudo apt-get purge <packages>
So that should be something like:
sudo apt-get purge ruby rubygems
From the apt-get man page:
purge purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).
If you are using RVM why bother even uninstalling the system ruby?
I install both 1.8.7 and 1.9.2-rc via RVM.
After you have installed RVM you can set the RVM 1.8.7 to be your default ruby installation. Just don't install RVM as root.
For those wondering, https://rvm.io/ has the RVM install instructions.
Make sure you read the instructions on what packages you need to install for Ubuntu before installing 1.8.7 via RVM. If you don't install them you may have issues with some gems.
How to remove Ruby from Ubuntu - Stack Overflow
How to uninstall ruby on ubuntu 10.10 - rubyonrails-talk - Ruby on Rails Discussions
any way to uninstall ruby using rbenv
How to uninstall / remove Ruby Gems (on Ubuntu)? « Aslam Najeebdeen
Why would I need to uninstall Ruby or Rails?
Can I reinstall Ruby or Rails after uninstallation?
Is it necessary to remove both Ruby and Rails?
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.
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.
The package name is ruby1.9.1 but the software version is 1.9.3, so remove it running:
sudo apt-get remove ruby1.9.1 libruby1.9.1
Are you sure when you run ruby you are running system ruby and not rvm or rbenv ruby?
$ which ruby
/home/jrwren/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
/usr/bin/ruby uses alternatives - you can read more with man update-alternatives
$ ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 22 Oct 11 2011 /usr/bin/ruby -> /etc/alternatives/ruby
$ ls -l /etc/alternatives/ruby
lrwxrwxrwx 1 root root 18 Oct 12 16:57 /etc/alternatives/ruby -> /usr/bin/ruby1.9.1
So ultimately ruby is a symlink to /usr/bin/ruby1.9.1 You can ask dpkg to which package this file belongs with -S
$ dpkg -S /usr/bin/ruby1.9.1
ruby1.9.1: /usr/bin/ruby1.9.1
And remove that package
$ sudo apt-get remove ruby1.9.1
At this point the alternatives system will kick in and symlink /usr/bin/ruby to another ruby version on your system if you have it. Mine found a ruby 1.8. Repeat the process if you with to remove that version.
Ubuntu...?
Use this to find out what executable you're running:
$ which ruby
/usr/bin/ruby
Use this to find out what it actually is:
$ readlink -f /usr/bin/ruby
/usr/bin/ruby1.8
Use this to find out what package it belongs to:
$ dpkg -S /usr/bin/ruby1.8
ruby1.8: /usr/bin/ruby1.8
Use this to uninstall that:
$ apt-get purge ruby1.8
Note: If you have installed Ruby using Version/Environment managers like RVM or Rbenv then this method is not gonna work because Rubies will be installed as scripts not packages.
If you used rbenv to install it, you can use
rbenv versions
to see which versions you have installed.
Then, use the uninstall command:
rbenv uninstall [-f|--force] <version>
for example:
rbenv uninstall 2.4.0 # Uninstall Ruby 2.4.0
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.