RVM:可以设置默认的ruby版本但不能设置当前版本

时间:2016-10-03 07:10:31

标签: ruby rvm

问题:虽然默认的ruby设置为ruby 2.2.2。当我打开一个终端ruby 2.2.1加载。当我打开一个新终端时,如何确保加载ruby 2.2.2。

问题措辞不同:除非我卸载ruby 2.2.1,否则我无法将current && default设置为ruby 2.2.2。这是我输入rvm list

时得到的结果
   ~ $ rvm list

    rvm rubies

       ruby-1.8.7-head [ x86_64 ]
       ruby-1.8.7-p374 [ x86_64 ]
       ruby-1.9.3-p551 [ x86_64 ]
       ruby-2.0.0-p353 [ x86_64 ]
       ruby-2.2.0 [ x86_64 ]
    => ruby-2.2.1 [ x86_64 ]
     * ruby-2.2.2 [ x86_64 ]
       ruby-2.2.4 [ x86_64 ]

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

我希望current && default是ruby-2.2.2。如果我输入rvm use default,我会得到以下结果(这就是我想要的)。

~ $ rvm list

rvm rubies

   ruby-1.8.7-head [ x86_64 ]
   ruby-1.8.7-p374 [ x86_64 ]
   ruby-1.9.3-p551 [ x86_64 ]
   ruby-2.0.0-p353 [ x86_64 ]
   ruby-2.2.0 [ x86_64 ]
   ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.2 [ x86_64 ]
   ruby-2.2.4 [ x86_64 ]

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

如何确保无论何时打开终端,环境current && default都设置为ruby 2.2.2,如上所示? 观察:如果我卸载ruby 2.2.1,则默认为上述情况。我有一些项目需要ruby 2.2.1,我不能那样做。

我该怎么办?

顺便提一句which ruby给出以下输出:

~ $ which ruby
/home/rk/.rvm/rubies/ruby-2.2.1/bin/ruby

这是一个类似的问题,但未得到答复: RVM default is 2.1.1 but 2.1.2 is loaded initially

以下是rvm info

的输出
~ $ rvm info

ruby-2.2.1:

  system:
    uname:       "Linux X200 4.4.0-36-generic #55~14.04.1-Ubuntu SMP Fri Aug 12 11:49:30 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux"
    system:      "ubuntu/14.04/x86_64"
    bash:        "/bin/bash => GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

  rvm:
    version:      "rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "1 year 3 months 21 days 22 hours 56 minutes 31 seconds ago"
    path:         "/home/rk/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.2.1p85"
    date:         "2015-02-26"
    platform:     "x86_64-linux"
    patchlevel:   "2015-02-26 revision 49769"
    full_version: "ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]"

  homes:
    gem:          "/home/rk/.rvm/gems/ruby-2.2.1"
    ruby:         "/home/rk/.rvm/rubies/ruby-2.2.1"

  binaries:
    ruby:         "/home/rk/.rvm/rubies/ruby-2.2.1/bin/ruby"
    irb:          "/home/rk/.rvm/rubies/ruby-2.2.1/bin/irb"
    gem:          "/home/rk/.rvm/rubies/ruby-2.2.1/bin/gem"
    rake:         "/home/rk/.rvm/rubies/ruby-2.2.1/bin/rake"

  environment:
    PATH:         "/home/rk/.rvm/gems/ruby-2.2.1/bin:/home/rk/.rvm/gems/ruby-2.2.1@global/bin:/home/rk/.rvm/rubies/ruby-2.2.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/rk/.rvm/bin:/home/rk/.rvm/bin:/usr/local/heroku/bin:/home/rk/android-studio/bin:/home/rk/.rvm/bin"
    GEM_HOME:     "/home/rk/.rvm/gems/ruby-2.2.1"
    GEM_PATH:     "/home/rk/.rvm/gems/ruby-2.2.1:/home/rk/.rvm/gems/ruby-2.2.1@global"
    MY_RUBY_HOME: "/home/rk/.rvm/rubies/ruby-2.2.1"
    IRBRC:        "/home/rk/.rvm/rubies/ruby-2.2.1/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

2 个答案:

答案 0 :(得分:1)

对于我执行工作的命令

rvm --default use 2.2.2

您可能遇到登录shell问题,并且需要使用/bin/bash --login作为命令

答案 1 :(得分:0)

我通过将 Rails 应用程序中的 .ruby-version 文件更新为您尝试使用的较新的 ruby​​ 版本(在您的情况下为 2.2.2)解决了同样的问题