如何卸载 Windows 上的所有 ruby gem?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6373160/
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 all ruby gems on windows?
提问by Bohdan
How to uninstall all ruby gems on Windows? Is it possible with single command?
如何在 Windows 上卸载所有 ruby gems?单个命令可以吗?
回答by Haris Krajina
One line to rule them all. Power shell not needed. From command prompt run:
一条线统治他们。不需要电源外壳。从命令提示符运行:
ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.empty? }"
Just copy / paste and voila!
只需复制/粘贴,瞧!
回答by Bohdan
I've found an elegant solution gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ }
and Windows Powershell
我找到了一个完美的解决方案gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ }
,并Windows Powershell
回答by Yardboy
You can delete the contents of your gems folder. Where this is will depend on how you installed Ruby and RubyGems, as well as the Ruby version. For instance, if you used the one-click installer for 1.9.2p180, and installed rubygems with ruby setup.rb, the gems folder would be c:\Ruby192\lib\ruby\gems\ - delete everything under that folder and poof! your gems are gone.
您可以删除 gems 文件夹中的内容。这将取决于您安装 Ruby 和 RubyGems 的方式,以及 Ruby 版本。例如,如果您使用 1.9.2p180 的一键安装程序,并使用 ruby setup.rb 安装 rubygems,那么 gems 文件夹将是 c:\Ruby192\lib\ruby\gems\ - 删除该文件夹下的所有内容,噗!你的宝石不见了。
回答by Luis Lavena
Using gem env
on your console will provide something like this:
gem env
在您的控制台上使用将提供如下内容:
- GEM PATHS:
- C:/Users/Luis/Tools/ruby/ruby-1.8.7-p334-i386-mingw32/lib/ruby/gems/1.8
If you browse using Explorer into that directory will find a series of folders that represent all the installed gems (cache
, doc
, spec
, gems
)
如果您使用资源管理器浏览到该目录,将找到一系列代表所有已安装 gems 的文件夹(cache
, doc
, spec
, gems
)
Remove all of them and it will remove all your gems.
删除所有这些,它将删除您所有的宝石。
Now, this will not remove any executable script installed by one of these gems. If you installed rake
or rails
gems, these scripts (as rails
and rails.bat
will remain in your Ruby bin
directory.
现在,这不会删除这些 gem 之一安装的任何可执行脚本。如果您安装了gemsrake
或rails
gems,这些脚本(asrails
并且rails.bat
将保留在您的 Rubybin
目录中。
You will also need to remove them manually.
您还需要手动删除它们。