简体   繁体   中英

RVM: Can set the default ruby version but cannot set the current version

Problem: Though the default ruby is set to ruby 2.2.2. When I open a terminal ruby 2.2.1 is loaded. How do I ensure that ruby 2.2.2 loads when I open a new terminal.

Problem phrased differently: I am not able to set current && default to ruby 2.2.2 unless I uninstall ruby 2.2.1. This is what I get when I type 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

I want the current && default to be ruby-2.2.2. If I type rvm use default I get the result as the following (which is what I want).

~ $ 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

How can I make sure whenever I open a terminal the environment current && default is set to ruby 2.2.2 as shown above? An observation: If I uninstall ruby 2.2.1 it defaults to the above situation. I have some projects which need ruby 2.2.1 and I cannot do that.

What should I do about this?

By the way which ruby gives the following output:

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

Here is a similar question which has been unanswered: RVM default is 2.1.1 but 2.1.2 is loaded initially

Here is the out put of 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:       ""

For me following command doing the work

rvm --default use 2.2.2

You might have issue with login shell and required to use /bin/bash --login as the command

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM