问题
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