views:

317

answers:

2

There is a similar question about 'bson_ext', but it's not work for me.

http://stackoverflow.com/questions/2900604/mongomapper-and-bson-ext-problem

I'm using Rails 2.3.8 + MongoId 1.9.1. I followed the "installation" page as:

gem install mongoid
gem install mongo -v=1.0.4
gem install bson_ext -v=1.0.4

In my config/environment.rb, I added:

config.gem 'mongoid'
config.gem 'mongo', :version=>'1.0.4'
config.gem 'bson_ext', :verstion=>'1.0.4'

When I start the application with ruby script/server, it shows:

=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
no such file to load -- bson_ext
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in `new_constants_in'
...
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
script/server:3
Missing these required gems:
  bson_ext  = 1.0.4

You're running:
  ruby 1.8.7.299 at /usr/local/bin/ruby
  rubygems 1.3.7 at /root/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

But I have installed bson_ext 1.0.4:

gem list

bson (1.0.4, 1.0.3, 1.0.1, 1.0)
bson_ext (1.0.4, 1.0.1, 1.0)
mongo (1.0.4, 1.0.1, 1.0)
mongoid (1.9.1)
mongo_ext (0.19.3)

And, I have tried to use 1.0 and 1.0.1, but the same exceptions are thrown.

What's wrong?

+2  A: 

Try changing your config.gem line to:

config.gem 'bson_ext', :version=>'1.0.4', :lib => false

This prevents rails from trying to require "bson_ext", which doesn't work. The bson gem actually tries to require "bson_ext/cbson" automatically, and eventually falls back to bson_ruby if it can't find a native version.

Jim Garvin
@Jim, thank you!
Freewind
A: 

I had to uninstall all the bson and mongo gems and then run rake gems:install with only:

  config.gem "mongo_mapper"

in my environment.rb file. The Railscasts for MongoDB and MongoMapper helped me get started using MongoDB with my Rails 2.3.8 app. Anything else would generate the bson_ext error.

rxgx
So you're running without the bson_ext lib?
Jim Garvin
Yes, that is correct. I'll try a fresh install with only "config.gem 'mongoid'" on my next instance to confirm this.
rxgx