rvm - ruby​​的默认版本

时间:2015-01-15 22:39:44

标签: ruby rvm

我几天前这样做了:

$ rvm --default use 2.1.5

但是当我今天跑ruby -v时,我得到了:

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

有没有更好的方法来永久设置我使用的Ruby版本?

====更新

$ rvm use
Using /Users/snowcrash/.rvm/gems/ruby-2.1.5
$ which rvm
/Users/snowcrash/.rvm/bin/rvm
$ which ruby
/Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin/ruby

rvm info的输出(请注意,ruby已恢复为2.0.0p481):

$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
$ rvm info

ruby-2.1.5:

  system:
    uname:       "Darwin w.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64"
    system:      "osx/10.10/x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)"
    zsh:         "/bin/zsh => zsh 5.0.5 (x86_64-apple-darwin14.0)"

  rvm:
    version:      "rvm 1.26.9 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "8 days 7 hours 2 minutes 42 seconds ago"
    path:         "/Users/snowcrash/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.0.0p481"
    date:         "2014-05-08"
    platform:     "universal.x86_64-darwin14"
    patchlevel:   "2014-05-08 revision 45883"
    full_version: "ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]"

  homes:
    gem:          "/Users/snowcrash/.rvm/gems/ruby-2.1.5"
    ruby:         "/Users/snowcrash/.rvm/rubies/ruby-2.1.5"

  binaries:
    ruby:         "/usr/bin/ruby"
    irb:          "/usr/bin/irb"
    gem:          "/usr/bin/gem"
    rake:         "/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin/rake"

  environment:
    PATH:         "/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin:/Users/snowcrash/.apportable/SDK/bin:/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/Users/snowcrash/Library/ec2-api-tools-1.3-24159/bin:/Users/snowcrash/bin:/Users/snowcrash/Library/android-sdk-mac_86:/Users/snowcrash/Library/android-sdk-mac_86/platform-tools:/Users/snowcrash/Library/bin:/usr/local/mysql/bin:/usr/local/bin:/Library/PostgreSQL/9.1/bin:/usr/local/sbin:/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin:/Users/snowcrash/.rvm/gems/ruby-2.1.5@global/bin:/Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/snowcrash/.rvm/bin:/Users/snowcrash/bin/gsutil:/usr/local/graphviz-2.14/bin:/Users/snowcrash/.rvm/bin"
    GEM_HOME:     "/Users/snowcrash/.rvm/gems/ruby-2.1.5"
    GEM_PATH:     "/Users/snowcrash/.rvm/gems/ruby-2.1.5:/Users/snowcrash/.rvm/gems/ruby-2.1.5@global"
    MY_RUBY_HOME: "/Users/snowcrash/.rvm/rubies/ruby-2.1.5"
    IRBRC:        "/Users/snowcrash/.rvm/rubies/ruby-2.1.5/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

2 个答案:

答案 0 :(得分:0)

rvm usewhich rvmwhich ruby之类的内容是什么?这看起来像系统Ruby,对我来说意味着你没有正确安装rvm并且你打开了一个新的终端会话并获得了系统版本。

或者,命令输入错误。 rvm use --default 2.1.5

之后,rvm list会将其标记为默认值。

(nick@blerp)-(~)
(507)⚡️ rvm use --default 2.2.0
Using /Users/nick/.rvm/gems/ruby-2.2.0

(nick@blerp)-(~)
(508)⚡️ rvm list

rvm rubies

=* ruby-2.2.0 [ x86_64 ]

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

您可以随时reinstall rvm(重新安装不会受到伤害)并确保路径设置位于您的shell dotfiles中。

答案 1 :(得分:0)

您的PATH多次包含/usr/bin次,其中第一次在/Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin之前,因此首先添加系统提供的ruby。

你似乎有很多条目 - 检查你的shell初始化文件(.bashrc,.bash_profile等)并检查操作$ PATH的任何内容