Ruby 1.8.7升级到ruby 1.9.2

时间:2012-06-24 10:55:45

标签: ruby rvm

我正在浏览this tutorial,但我已经安装了Ruby 1.8.7。我需要有1.9.2 / 1.9.3版本。

我开始使用RVM。

$ rvm list rubies
rvm rubies
    ruby-1.8.7-p358 [ x86_64 ]
    ruby-1.9.2-p318 [ x86_64 ]
=*  ruby-1.9.2-p320 [ x86_64 ]
    ruby-1.9.3-p194 [ x86_64 ]

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

但是如果我运行ruby -v,它仍然返回1.8.7。

$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

其他回报值:

$ whereis ruby
ruby: /usr/bin/ruby /usr/bin/ruby1.8 /usr/lib/ruby /usr/share/man/man1/ruby.1.gz
$ which rails
/usr/local/bin/rails
$ which ruby
/usr/bin/ruby

2 个答案:

答案 0 :(得分:1)

当你输入ruby时,你仍然在使用系统ruby,而不是rvm ruby​​。

您是否按照此处的所有说明操作:https://rvm.io//rvm/install/

看起来你正在运行Linux - 你是否在rvm安装文档中看到了这一部分?

If you open a new shell and running:

$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.

Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.

If you are using GNOME on Red Hat, CentOS or Fedora, ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.

此外,rvm会在您的.bashrc文件中添加一些行,以便在您打开控制台会话时将其自身加载到内存中。看起来这可能是你的问题。

例如,在我的.bashrc中,rvm插入了以下内容:

export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql84/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

你的相似之处吗?此外,如果您使用的是z-shell,则可能需要采取安装文档中概述的一些额外步骤。

答案 1 :(得分:0)

尝试

$ rvm use ruby-1.9.2-p320

然后

$ ruby -v

这会带来什么回报?

这应该在当前控制台中将ruby版本更改为ruby-1.9.2-p320,如果你想在每个新打开的终端上使用它,你可以使用--default选项

$ rvm --default use ruby-1.9.2-p320

然后

$ruby -v

应该在当前和每个新窗口中打开ruby-1.9.2-p320版本。 任何时候你想要返回你的系统ruby安装 使用

$ rvm use system