为什么将gems安装在与我运行的Ruby版本不同的目录中? [英] Why are gems installed in a directory with a different Ruby version than I’m running?

查看:68
本文介绍了为什么将gems安装在与我运行的Ruby版本不同的目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装gem时,尽管不是我安装的Ruby版本,它仍会安装在名为1.9.1的目录中:

When I install a gem, it gets installed in a directory named 1.9.1, despite that not being the version of Ruby I have installed:

$ ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]

$ gem which rails
.../ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails.rb

为什么会这样?我没有安装其他Ruby版本(当然也没有安装v1.9.1).

Why does this happen? I have no other Ruby versions installed (and certainly not v1.9.1).

推荐答案

请注意,以下内容适用于撰写本文时的所有更高Ruby版本,而不仅仅是1.9.2.

Note that the following is also for all later Ruby versions as of this writing, not just 1.9.2.

根据> 1.9. 2发布公告:

标准库安装在/usr/local/lib/ruby/1.9.1

此版本是与库兼容的版本". Ruby 1.9.2几乎与1.9.1兼容,因此该库安装在1.9.1目录中.

This version is a "library compatible version." Ruby 1.9.2 is almost 1.9.1 compatible, so the library is installed in the 1.9.1 directory.

即使将其安装在编号不同的目录中,它仍使用1.9.2. RubyGems可以通过gem env显示其正在使用的所有目录.

Even though it is installed in a differently-numbered directory, it is using 1.9.2. RubyGems can show all the directories it’s using via gem env.

这确保了一组已安装的gem仅可以由它们实际运行的版本使用(特别是由于已编译的C扩展),并且确保在升级到较新的但与库兼容"的版本时,它不会运行.不必重新安装所有宝石.

This ensures that a set of installed gems is only used by versions that they can actually run with (especially due to compiled C extensions), and that when upgrading to a newer, but "library compatible", version, one doesn’t have to reinstall all gems.

这篇关于为什么将gems安装在与我运行的Ruby版本不同的目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆