Rubygems. LoadError in Rails

Everytime I start my Rails applications I get LoadError with the following output.

On Rails 2.3.8:

no such file to load -- sqlite3/sqlite3_native
<internal:lib/rubygems/custom_require>:29:in `require'

On Rails 3.0.0:

no such file to load -- bundler
<internal:lib/rubygems/custom_require>:29:in `require'

I run the applications in the production mode on a development machine using Nginx + Passenger.

What is the reason of this issue? How can I solve it?

Thanks.

Debian GNU/Linux 5.0.6;

Ruby 1.9.2;

Rubygems 1.3.7;

Ruby on Rails 2.3.8, 3.0.0;

Nginx 0.8.50;

Passenger 2.2.15;

sqlite3-ruby 1.3.1;

bundler 1.0.0.rc.6.

Updated


All of my gems is installed by the unprivileged user in the local directory /home/<usernam>/.gem . If it helps, here's the gem env output:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
  - INSTALLATION DIRECTORY: /home/<username>/.gem
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /home/<username>/.gem/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /home/<username>/.gem
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-ri --no-rdoc"
     - :gemhome => "/home/<username>/.gem"
     - :gempath => ["/home/<username>/.gem"]
  - REMOTE SOURCES:
     - http://rubygems.org/

Updated


I tackled with the problem. Its source was that I defined a custom gem path . That is I added to the ~/.gemrc file the following lines:

:gemhome: /home/<username>/.gem
:gempaths:
  - /home/<username>/.gem

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.

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.

Once again, the bug conditions are:

  • Nginx + Passenger;
  • The gempath is set to /home/<unprivileged_user>/.gem in ~/.gemrc ;
  • An init.d script is creaded and added to the boot sequence ( update-rc.d nginx defaults );
  • System is rebooted, server is started atomaticlally;
  • http://localhost/my_rails_app;
  • LoadError; no such file to load -- ; :29:in `require'.
  • Why can't Rubygems find gems in the custom location but can find them in default? That's the question.


    I too had this problem when using RVM - I must have specified a gemset or something and not made it project specific. At any rate, read this rvm guide if you want to know the basics of RVM and try to specify a new gemset for your current folder / project, install a new rails gem to that gemset, and then use that gemset. For example, to create a new gemset for rails version 2.3.8:


    $ rvm gemset create rails238


    $ rvm ruby-1.8.7@rails238


    $ gem install rails -v 2.3.8


    Then if all went according to plan type rvm gemset use [gemsetName], or do rvm gemset list to see a list of installed gemsets, and to see if rails is working fine try rails -v and you should see rails 2.3.8


    Check your system to locate where your rubies and gems are installed ( you can do this by "which ruby" and "which gem"). Usually, they're installed in the same folder (/usr/bin or /usr/local). If they are in different locations, there might be load error. Just a suggestion.

    链接地址: http://www.djcxy.com/p/25272.html

    上一篇: 如何在类初始化中拯救输入

    下一篇: RubyGems的。 LoadError在Rails中