Why is Rails using an old version of Ruby even though I have updated it?

只愿长相守 提交于 2019-12-13 02:51:10

问题


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?


回答1:


Wait... you actually compiled it from source? You most likely have the new version of ruby in your console path but you application dosnt have it. Uninstall ruby from your system and use RVM that way you have something managing your ruby versions.




回答2:


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



来源:https://stackoverflow.com/questions/6232193/why-is-rails-using-an-old-version-of-ruby-even-though-i-have-updated-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!