From: Josh Cheek Date: 2011-08-29T17:54:07+09:00 Subject: Re: load mongo fail --0015177414b298b84d04aba1093a Content-Type: text/plain; charset=ISO-8859-1 On Mon, Aug 29, 2011 at 2:45 AM, zuerrong wrote: > Hi > > I have installed mongo gem firstly, but when I require 'mongo' it get > failed: > > irb(main):001:0> require 'rubygems' > => true > irb(main):002:0> require 'mongo' > NameError: uninitialized constant Mongo > from ./mongo.rb:5 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in > `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in > `require' > from (irb):2 > > > This is my ruby and gem version: > > $ ruby -v > ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux] > $ gem -v > 1.8.10 > > Please help, thank you. > > You're using an old version of Ruby that leaves the current directory in the load path. This means that when you type `require "mongo"`, it is not requiring the mongo gem, instead it is requiring your local file. Look at the first line of the backtrace "from ./mongo.rb:5" The path to that file is ./mongo.rb, it's in your current directory. Obviously that file references `Mongo` on line 5, probably expecting that you'd already required the gem. --0015177414b298b84d04aba1093a--