Rails:控制台如何决定使用哪个Ruby版本?

时间:2014-04-07 17:14:05

标签: ruby-on-rails ruby rails-console

我对在我的机器上使用的Ruby版本感到有点困惑 - 有人可以解释为什么Rails控制台使用不同版本的Ruby (2.1.0)(或似乎是)使用不同版本的Ruby (2.1.1)。以下命令返回$ bundle exec rails c Loading development environment (Rails 4.1.0.rc2) 2.1.0 :001 >

$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

=> 2.1.0

$ which ruby
/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby

=> 2.1.1

$ rvm list

rvm rubies

=* ruby-2.1.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

=> 2.1.1

$ rvm info

ruby-2.1.1@rails410rc2:

  system:
    uname:       "Linux [...] 3.11.0-18-generic #32-Ubuntu SMP Tue Feb 18 21:11:14 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "ubuntu/13.10/x86_64"
    bash:        "/bin/bash => GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.25.22 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "7 days 9 hours 8 minutes 49 seconds ago"
    path:         "/usr/local/rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.1.1p76"
    date:         "2014-02-24"
    platform:     "x86_64-linux"
    patchlevel:   "2014-02-24 revision 45161"
    full_version: "ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]"

  homes:
    gem:          "/usr/local/rvm/gems/ruby-2.1.1@rails410rc2"
    ruby:         "/usr/local/rvm/rubies/ruby-2.1.1"

  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-2.1.1/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-2.1.1/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-2.1.1/bin/gem"
    rake:         "/usr/local/rvm/rubies/ruby-2.1.1/bin/rake"

  environment:
    PATH:         "/usr/local/rvm/gems/ruby-2.1.1@rails410rc2/bin:/usr/local/rvm/gems/ruby-2.1.1@global/bin:/usr/local/rvm/rubies/ruby-2.1.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/rvm/bin"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-2.1.1@rails410rc2"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-2.1.1@rails410rc2:/usr/local/rvm/gems/ruby-2.1.1@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-2.1.1"
    IRBRC:        "/usr/local/rvm/rubies/ruby-2.1.1/.irbrc"
    RUBYOPT:      ""
    gemset:       "rails410rc2"

=&GT; 2.1.1

编辑:

{{1}}

1 个答案:

答案 0 :(得分:0)

由于RUBY_VERSION返回2.1.1,因此您使用的是Ruby 2.1.1。可能irb提示符以某种方式修补,返回2.1.0而不是2.1.1,我猜是通过RVM。它应该打补丁,因为标准的irb提示符应该是

irb(main):001:0>