我对我的机器上使用的Ruby版本有点困惑——有人能解释一下为什么Rails控制台(或者看起来)使用的Ruby版本不同于下面其他命令返回的Ruby版本吗?
$ bundle exec rails c
Loading development environment (Rails 4.1.0.rc2)
2.1.0 :001 >
=>2.1.0版
$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
=>2.1.1条
$ 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 <[email protected]>, Michal Papis <[email protected]> [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"
最佳答案
因为RUBY_VERSION
返回2.1.1
所以您使用的是Ruby 2.1.1可能irb提示符是以某种方式修补的,返回的是2.1.0而不是2.1.1,我猜是RVM它应该被修补,因为标准的irb提示应该是
irb(main):001:0>