Already initialized constants on Ruby 1.9.2
When I have json_pure in my project, every time I run rake something, it outputs this first:
/home/steven/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:65: warning: already initialized constant State /home/steven/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:66: warning: already initialized constant SAFE_STATE_PROTOTYPE /home/steven/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:67: warning: already initialized constant FAST_STATE_PROTOTYPE /home/steven/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/common.rb:74: warning: already initialized constant PRETTY_STATE_PROTOTYPE /home/steven/.rvm/gems/ruby-1.9.2-p0/gems/json_pure-1.4.6/lib/json/pure.rb:76: warning: already initialized constant JSON_LOADED
Highly annoying.
This is a duplicate of http://github.com/flori/json/issues#issue/43
but I'm getting the same thing with with rake using ruby 1.8.7-p249 and json-1.4.3
updated to json and json_pure 1.4.6 and still am getting the messages with rake
This is just a warning which is caused by some software (rails, autotest) ignoring ruby's require semantics, which only is supposed to load each required ruby file once, and instead reloading a required file many times. This patch should silence the warnings: flori/json@2c0f8d2c9b15a33b8d10ffcb1959aef54d320b57
Maybe you want to try it?
flori, the patch worked for me. http://github.com/flori/json/issues/labels/duplicate#issue/44/comment/414682 Thanks, and I look forward to a new gem :)
Nice, thanks, works for me too. Hope that's included in the new gem.
+1 for a new gem with this patch :-)
highly annoying, would love to see this fixed... :)
Also pesky for me. +1 on a the patch/gem bump asap.
Agreed. Bump the gem up please.
Please bump…I hate clutter…
+1 also find it very annoying
+1 still having issues with it...
can we please have a new version released with this solution as it's already been patched :)
Latest gem released was before this patch was even written, so no. https://rubygems.org/gems/json/versions
+1 for bump
Please release a gem. Please.
I figured out a workaround.
put this in your Gemfile: gem 'json_pure', "1.4.6a", :git => "git://github.com/flori/json.git", :ref => "2c0f8d"
That should be enough to fix it. I did mess around a hell of a lot with Gemfile.lock, but I'm pretty sure that all got overwritten and fixed up.
Heroku accepted it too and my app launched. I'm only starting out so I haven't got any tests to run yet. Let me know if you think this workaround will cause any problems.
To make heroku happy from the command line, you ALSO need to: $ gem install json_pure this will of course, put the broken version in your gemset, but apparently this is somehow what you need. I no longer get any error messages with everything setup this way. Just found this out when one of my collaborators hit a snag.
So, make sure you have both!
Also, I should note, I am using rvm
+1. I was also bitch slapped by this issue.