Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  1. Nginx + Passenger;
  2. The gempath is set to /home/<unprivileged_user>/.gem in ~/.gemrc;
  3. An init.d script is creaded and added to the boot sequence (update-rc.d nginx defaults);
  4. System is rebooted, server is started atomaticlally;
  5. http://localhost/my_rails_app;
  6. LoadError; no such file to load -- <gem_name>; <internal:lib/rubygems/custom_require>:29:in `require'.

Why can't Rubygems find gems in the custom location but can find them in default? That's the question.

like image 847
Shamaoke Avatar asked Nov 06 '22 09:11

Shamaoke


1 Answers

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

like image 52
Danny Avatar answered Nov 09 '22 16:11

Danny