Juanito Fatas
Juanito Fatas

Reputation: 9949

How to uninstall ruby installed by ruby-install

I have many rubies installed by ruby-install under ~/.rubies:

ls .rubies
ruby-1.9.3-p545 ruby-2.0.0-p598 ruby-2.1.3      ruby-2.1.5
ruby-2.0.0-p451 ruby-2.1.2      ruby-2.1.4      ruby-2.2.0

I want to uninstall one of the ruby installed by ruby-install, How do I do that?

Upvotes: 32

Views: 118614

Answers (7)

Emmanuel Dafiewhare
Emmanuel Dafiewhare

Reputation: 1

Removes all associated ruby packages

sudo apt remove ruby

Upvotes: -1

Rael Gugelmin Cunha
Rael Gugelmin Cunha

Reputation: 3532

Unfortunately appears that ruby-install just downloads and compiles Ruby, with no option to remove it, unlike RVM or rbenv.

So, probably you'll need to run some manual commands here to delete all installed files.

1. Locate it

Usually ruby-install will install rubies in ~/.rubies/ folder.

If you're not sure which ruby was installed using ruby-install, locate the file .installed.list, as it has a list of installed files during Ruby install. If you want to quickly locate it, just run locate .installed.list and you'll get a short list of them.

Then run a cat on the file located at the version you want to remove, to make sure which is the root folder for the ruby install you want to delete.

2. Remove it

Then you can just remove the folder where the target version is located.

If you want to remove ruby-1.9.3-p545, run:

rm -Rf ~/.rubies/ruby-1.9.3-p545

3. Installed gems

If you want to remove installed gems, usually they're located at ~/.gem/ruby/.

Upvotes: 27

ILMostro_7
ILMostro_7

Reputation: 1482

Based on the responses in a feature request, the best way to remove older ruby versions is to go back to the src directory and run make uninstall or rake uninstall. By default, ruby-install uses $HOME/src/ruby-$version for unpacked sources of ruby versions during installation.

For example, removing ruby version 2.6.3:

cd $HOME/src/ruby-2.6.3/ && make uninstall

Unfortunately, even though this bug/request was opened in 2016, this feature is still not implemented in ruby-install.

If you've installed the ruby version using the default locations, then you should be safe by removing the specific subfolder within $HOME/.rubies/.

rm -rf $HOME/.rubies/ruby-2.6.3

It's worth noting that it may be necessary to manually remove any gems installed with that ruby version.

e.g.

rm -rf $HOME/.gem/ruby/ruby-2.6.3

Upvotes: 5

eric323
eric323

Reputation: 19

If you installed package 2.3x(+) and you need to uninstall it, there is an uninstall executable inside of the root directory. Go to C:/ and you'll see the ruby folder there, inside it there will be the unin.exe. This all depends on where you chose to install it.

Upvotes: 2

emelieh21
emelieh21

Reputation: 21

I had exactly the same problem with my lubuntu virtual machine! I went into the shell from the login screen (by pressing CNTR + ALT + F3) and checked the versions of ruby and gem:

ruby -v
gem -v

then I run sudo apt-get purge -y ruby as suggested by chad. It successfully removed both ruby and gem.

Then I rebooted with:

reboot

And I was able to log in normally again!

Upvotes: 2

Juanito Fatas
Juanito Fatas

Reputation: 9949

You just remove where the ruby is.

For example, uninstall ruby that installed by ruby-install (default installation location is ~/.rubies):

rm ~/.rubies/ruby-2.2.0

If you see this kind of error after removed Ruby 2.2.0-preview2 and installed Ruby 2.2.0-p0 for example:

$ bundle -v
zsh: /Users/Juan/.gem/ruby/2.2.0/bin/bundle: bad interpreter:
     /Users/Juan/.rubies/ruby-2.2.0-preview2/bin/ruby: no such file or directory

You need to run

gem pristin --only-executables

Because whenever a ruby is updated or perhaps moved/named, due to RubyGems is generating explicit #!/path/to/ruby for all gem executables, will need to regenerate the gem bin stubs with the new path to the ruby executable.

Upvotes: 2

chad
chad

Reputation: 61

if you install soft by dpkg or yum, when to uninstall it, you also should use dpkg or yum to purge it.

for example, we want to unintall fcitx,

sudo apt-get purge -y fcitx

otherwise, the soft install manually, use configuration && make && make install , just remove the directory installed when you uninstall it.

for you example. just

rm -rf ~/.rubies/ruby-2.2.0

if you have doubts that is the target ruby remove clearly, just use find command to confirm.

find ~/ -name "ruby-2.2.0"

Upvotes: 1

Related Questions