为什么即使我已更新Rails,Rails仍使用旧版本的Ruby? [英] Why is Rails using an old version of Ruby even though I have updated it?

查看:92
本文介绍了为什么即使我已更新Rails,Rails仍使用旧版本的Ruby?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台安装了Ruby 1.8的Ubuntu计算机.

我将Rails应用程序复制到该文件,并执行了bundle install.它安装一切正常.该应用程序需要Ruby 1.9,因此我下载了Ruby源代码,对其进行了编译和安装.

当我执行ruby -v时,我得到ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux],但是当我对rails console进行RUBY_VERSION时,我得到了1.8.7.当我尝试运行Rails应用程序时,它失败了.我的Rails应用程序使用的是Ruby的旧版本,即使在控制台和其他任何地方都可以正常工作.哎呀,我什至创建了一个新的Rails应用程序,它使用的是新版本.

有什么想法吗?

解决方案

键入哪个红宝石"和哪个irb"

您应该看到其中带有〜/.rvm/的路径...但是我敢打赌,您的系统上某处有一个旧版本的ruby和irb ..可能在/usr/bin下

要摆脱这一点,您需要在RVM 中设置默认的ruby版本,并且您需要确保正确设置了RVM(例如,在.bashrc或.bash_profile文件中)

输入"rvm list" ..,您应该会看到类似以下内容的内容:

$ rvm list

rvm rubies

   ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

注意:您应该看到指向1.9.2的箭头,这表明它是默认版本

如果未将其设置为默认值,请键入:"rvm --default use 1.9.2"

还请检查"printenv PATH"以检查.rvm目录是否位于PATH中的/usr/bin之前

I have an Ubuntu machine with Ruby 1.8 installed.

I copied my Rails application to it, and did bundle install. It installed everything fine. The application requires Ruby 1.9, so I downloaded the Ruby source, compiled, and installed it.

When I do ruby -v, I get ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux], but when I do RUBY_VERSION on rails console, I get 1.8.7. When I try to run my Rails application, it fails. My Rails application is using the older version of Ruby even when from the console and everywhere else it works fine. Heck, I even created a new Rails application and it uses a newer version.

Any ideas what's going on?

解决方案

type "which ruby" and "which irb"

you should see a path with ~/.rvm/ in it... but I bet you that you have somewhere on your system an old version of ruby and irb .. probably under /usr/bin

to get rid of this, you need to set your default ruby version in RVM and you need to make sure that RVM is setup correctly (e.g. in your .bashrc or .bash_profile file)

type "rvm list" .. and you should see something like this:

$ rvm list

rvm rubies

   ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]

NOTE: that you should see the arrow pointing to 1.9.2 which indicates it is the default version

if it is not set as default, type: "rvm --default use 1.9.2"

Also check "printenv PATH" to check that .rvm directories come before /usr/bin in the PATH

这篇关于为什么即使我已更新Rails,Rails仍使用旧版本的Ruby?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆