json icon indicating copy to clipboard operation
json copied to clipboard

Already initialized constants on Ruby 1.9.2

Open stevenheidel opened this issue 16 years ago • 25 comments

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.

stevenheidel avatar Aug 25 '10 22:08 stevenheidel

This is a duplicate of http://github.com/flori/json/issues#issue/43

flori avatar Aug 26 '10 06:08 flori

but I'm getting the same thing with with rake using ruby 1.8.7-p249 and json-1.4.3

dgoldie avatar Aug 31 '10 20:08 dgoldie

updated to json and json_pure 1.4.6 and still am getting the messages with rake

dgoldie avatar Aug 31 '10 20:08 dgoldie

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 avatar Sep 18 '10 10:09 flori

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 :)

jeberly avatar Sep 29 '10 01:09 jeberly

Nice, thanks, works for me too. Hope that's included in the new gem.

mattheworiordan avatar Sep 30 '10 13:09 mattheworiordan

+1 for a new gem with this patch :-)

thibaudgg avatar Oct 07 '10 10:10 thibaudgg

highly annoying, would love to see this fixed... :)

dvdplm avatar Oct 07 '10 15:10 dvdplm

Also pesky for me. +1 on a the patch/gem bump asap.

maxmmurphy avatar Oct 07 '10 16:10 maxmmurphy

Agreed. Bump the gem up please.

erskingardner avatar Oct 08 '10 07:10 erskingardner

Please bump…I hate clutter…

miwillhite avatar Oct 08 '10 22:10 miwillhite

+1 also find it very annoying

bradrobertson avatar Oct 13 '10 01:10 bradrobertson

+1 still having issues with it...

sscirrus avatar Oct 13 '10 22:10 sscirrus

can we please have a new version released with this solution as it's already been patched :)

parndt avatar Oct 26 '10 22:10 parndt

Latest gem released was before this patch was even written, so no. https://rubygems.org/gems/json/versions

parndt avatar Oct 26 '10 23:10 parndt

+1 for bump

felixandersen avatar Oct 29 '10 18:10 felixandersen

Please release a gem. Please.

stevenheidel avatar Nov 16 '10 22:11 stevenheidel

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.

bensand avatar Nov 20 '10 10:11 bensand

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

bensand avatar Nov 21 '10 05:11 bensand

+1. I was also bitch slapped by this issue.

mejibyte avatar Nov 25 '10 03:11 mejibyte