title: Running RoR2 application via unicorn or thin gives gem missing error
body: <p>Hullo,</p>
  
  <p>The following issue has really been bothering me much of late. I haven't been able to figure out exactly why it exists. </p>
  
  <p>I have a <code>Rails 2</code> application, specifically <code>Rails 2.3.5</code>, built that I am trying to deploy on a development machine running Ubuntu 10.10. I have set up everything properly, to the best of my knowledge. Here's some proof:</p>
  
  <pre><code>ayaz@ubuntu$ rails -v
  Rails 2.3.5
  ayaz@ubuntu$ gem -v
  1.3.7
  ayaz@ubuntu$ ruby -v
  ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
  ayaz@ubuntu$ gem env
  RubyGems Environment:
    - RUBYGEMS VERSION: 1.3.7
    - RUBY VERSION: 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
    - INSTALLATION DIRECTORY: /var/lib/gems/1.8
    - RUBY EXECUTABLE: /usr/bin/ruby1.8
    - EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
    - RUBYGEMS PLATFORMS:
      - ruby
      - x86-linux
    - GEM PATHS:
       - /var/lib/gems/1.8
       - /home/ayaz/.gem/ruby/1.8
    - GEM CONFIGURATION:
       - :update_sources =&gt; true
       - :verbose =&gt; true
       - :benchmark =&gt; false
       - :backtrace =&gt; false
       - :bulk_threshold =&gt; 1000
    - REMOTE SOURCES:
       - http://rubygems.org/
  ayaz@ubuntu$ gem list
  
  *** LOCAL GEMS ***
  
  actionmailer (2.3.5)
  actionpack (2.3.5)
  activerecord (2.3.5)
  activeresource (2.3.5)
  activesupport (2.3.5)
  atomic (1.1.10)
  daemons (1.1.9)
  eventmachine (1.0.3)
  i18n (0.6.4)
  kgio (2.8.0)
  minitest (4.7.5)
  multi_json (1.7.7)
  rack (1.5.2, 1.0.1)
  rails (2.3.5)
  raindrops (0.11.0)
  rake (10.1.0)
  thin (1.5.1)
  thread_safe (0.1.2)
  tzinfo (0.3.37)
  unicorn (4.6.3)
  </code></pre>
  
  <p>If I run the application via <code>script/server</code>, it runs fine:</p>
  
  <pre><code>ayaz@ubuntu$ script/server 
  =&gt; Booting WEBrick
  =&gt; Rails 2.3.5 application starting on http://0.0.0.0:3000
  =&gt; Call with -d to detach
  =&gt; Ctrl-C to shutdown server
  [2013-07-28 01:10:37] INFO  WEBrick 1.3.1
  [2013-07-28 01:10:37] INFO  ruby 1.8.7 (2010-06-23) [i686-linux]
  </code></pre>
  
  <p>However, if I run it, say, via <a href="https://github.com/blog/517-unicorn" rel="nofollow">unicorn</a> or <a href="http://code.macournoyer.com/thin/" rel="nofollow">thin</a>, I keep getting this <code>gem</code> error:</p>
  
  <pre><code>ayaz@ubuntu$ thin start
  &gt;&gt; Using rails adapter
  Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 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><code>unicorn_rails</code> gives the same error. Now, I've looked around and found suggestions about adding a <code>require "rubygems"</code> beforehand. I have tried it: I have added the line at the top of <code>config/boot.rb</code> as well as <code>config/environment.rb</code>, but to no avail. </p>
  
  <p>Would anyone be kind enough to point me in the right direction, please? </p>
  
  <p>Thanks much!</p>