如何获取已安装且具有本机扩展的 gem 列表?
我使用的是 Windows,并且已从 ruby 1.8.x 更新到 1.9.x,现在收到错误弹出窗口,抱怨 ruby-mssomethingrt.1.8.x.dll 丢失。
我想找出哪些 gem 具有本机扩展,因此我可以卸载它们并在安装过程中再次在本地强制重建本机扩展,以使错误消失。
I'm on windows, and have updated from ruby 1.8.x to 1.9.x, and am now getting error popups that complain ruby-mssomethingrt.1.8.x.dll is missing.
I would like to find out which gems have native extensions, so I can uninstall them and force a rebuild of the native extensions locally during installation again, to make the error go away.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
基于这个答案,这里有一个解决方案,它可以查找并提供重新安装带有本机扩展的gems,该扩展适用于最近的版本红宝石 (>=1.9)。
示例输出:
Based on this answer, here is a solution that finds and offers to reinstall gems with native extensions that works with recent rubies (>=1.9).
Example Output:
一个好的开始是查看每个 gem 的 gem 规范,看看它是否具有 extensions 字段放。这应该会给您留下一个要重新安装的宝石的简短列表。它们不一定都使用本机扩展,但如果您查看相应的 extconf.rb 文件,应该很容易找到。
更新:这是一个简短的 ruby 脚本来列出这些宝石:
A good start would be to look at the gem specification for each gem and see if it has the extensions field set. That should leave you with a short-list of gems to re-install. They don't necessarily all use native extensions, but if you look at the corresponding
extconf.rb
files, this should be pretty easy to find out.Update: Here is a short ruby script to list those gems:
您可以使用以下命令重建(并恢复到原始状态)所有已安装的 gem:
--all --no-extensions
将恢复 gem 不带扩展,但尽管有记录,< code>--extensions 似乎没有效果(至少在 Ubuntu 12.10 上的 rubygems 1.8.23 上)。You can rebuild (and restore to a pristine state) all installed gems with:
--all --no-extensions
will restore gems without extensions, but despite being documented,--extensions
appears to have no effect (at least on rubygems 1.8.23 on Ubuntu 12.10).用于捆绑器 + Rails 的 Onliner:
打印出所有本机代码 gem(在更新主要 Ruby 版本时通常需要更新)
Onliner for bundler + rails:
prints out all native code gems (which usually need updates when updating major Ruby versions)
在 Cygwin 中,您可以尝试 gem list --all -d | grep --before-context=1 --after-context=4 平台。
In Cygwin you could try
gem list --all -d | grep --before-context=1 --after-context=4 Platform
.gem 列出
gem 旁边的版本后面的部分应指示它是否正在运行本机代码:
例如 json (1.4.6 x86-mingw32)
您看到的错误是因为您正在使用的 gems 之一期望 1.8 ruby 解释器存在,但它不再存在(因为您已升级到 1.9)。
我本以为只需运行“gem update”就能解决您的问题。如果没有,那么您可能需要为期望 ruby 1.8 解释器存在的宝石寻找替代宝石。
gem list
the part after the version next to the gem should indicate whether it's running native code:
e.g. json (1.4.6 x86-mingw32)
The error you are seeing is because one of the gems you are using expects the 1.8 ruby interpreter to be present which it no longer is (as you have upgraded to 1.9).
I would have thought that just running 'gem update' would fix your problem. If it doesn't, then you might need to seek an alternative gem for the one that is expecting the ruby 1.8 interpreter to be present.