Oj: Receiving warnings for two already initialized constants JSON::State and JSON::Parser

Created on 26 Apr 2017  路  8Comments  路  Source: ohler55/oj

I've started receiving these warnings about two already initialized constants JSON::State and JSON::Parser. These warnings seem to only be warnings, and I haven't ran into any actual issues yet. I'm on Rails 5.0.2 and Ruby 2.3.3.

/usr/local/bundle/gems/oj-3.0.1/lib/oj/json.rb:95: warning: already initialized constant JSON::State
/usr/local/bundle/gems/json-2.1.0/lib/json/common.rb:67: warning: previous definition of State was here
/usr/local/bundle/gems/oj-3.0.1/lib/oj/json.rb:97: warning: already initialized constant JSON::Parser
/usr/local/bundle/gems/json-2.1.0/lib/json/common.rb:29: warning: previous definition of Parser was here

Most helpful comment

Good to close everyone?

All 8 comments

They are warnings and they are being redefined by Oj which is what you expect when Oj is mimicking JSON. There is already some checking going on but maybe not enough. I take a look later today.

+1, thanks for taking care of it. On Rails 4.2.8 - Ruby 2.3.1 - OJ 3.0.1

The same warnings on Rails 5.0.2, Ruby 2.4.1, and oj 3.0.1

Just released 3.0.3 with a fix.

I installed 3.0.4 and can see the warnings:

$ rails c
/Users/frodsan/Code/frodsan/demo/.gs/gems/oj-3.0.4/lib/oj/json.rb:95: warning: already initialized constant JSON::State
/Users/frodsan/.rbenv/versions/2.4.1/lib/ruby/2.4.0/json/common.rb:67: warning: previous definition of State was here
/Users/frodsan/Code/frodsan/demo/.gs/gems/oj-3.0.4/lib/oj/json.rb:101: warning: already initialized constant JSON::Parser
/Users/frodsan/.rbenv/versions/2.4.1/lib/ruby/2.4.0/json/common.rb:29: warning: previous definition of Parser was here
Loading development environment (Rails 5.1.0)
>>

Another attempt with 3.0.5.

Fixed for Ruby 2.3.1 - Rails 4.2.8 - Oj 3.0.5.

Good to close everyone?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ohler55 picture ohler55  路  21Comments

paradox460 picture paradox460  路  8Comments

vincentwoo picture vincentwoo  路  14Comments

ericmwalsh picture ericmwalsh  路  25Comments

skliew picture skliew  路  6Comments