How to uninstall ruby installed by ruby-install
Asked Answered
P

8

32

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?

Poock answered 27/12, 2014 at 7:43 Comment(4)
Are you using Linux? If yes, which distro? Are you using rvm, rbenv or any other ruby version manager?Phenosafranine
Does it matter which OS? I use OS X and I don't use any tools except ruby-install and chruby.Poock
Yes, it matters a lot. While on Linux you can completely remove Ruby, Apple includes Ruby starting at Snow Leopard and has code calling it from apps. I've upvoted your question if the OS matters, because it's frequent and really important :)Phenosafranine
I did not want to completely remove Ruby, just want to remove one version of Ruby installed by ruby-install. And I did not want to remove system Ruby. Sorry I did not state clearly from my question. I have updated my question.Poock
P
26

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/.

Phenosafranine answered 28/12, 2014 at 12:18 Comment(3)
You'll also need to clear out the installed gems as well. For me they are in ~/.gem/ruby/*.Unstrained
And then to update the list of rubies that chruby reports, either open a new shell or run source /usr/local/share/chruby/chruby.sh. See github.com/postmodern/ruby-install/issues/135Smithers
Removing the directory seems to be the documented ruby-install way.Vishnu
G
5

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
Getupandgo answered 24/7, 2019 at 7:12 Comment(1)
In my case a gem update corrupted my 2.7.2 version. Removing (rm -rf) the ~/.rubies/ruby-2.7.2 and ~/.gem/ruby/ruby-2.7.2 and then reinstalling with ruby-install --src-dir ~/src/ruby-install ruby 2.7.2 worked for me. My setup: Ubuntu 20.04, using brew.sh for ruby-install and chruby installsNorikonorina
C
2

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!

Chaney answered 19/3, 2017 at 10:12 Comment(0)
E
2

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.

Epos answered 3/5, 2017 at 14:50 Comment(0)
P
1

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.

Poock answered 27/12, 2014 at 7:43 Comment(0)
W
1

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"

Weary answered 27/12, 2014 at 12:53 Comment(1)
Thank you. But I mentioned that Ruby was installed by ruby-install.Poock
A
-1

To uninstall Ruby installed by ruby-install, you can follow these steps:

  1. Locate the Ruby installation directory. Ruby-install typically installs Rubies in the ~/.rubies/ folder. You can check the exact location by running the following command:
ruby-install list

This will list all of the Ruby installations managed by ruby-install.

  1. Uninstall the Ruby installation. Once you have located the Ruby installation directory, you can uninstall it by running the following command:
sudo rm -rf ~/.rubies/<version>

Replace <version> with the version of Ruby that you want to uninstall.

  1. Remove any installed gems. If you have any gems installed for the Ruby version that you are uninstalling, you can remove them by running the following command:
gem uninstall -a --all-versions --system | grep -v '^Already uninstalled'

This will uninstall all of the gems installed for the specified Ruby version.

  1. Remove the ruby-install cache. If you want to remove the ruby-install cache, you can run the following command:
sudo rm -rf ~/.cache/ruby-install

This will remove all of the Ruby installation files that are cached by ruby-install.

Important: Be careful when uninstalling Ruby, as it may remove other dependencies that are installed on your system. It is always a good idea to back up your system before uninstalling any software.

Albania answered 13/11, 2023 at 3:49 Comment(0)
L
-1

Removes all associated ruby packages

sudo apt remove ruby

Landrum answered 11/12, 2023 at 11:25 Comment(2)
After run sudo apt autoremoveLandrum
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Bedesman

© 2022 - 2024 — McMap. All rights reserved.