title: Rubygems. LoadError in Rails
body: <p>Everytime I start my Rails applications I get <strong>LoadError</strong> with the following output.</p>
  
  <p>On Rails 2.3.8:</p>
  
  <pre>
  no such file to load -- sqlite3/sqlite3_native
  &#60;internal:lib/rubygems/custom_require&#62;:29:in `require'
  </pre>
  
  <p>On Rails 3.0.0:</p>
  
  <pre>
  no such file to load -- bundler
  &#60;internal:lib/rubygems/custom_require&#62;:29:in `require'
  </pre>
  
  <p>I run the applications in the production mode on a development machine using Nginx + Passenger.</p>
  
  <p>What is the reason of this issue? How can I solve it?</p>
  
  <p>Thanks.</p>
  
  <p>Debian GNU/Linux 5.0.6;</p>
  
  <p>Ruby 1.9.2;</p>
  
  <p>Rubygems 1.3.7;</p>
  
  <p>Ruby on Rails 2.3.8, 3.0.0;</p>
  
  <p>Nginx 0.8.50;</p>
  
  <p>Passenger 2.2.15;</p>
  
  <p>sqlite3-ruby 1.3.1;</p>
  
  <p>bundler 1.0.0.rc.6.</p>
  
  <p><strong>Updated</strong></p>
  
  <hr>
  
  <p>All of my gems is installed by the unprivileged user in the local directory <code>/home/&lt;usernam&gt;/.gem</code>. If it helps, here's the <code>gem env</code> output:</p>
  
  <pre>
  RubyGems Environment:
    - RUBYGEMS VERSION: 1.3.7
    - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
    - INSTALLATION DIRECTORY: /home/&#60;username&#62;/.gem
    - RUBY EXECUTABLE: /usr/local/bin/ruby
    - EXECUTABLE DIRECTORY: /home/&#60;username&#62;/.gem/bin
    - RUBYGEMS PLATFORMS:
      - ruby
      - x86-linux
    - GEM PATHS:
       - /home/&#60;username&#62;/.gem
    - GEM CONFIGURATION:
       - :update_sources => true
       - :verbose => true
       - :benchmark => false
       - :backtrace => false
       - :bulk_threshold => 1000
       - "gem" => "--no-ri --no-rdoc"
       - :gemhome => "/home/&#60;username&#62;/.gem"
       - :gempath => ["/home/&#60;username&#62;/.gem"]
    - REMOTE SOURCES:
       - http://rubygems.org/
  </pre>
  
  <p><strong>Updated</strong></p>
  
  <hr>
  
  <p>I tackled with the problem. Its source was that <strong>I defined a custom gem path</strong>. That is I added to the <code>~/.gemrc</code> file the following lines:</p>
  
  <pre>
  :gemhome: /home/&#60;username&#62;/.gem
  :gempaths:
    - /home/&#60;username&#62;/.gem
  </pre>
  
  <p>Thus all of my gems was placed in the specified directory but not the default one. For some reason Rubygems coundn't find it there and rose an exception.</p>
  
  <p>When I removed that lines from the file the default paths was set for Rubygems and after I installed all the required gems and loaded my Rails applications all began to work.</p>
  
  <p>Once again, the bug conditions are:</p>
  
  <ol>
  <li>Nginx + Passenger;</li>
  <li>The gempath is set to <code>/home/&lt;unprivileged_user&gt;/.gem</code> in <code>~/.gemrc</code>;</li>
  <li>An <code>init.d</code> script is creaded and added to the boot sequence (<code>update-rc.d nginx defaults</code>);</li>
  <li>System is rebooted, server is started atomaticlally;</li>
  <li><a href="http://localhost/my_rails_app" rel="nofollow noreferrer">http://localhost/my_rails_app</a>;</li>
  <li>LoadError; no such file to load -- &#60;gem_name&#62;; &#60;internal:lib/rubygems/custom_require&#62;:29:in `require'.</li>
  </ol>
  
  <p><strong>Why can't Rubygems find gems in the custom location but can find them in default?</strong> That's the question.</p>