How to uninstall ruby installed by ruby-install

左心房为你撑大大i 提交于 2021-02-07 11:16:27

问题


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?


回答1:


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



回答2:


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



回答3:


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.




回答4:


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"




回答5:


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!




回答6:


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.



来源:https://stackoverflow.com/questions/27665381/how-to-uninstall-ruby-installed-by-ruby-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!