54

How can I uninstall Ruby 1.9.2dev (2010-07-02) [i486-linux] on ubuntu? Need to reinstall - please help

purti
  • 61
  • 1
  • 1
  • 5
khanh
  • 4,228
  • 10
  • 27
  • 47
  • Helpful similar question on the ubuntu stackexchange: http://askubuntu.com/questions/95/completely-remove-ruby-rails-gems – Jon Smock Jan 31 '11 at 02:40
  • Using `which -a ruby` I found out my ruby installation could be found in `/usr/bin/ruby` Well that's not exactly the case. I went to `/usr/bin` and listed all the folders/files in the `bin` directory` using `ls -ln`, and found out `/usr/bin/ruby` is just the alias. The actually path to the installation directory has the version appended, for me it was `/usr/bin/ruby1.9.1`. I was successfully able to uninstall ruby using `sudo apt remove ruby1.9.1` – iRector Mar 16 '18 at 00:37

11 Answers11

65

This command should do the trick (provided that you installed it using a dpkg-based packet manager):

aptitude purge ruby
jwueller
  • 28,909
  • 4
  • 60
  • 69
  • thanks for your response. It didn't sloved this problem. I execute this command and check ruby -v. it still show ruby 1.8.7 – khanh Oct 18 '10 at 09:13
  • $ sudo aptitude purge ruby No packages will be installed, upgraded, or removed. 0 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded. Need to get 0B of archives. After unpacking 0B will be used. – khanh Oct 18 '10 at 09:17
  • $ruby -v ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.02 – khanh Oct 18 '10 at 09:18
  • 3
    It seems like aptitude did not find the package `ruby` on your system. Execute `dpkg -l | grep ruby` for a list of installed ruby-related packages. For example `ruby1.8`. – jwueller Oct 18 '10 at 09:18
  • yes. I execute this command. this is result libopenssl-ruby, ruby-enterprise 1.8.7-2010.02, ruby1.8 1.8.6.111-2ubuntu1... – khanh Oct 18 '10 at 09:22
  • 1
    Then simply execute `aptitude purge ruby1.8` to remove that package. – jwueller Oct 18 '10 at 09:24
  • I suggest that you add `sudo ` in your answer for lazy "copiers/pasters" like the person that wrote my comment. – Nabil Kadimi Mar 05 '14 at 20:47
59

Run the following command from your terminal:

sudo apt-get purge ruby

Usually works well for me.

Jai Kumar Rajput
  • 3,214
  • 2
  • 29
  • 49
theamoeba
  • 1,185
  • 12
  • 14
23

At first find out where ruby is? then

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
regmiprem
  • 725
  • 2
  • 13
  • 38
13

I have tried many include sudo apt-get purge ruby , sudo apt-get remove ruby and sudo aptitude purpe ruby, both with and without '*' at the end. But none of them worked, it's may be I've installed more than one version ruby.

Finally, when I triedsudo apt-get purge ruby1.9(with the version), then it works.

shellbye
  • 3,834
  • 2
  • 27
  • 39
8

Here is what sudo apt-get purge ruby* removed relating to GRUB for me:

grub-pc 
grub-gfxpayload-lists
grub2-common
grub-pc-bin 
grub-common 
Baby Groot
  • 4,609
  • 39
  • 50
  • 67
Travis
  • 310
  • 4
  • 15
8

Run the following command on the terminal:

sudo apt-get autoremove ruby
Narendra Jadhav
  • 8,799
  • 15
  • 28
  • 38
DDD
  • 393
  • 1
  • 4
  • 12
4

On Lubuntu, I just tried apt-get purge ruby* and as well as removing ruby, it looks like this command tried to remove various things to do with GRUB, which is a bit worrying for next time I want to reboot my computer. I can't yet say if any damage has really been done.

Alistair
  • 41
  • 1
  • 1
    The same happened to me, but it gives you the clue on what packages yo have to uninstall to remove ruby. So just remove all the packages the apt suggested, except for the obvious ones you don't want to remove, like grub, and you are done. – sh4 Feb 11 '13 at 17:01
3

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

If you installed Rails, it will be removed, too.

Aboozar Rajabi
  • 1,453
  • 17
  • 25
1

Why you are removing old version of the ruby?

rvm install 2.4.2 // version of ruby u need to insatll rvm use 2.4.2 --default // set ruby version you want use by default

Using rvm you can install multiple ruby version in the system

Please follow below steps install ruby using rvm

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 
curl -sSL https://get.rvm.io | bash -s stable 
source ~/.rvm/scripts/rvm
rvm install 2.4.2 
rvm use 2.4.2 --default 
ruby -v

The installation step will change for different Ubuntu version

For more info,

https://gorails.com/setup/ubuntu/14.04

Nataraja B
  • 535
  • 3
  • 15
0

Uninstall the make install software when make uninstall invalid.

  • make install will create file '.installed.list'
  • Choose to clean up the files described in .installed.list (need to be careful if you have multiple versions)
  • Case: ruby2.4 switch to ruby2.3, thinking directly delete all ruby software, and then re-make install 2.3, see: Ruby # Installation Guide
  • make install -> .installed.list
  • see .installed.list file, delete all install files.

rm -rf /usr/local/include/ruby-*
rm -rf /usr/local/lib/ruby
rm /usr/local/bin/erb /usr/local/bin/gem /usr/local/bin/irb /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/ruby
rm /usr/local/share/man/man1/erb.1 /usr/local/share/man/man1/irb.1 /usr/local/share/man/man1/ri.1 /usr/local/share/man/man1/ruby.1
rm /usr/local/lib/libruby-static.a
rm -rf /usr/local/lib/pkgconfig/ruby-*
which ruby
pkg-config --list-all|grep ruby
Stephen Kennedy
  • 16,598
  • 21
  • 82
  • 98
takeseem
  • 121
  • 1
  • 4
0

You can use sudo apt remove ruby

Emjey
  • 1,802
  • 1
  • 12
  • 30