“宝石清单”卸载宝石后返回非空的
我正在尝试完全清理我的红宝石环境,因为我的宝石安装无法做任何事情。 所以我做到了:
sudo gem uninstall -aIx
但是之后:
gem list
仍然返回一长串宝石。为什么?
有没有方法可以摆脱一切并从头开始?
I'm trying to completely clean up my ruby environment, because my gem install is failing to do anything.
So I did:
sudo gem uninstall -aIx
But following that:
gem list
still returns a long list of gems. Why?
Is there way to get rid of everything and start from scratch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您永远不要
首先拥有零宝石,将宝石作为root在系统环境中的安装总是一个坏主意。其次,卸载Ruby或其宝石通常会引起问题。 如果您已经破坏了您的系统Ruby,则可能需要重新安装核心包,如果您在Linux上,或者如果您在MacOS上进行系统恢复。将来,请始终使用Ruby版本管理器以用户而不是root安装红宝石和宝石。
但是,值得注意的是,所有 All Ruby安装都带有一组默认的宝石,其中大部分用于标准库模块或Ruby在您的特定操作系统上运行所需的必需。即使是新鲜的Ruby也有许多默认的宝石,因此,除非您打破了Ruby的安装,否则您永远都不会看到完全空的宝石列表。例如,新的安装默认值:。
nb:无论出于何种原因,XMLRPC默认是在MacOS上使用Jruby安装的,但并未锁定默认版本。但是,出于讨论的目的,您可以将其视为默认的宝石,因为它是作为给定红宝石
的 基础安装的一部分安装的。它默认安装的宝石:
您永远不要尝试摆脱默认的宝石(例如,具有
default>默认的版本的任何GEM:
),因为已安装的Ruby版本取决于它们。这就是为什么Ruby版本经理通常定义单独的 gem_home 环境变量:以便您可以添加,升级或删除默认值以外的其他宝石而不会影响基本安装。因为这通常会导致给定宝石的多个版本,即使您运行GEM CLEAN
,使用 bundler 或 gemsets 很有用。如果您已经将您的系统ruby插入了系统,请根据操作系统适当地重新安装它。然后安装 chruby , rbenv 或 rvm 修改您的系统Ruby,再也不会运行
sudo gem
。从长远来看,您将为自己节省很多悲伤。You Should Never Have Zero Gems
First of all, installing gems as root into your system environment is always a bad idea. Secondly, uninstalling the system Ruby or its gems can often cause cause problems. If you've wrecked your system Ruby, you may need to reinstall the core packages for it if you're on Linux, or do a system recovery if you're on macOS. In future, always use a Ruby version manager to install Rubies and gems as a user rather than as root.
However, it's worth noting that all Ruby installations come with a set of default gems, most of which are for standard library modules or required for Ruby to run on your particular OS. Even a freshly-installed Ruby has a number of default gems, so you should never see a completely empty gem list unless you've broken your Ruby installation. For example, a fresh install of JRuby 9.3.4.0 has 39 gems, 38 of which are prefixed with
default:
.NB: For whatever reason, xmlrpc is installed by default with JRuby on macOS, but is not locked to a default version. Nevertheless, for the purposes of this discussion you can consider it a default gem since it's installed as part of the base installation for the given Ruby.*
For example, given a fresh installation of JRuby, you can see the list of gems it installs by default:
You should never try to get rid of default gems (e.g. any gem with a version prefixed with
default:
) because the installed Ruby version depends on them. That's why Ruby version managers typically define a separate GEM_HOME environment variable: so that you can add, upgrade, or remove gems other than the defaults without affecting the base installation. As this will generally result in having multiple versions of a given gem even if you rungem clean
, using Bundler or a version manager with gemsets can be useful.If you've already borked your system Ruby, reinstall it as appropriate depending on your OS. Then install chruby, rbenv, or rvm, and use that to manage your Rubies and gems without modifying your system Ruby, and never ever run
sudo gem
again. You'll save yourself a lot of grief in the long run that way.