如何卸载通过 ruby-install 安装的 ruby
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27665381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to uninstall ruby installed by ruby-install
提问by Juanito Fatas
I have many rubies installed by ruby-installunder ~/.rubies:
我在ruby-install下安装了许多红宝石~/.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?
我想卸载 ruby-install 安装的 ruby 之一,我该怎么做?
回答by Rael Gugelmin Cunha
Unfortunately appears that ruby-installjust downloads and compiles Ruby, with no option to remove it, unlike RVMor rbenv.
不幸的是,它ruby-install只是下载和编译 Ruby,没有删除它的选项,不像RVM或rbenv。
So, probably you'll need to run some manual commands here to delete all installed files.
因此,您可能需要在此处运行一些手动命令来删除所有已安装的文件。
1. Locate it
1. 找到它
Usually ruby-installwill install rubies in ~/.rubies/folder.
通常ruby-install会在~/.rubies/文件夹中安装红宝石。
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.listand you'll get a short list of them.
如果您不确定使用 安装了哪个 ruby ruby-install,请找到该文件.installed.list,因为它具有在 Ruby 安装过程中已安装文件的列表。如果你想快速找到它,只需运行locate .installed.list,你就会得到一个简短的列表。
Then run a caton 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.
然后cat对位于您要删除的版本的文件运行 a ,以确保哪个是您要删除的 ruby 安装的根文件夹。
2. Remove it
2. 删除它
Then you can just remove the folder where the target version is located.
然后您可以删除目标版本所在的文件夹。
If you want to remove ruby-1.9.3-p545, run:
如果要删除ruby-1.9.3-p545,请运行:
rm -Rf ~/.rubies/ruby-1.9.3-p545
回答by eric323
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.
如果您安装了 2.3x(+) 包并且需要卸载它,则根目录中有一个卸载可执行文件。转到 C:/,你会在那里看到 ruby 文件夹,里面有 unin.exe。这一切都取决于您选择安装它的位置。
回答by ILMostro_7
Based on the responses in a feature request, the best way to remove older ruby versions is to go back to the srcdirectory and run make uninstallor rake uninstall. By default, ruby-installuses $HOME/src/ruby-$versionfor unpacked sources of ruby versions during installation.
根据功能请求中的响应,删除旧 ruby 版本的最佳方法是返回src目录并运行make uninstall或rake uninstall。默认情况下,ruby-install使用$HOME/src/ruby-$version在安装过程中的Ruby版本解压来源。
For example, removing ruby version 2.6.3:
例如,删除 ruby 版本 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.
不幸的是,即使这个错误/请求是在 2016 年打开的,这个功能仍然没有在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/.
如果您已经使用默认位置安装了 ruby 版本,那么您应该通过删除$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.
值得注意的是,可能需要手动删除与该 ruby 版本一起安装的任何 gem。
e.g.
例如
rm -rf $HOME/.gem/ruby/ruby-2.6.3
回答by chad
if you install soft by dpkg or yum, when to uninstall it, you also should use dpkg or yum to purge it.
如果你用dpkg或yum安装soft,卸载的时候,你也应该用dpkg或yum来清除它。
for example, we want to unintall fcitx,
例如,我们要卸载 fcitx,
sudo apt-get purge -y 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.
否则,手动软安装,使用配置 && make && make install ,卸载时删除安装的目录即可。
for you example. just
以你为例。只是
rm -rf ~/.rubies/ruby-2.2.0
rm -rf ~/.rubies/ruby-2.2.0
if you have doubts that is the target ruby remove clearly, just use find command to confirm.
如果您怀疑目标 ruby 是否已删除,只需使用 find 命令确认即可。
find ~/ -name "ruby-2.2.0"
找到 ~/ -name " ruby-2.2.0"
回答by emelieh21
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:
我的 lubuntu 虚拟机遇到了完全相同的问题!我从登录屏幕(通过按CNTR + ALT + F3)进入 shell并检查了 ruby 和 gem 的版本:
ruby -vgem -v
ruby -vgem -v
then I run sudo apt-get purge -y rubyas suggested by chad. It successfully removed both ruby and gem.
然后我sudo apt-get purge -y ruby按照乍得的建议运行。它成功地删除了 ruby 和 gem。
Then I rebooted with:
然后我重新启动:
reboot
reboot
And I was able to log in normally again!
我又可以正常登录了!
回答by Juanito Fatas
You just remove where the ruby is.
您只需删除红宝石所在的位置。
For example, uninstall ruby that installed by ruby-install (default installation location is ~/.rubies):
例如,卸载通过 ruby-install 安装的 ruby(默认安装位置为~/.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:
如果您在删除 Ruby 2.2.0-preview2 并安装 Ruby 2.2.0-p0 后看到此类错误,例如:
$ 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/rubyfor all gem executables, will need to regenerate the gem bin stubs with the new path to the ruby executable.
因为每当 ruby 更新或移动/命名时,由于 RubyGems 正在#!/path/to/ruby为所有 gem 可执行文件生成显式,将需要使用新的 ruby 可执行文件路径重新生成 gem bin 存根。

