Q:

Why is Rails using the wrong version of Ruby?

I have a Centos6 server with Ruby 1.9.3 and rails 3.2.3 on it. I use RVM. I then installed ruby 2.0.0 and rails 4.0.0. I changed the default ruby version with RVM. and confirmed with ruby --version I then changed my Gemfile appropriately and ran bundle install and/or bundle update as needed. Everything worked great. I then ran service httpd restart which worked and then navigated to my website and got the following:
Web application could not be started (Phusion Passenger error)
Could not find minitest-4.7.5 in any of the sources (Bundler::GemNotFound)
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/environment.rb:18:in `requested_specs'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:13:in `setup'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
/usr/local/rvm/gems/ruby-1.9.3-p429@global/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `<top (required)>'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
/usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/lib/phusion_passenger/loader_shared_helpers.rb:212:in `run_load_path_setup_code'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:73:in `preload_app'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:127:in `<module:App>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:6:in `<module:PhusionPassenger>'
/usr/local/rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.5/helper-scripts/rack-preloader.rb:5:in `<main>'

Environment variables
rvm_bin_path = /usr/local/rvm/bin
GEM_HOME = /usr/local/rvm/gems/ruby-1.9.3-p429
TERM = xterm
SHELL = /sbin/nologin
HISTSIZE = 1000
IRBRC = /usr/local/rvm/rubies/ruby-1.9.3-p429/.irbrc
PYTHONUNBUFFERED = 1
PASSENGER_ENV = production
PASSENGER_DEBUG_DIR = /tmp/passenger.spawn-debug.11360-47389796731312
SERVER_PORT = 80
MY_RUBY_HOME = /usr/local/rvm/rubies/ruby-1.9.3-p429
USER = nobody
REQUEST_URI = /
rvm_path = /usr/local/rvm
IN_PASSENGER = 1
RACK_ENV = production
REMOTE_PORT = 13101
rvm_prefix = /usr/local
PATH = /usr/local/rvm/gems/ruby-1.9.3-p429/bin:/usr/local/rvm/gems/ruby-1.9.3-p429@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p429/bin:/usr/local/rvm/bin:/usr/local/rvm/gems/ruby-2.0.0-p195/bin:/usr/local/rvm/gems/ruby-2.0.0-p195@global/bin:/usr/local/rvm/rubies/ruby-2.0.0-p195/bin:/usr/local/rvm/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin
MAIL = /var/spool/mail/nobody
WSGI_ENV = production
LANG = C
HISTCONTROL = ignoredups
rvm_env_string = ruby-1.9.3-p429
rvm_version = 1.20.13 (stable)
SHLVL = 2
HOME = /
RAILS_ENV = production
rvm_ruby_string = ruby-1.9.3-p429
SERVER_SOFTWARE = Apache/2.2.15 (CentOS)
LOGNAME = nobody
QUERY_STRING = 
CVS_RSH = ssh
GEM_PATH = /usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global
LESSOPEN = |/usr/bin/lesspipe.sh %s
SERVER_PROTOCOL = HTTP/1.1
REQUEST_METHOD = GET
RUBY_VERSION = ruby-1.9.3-p429
G_BROKEN_FILENAMES = 1
_ORIGINAL_GEM_PATH = /usr/local/rvm/gems/ruby-1.9.3-p429:/usr/local/rvm/gems/ruby-1.9.3-p429@global

But running env at the command line reveals these:
GEM_HOME=/usr/local/rvm/gems/ruby-2.0.0-p195
MY_RUBY_HOME=/usr/local/rvm/rubies/ruby-2.0.0-p195
PATH=/usr/local/rvm/gems/ruby-2.0.0-p195/bin:/usr/local/rvm/gems/ruby-2.0.0-p195@global/bin:...and so on
GEM_PATH=/usr/local/rvm/gems/ruby-2.0.0-p195:usr/local/rvm/gems/ruby-2.0.0-p195@global
RUBY_VERSION=ruby-2.0.0-p195

What am I missing? Why is rails trying to use the wrong version of ruby?

A:

You'll need to recompile passenger with your target Ruby:
rvm use 2.0.0
passenger_install_apache2_module

Update your apache passenger configs accordingly with the output it gives you.

A:

If you're logged into your server run
rvm --default use 2.0.0

A:

Ok. So after some searching I found that in my httpd.conf file the path to the old ruby was explicitly set. So I changed the path to the new ruby path
then ran gem install passenger
then installed it with with 
./usr/local/rvm/gems/ruby-2.0.0-p195/gems/passenger-4.0.5/bin/passenger-install-apache2-module

then service httpd restart and now it works!

