ruby 1.8.7 升级到 ruby 1.9.2

标签 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

最佳答案

当您输入 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 文件中添加一些行,以便在您打开控制台 session 时将其自身加载到内存中。看起来这可能是您的问题。

在我的 .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,您可能需要执行安装文档中概述的一些额外步骤。

关于 ruby 1.8.7 升级到 ruby 1.9.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11176850/

相关文章:

Ruby Koans 与 Ruby 2.0.0 不兼容?

ruby - 无法安装 ruby​​ 2.0.0

ruby-on-rails - 将 CSV 转换为数组?

ruby - 在 Ruby 中将数组输出到 CSV

html - Bootstrap 似乎没有导入

Ruby 字符串到类名

bash - 如何在 shell 脚本中使用 rvm

ruby - 如何彻底去除 ruby ?

ruby - 无法加载 'active_record/connection_adapters/mysql2_adapter'

ruby-on-rails - rails smtp 问题