title: Rails 2.1.0 Gem Missing - RVM, Passenger, Apache
body: <p>Yesterday I was trying to fix the readline console issue (slow copy/paste in irb), which I wasn't able to fix - but also must have messed something up bad with my rvm setup.</p>
  
  <p>Ubuntu 11.10.</p>
  
  <p><strong>First my problem:</strong> Can't load the website through virtual host, only script/server. When loading through virtualhost, I get this:</p>
  
  <pre><code>Missing the Rails 2.1.0 gem. Please `gem install -v=2.1.0 rails`,
  update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails
  version you do have installed, or comment out RAILS_GEM_VERSION to use
  the latest version installed.
  </code></pre>
  
  <p>Gem list shows (edited for clarity - note that both mysql, rails 2.1, and passenger show in the list - it is grabbing from both global and myapp21 gemsets):</p>
  
  <pre><code>tom@DEVPC2:/var/www/myapp$ gem list
  
  *** LOCAL GEMS ***
  ....
  actionmailer (2.1.0)
  actionpack (2.1.0)
  activerecord (2.1.0)
  activeresource (2.1.0)
  activesupport (2.1.0)
  bundler (1.0.21)
  capistrano (2.9.0)
  mysql (2.8.1)
  passenger (3.0.11)
  rack (1.3.5)
  rails (2.1.0)
  rake (0.9.2.2)
  ...
  </code></pre>
  
  <p><strong>So, here are the things I have tried so far:</strong></p>
  
  <p>I have completely removed all gemsets, rubys (only have one, 1.8.7), and then rvm itself. Reinstalled from the <a href="http://beginrescueend.com/rvm/install/" rel="nofollow">guide</a>. Added passenger, bundler (not using for this project), and capistrano to gemset global. Installed passenger module for apache2 (passenger-install-apache2-module), followed instructions to add the load passenger stuff to /etc/apache2/apache2.conf:</p>
  
  <pre><code>LoadModule passenger_module /home/tom/.rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
  PassengerRoot /home/tom/.rvm/gems/ruby-1.8.7-p352@global/gems/passenger-3.0.11
  PassengerRuby /home/tom/.rvm/wrappers/ruby-1.8.7-p352@global/ruby
  </code></pre>
  
  <p>Then: rvm gemset create myapp21 - proceeded to install rails 2.1.0, mysql, other gems to the gemset.</p>
  
  <p>Set up myapp/.rvmrc:</p>
  
  <pre><code>rvm use ruby-1.8.7-p352@myapp21
  </code></pre>
  
  <p>And config/setup_load_paths.rb:</p>
  
  <pre><code>if ENV['MY_RUBY_HOME'] &amp;&amp; ENV['MY_RUBY_HOME'].include?('rvm')
    begin
      rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
      rvm_lib_path = File.join(rvm_path, 'lib')
      $LOAD_PATH.unshift rvm_lib_path
      require 'rvm'
      RVM.use_from_path! File.dirname(File.dirname(__FILE__))
    rescue LoadError
      # RVM is unavailable at this point.
      raise "RVM ruby lib is currently unavailable."
    end
  end
  </code></pre>
  
  <p>I have my virtualhost:</p>
  
  <pre><code>tom@DEVPC2:/var/www/myapp$ cat /etc/apache2/sites-enabled/myapp.local 
  &lt;VirtualHost *:80&gt;
     ServerName myapp.local
     RailsEnv development
     DocumentRoot /var/www/myapp/public
     &lt;Directory /var/www/myapp/public&gt;
        AllowOverride all
        Options -MultiViews
     &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>Now some info:</p>
  
  <pre><code>tom@DEVPC2:/var/www/myapp$ rvm info    
  ruby-1.8.7-p352@myapp21:
  
    system:
      uname:       "Linux DEVPC2 3.0.0-13-generic-pae #22-Ubuntu SMP Wed Nov 2 15:17:35 UTC 2011 i686 i686 i386 GNU/Linux"
      bash:        "/bin/bash =&gt; GNU bash, version 4.2.10(1)-release (i686-pc-linux-gnu)"
      zsh:         " =&gt; not installed"
  
    rvm:
      version:      "rvm 1.10.0-pre by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
  
    ruby:
      interpreter:  "ruby"
      version:      "1.8.7"
      date:         "2011-06-30"
      platform:     "i686-linux"
      patchlevel:   "2011-06-30 patchlevel 352"
      full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]"
  
    homes:
      gem:          "/home/tom/.rvm/gems/ruby-1.8.7-p352@myapp21"
      ruby:         "/home/tom/.rvm/rubies/ruby-1.8.7-p352"
  
    binaries:
      ruby:         "/home/tom/.rvm/rubies/ruby-1.8.7-p352/bin/ruby"
      irb:          "/home/tom/.rvm/rubies/ruby-1.8.7-p352/bin/irb"
      gem:          "/home/tom/.rvm/rubies/ruby-1.8.7-p352/bin/gem"
      rake:         "/home/tom/.rvm/gems/ruby-1.8.7-p352@global/bin/rake"
  
    environment:
      PATH:         "/home/tom/.rvm/gems/ruby-1.8.7-p352@myapp21/bin:/home/tom/.rvm/gems/ruby-1.8.7-p352@global/bin:/home/tom/.rvm/rubies/ruby-1.8.7-p352/bin:/home/tom/.rvm/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
      GEM_HOME:     "/home/tom/.rvm/gems/ruby-1.8.7-p352@myapp21"
      GEM_PATH:     "/home/tom/.rvm/gems/ruby-1.8.7-p352@myapp21:/home/tom/.rvm/gems/ruby-1.8.7-p352@global"
      MY_RUBY_HOME: "/home/tom/.rvm/rubies/ruby-1.8.7-p352"
      IRBRC:        "/home/tom/.rvm/rubies/ruby-1.8.7-p352/.irbrc"
      RUBYOPT:      ""
      gemset:       "myapp21"
  </code></pre>
  
  <p>Using script/server allows me to load to localhost:3000 (or whatever port specified). But I can't load myapp.local, which just yesterday I was able to do - it tells me rails is missing.</p>
  
  <p>What I believe is happening:
  Passenger is loading ruby, the virtual host stuff is still working, but for some reason it's not grabbing the directives from setup_load_paths to load my gemsets based on the rvmrc (I am not entirely sure if this is what happens, but if it is, it's not doing it).</p>
  
  <p>My next step is a clean install. JUST got this machine all set up, don't want to waste my weekend on that.</p>