From: "jonforums (Jon Forums)" Date: 2012-06-12T23:15:42+09:00 Subject: [ruby-core:45585] [Backport92 - Backport #6578] (Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level Issue #6578 has been updated by jonforums (Jon Forums). > By the way, I haven't checked whether this works on Ruby 1.9.3... I am (sadly) stuck developing on Windows and can't install multiple versions of Ruby without RVM. Be happy...test with multiple roobies on windows using pik: https://github.com/vertiginous/pik C:\Users\Jon>pik ls 167: jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client ... 187: ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-mingw32] 193: ruby 1.9.3p125 (2012-02-16) [i386-mingw32] * 193: ruby 1.9.3p235 (2012-06-05 revision 35917) [i386-mingw32] 193: tcs-ruby 1.9.3p231 (2012-05-25, TCS patched 2012-05-27) [i386-mingw32] 200: ruby 2.0.0dev (2012-06-11 trunk 36028) [i386-mingw32] C:\Users\Jon>pik ruby -e "puts 'hi ruby'" jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) Client VM 1.7.0_04) [Windows 7-x86-java] hi ruby ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-mingw32] hi ruby ruby 1.9.3p125 (2012-02-16) [i386-mingw32] hi ruby ruby 1.9.3p235 (2012-06-05 revision 35917) [i386-mingw32] hi ruby tcs-ruby 1.9.3p231 (2012-05-25, TCS patched 2012-05-27) [i386-mingw32] hi ruby ruby 2.0.0dev (2012-06-11 trunk 36028) [i386-mingw32] hi ruby ---------------------------------------- Backport #6578: (Ruby 1.9.2-p290) Built-in JSON library fails if "Parser" is defined at top level https://bugs.ruby-lang.org/issues/6578#change-27182 Author: alexdowad (Alex Dowad) Status: Open Priority: Normal Assignee: Category: Target version: To duplicate: class Parser end require 'json' The culprit is line 27 of common/json.rb: remove_const :Parser if const_defined? :Parser #const_defined? returns true even if Parser is defined at the top level, not within JSON. In this case, #remove_const fails with an exception. A possible fix would be: remove_const :Parser if constants.include? :Parser -- http://bugs.ruby-lang.org/