Print Page

Sunday, October 10, 2010

json_pure 1.4.6 warnings

Was getting the constants reloaded warnings from json_pure 1.4.6 loading after json 1.4.6 . Found some discussion pointing to a patch at
Tried setting that as the source for the json gem in the Gemfile (gem 'json', :git => "git://" )and bundle installing. First run after that blew up like this:

allen$ rails c
/Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/source.rb:544:in `rescue in load_spec_files': git:// (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/source.rb:542:in `load_spec_files'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/source.rb:362:in `local_specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/source.rb:527:in `specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:341:in `block in converge_locked_specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:330:in `each'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:330:in `converge_locked_specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:145:in `resolve'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:93:in `specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:137:in `specs_for'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/definition.rb:126:in `requested_specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/environment.rb:23:in `requested_specs'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler/runtime.rb:11:in `setup'
from /Users/allen/.rvm/gems/ruby-1.9.2-p0@global/gems/bundler-1.0.0/lib/bundler.rb:100:in `setup'
from /Users/allen/Projects/charsheets/config/boot.rb:8:in `'
from :29:in `require'
from :29:in `require'
from script/rails:5:in `

Changed to just (gem 'json') and bundle install again.
Now it's working cleanly in both console and unicorn-rails, it seems the patching worked, though I need to understand things better.

allen$ rails c
Loading development environment (Rails 3.0.0)
ruby-1.9.2-p0 >

Why Mongoid

Just noticed the previous post to my mongoid troubleshooting post mentioned mongo_mapper. Why did I change? I hadn't gotten too deep into either one so didn't have much of an opinion. I picked mongo_mapper initially since it had more of a track record, even though some blog posts said mongoid integrated a bit better with Rails 3. But then I wanted to try out devise and they had switched from direct support of mongo_mapper to mongoid. I started into a brief look at what it would take to hook up devise with mongo_mapper, since I had started using it (barely), but then I found Daniel Kehoe's excellent devise mongo starter project and tried it out. I started a test project off of it as he suggested, and that worked right away. Later fiddling with my Gemfile got things out of sync. Now I see he is using an updated his Gemfile's lines for mongoid, so I will try that.

Round and round in circles on mongoid dependencies

I kept having the bug where it fails to load the binaries for bson_ext:

>rails c

**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
You can install the extension as follows:
gem install bson_ext

If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.

After several rounds of fiddling what worked was uninstalling mongo, mongoid, bson, bson_ext and then in the Gemfile:

# Bundle gems needed for Mongoid

gem "mongoid", "~>2.0.0.beta"
gem "mongo", "1.0.9"
gem "bson", "1.0.9"
gem "bson_ext", "1.0.9", :require => false

I think among the things that had me tripped up before was that just specifying bson was getting me 1.10, but mongo is 1.0.9 and there is some version matching needed. I think the :require => false on bson_ext may be important too.