Skip to content

Commit dfdd4ac

Browse files
committed
Workaround being loaded alongside a different json_pure version
Fix: #646 Since both `json` and `json_pure` expose the same files, if the versions don't match, the native extension may be loaded with Ruby code that don't match and is incompatible. By doing the `require json/ext/generator/state` from C we ensure we're at least loading that. But this is a dirty workaround for the 2.7.x branch, we should find a better way to fully isolate the two gems.
1 parent 1f5e849 commit dfdd4ac

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

ext/json/ext/generator/generator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,4 +1521,6 @@ void Init_generator(void)
15211521
usascii_encindex = rb_usascii_encindex();
15221522
utf8_encindex = rb_utf8_encindex();
15231523
binary_encindex = rb_ascii8bit_encindex();
1524+
1525+
rb_require("json/ext/generator/state");
15241526
}

lib/json/ext.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ module Ext
1515
else
1616
require 'json/ext/parser'
1717
require 'json/ext/generator'
18-
unless RUBY_ENGINE == 'jruby'
19-
require 'json/ext/generator/state'
20-
end
2118
$DEBUG and warn "Using Ext extension for JSON."
2219
JSON.parser = Parser
2320
JSON.generator = Generator

0 commit comments

Comments
 (0)