There is a similar question about 'bson_ext', but it's not work for me.
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 req开发者_StackOverflow社区uired 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?
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.
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.
精彩评论