[Rubygems-developers] Is a "pure" platform needed?

Tony Arcieri tony.arcieri at medioh.com
Tue Aug 31 21:48:32 EDT 2010

Context for the problem is here:


Resque used to be broken on JRuby because the json gem used to only work on
MRI. After a lot of complaining Charlie from the JRuby team got commit
access, and patches from Evan of Rubinius got accepted. Now everything is
dandy, except on IronRuby. The JSON gem only works on MRI, YARV, JRuby, and
Rubinius, NOT on IronRuby.

But IronRuby isn't the only concern. What about MagLev? Or BlueRuby? There
are a lot of alternative Ruby implementations out there which don't provide
the MRI C extension API. Using a gem like "json" on these platforms is
broken-by-default, since the "default" platform is called "ruby", and the
"ruby" platform seems to assume out-of-the-gate that you can install C
extensions, when in fact the opposite is true. Support for MRI C extensions
is almost a rarity when it comes to the totality of Ruby implementations
available, with the only implementations supporting them are MRI, YARV,
Rubinius, and JRuby to a limited extent.

For these platforms, there's the "json_pure" gem. This gem exposes (in
theory!) the same API as the json gem, but is implemented in pure Ruby.
However, when trying to specify dependencies, which gem does one pick?
json_pure is the least common denominator, but as has been seen in practice
in Resque, compatibility issues can arise:


My immediate proposed solution for the resque/json scenario is:

MRI/YARV/Rubinius: use the C extension
JRuby: use the Java version
IronRuby: package json_pure as "json"
Other platforms: you're screwed

The question is, how can we solve this problem for not only IronRuby, but
all other Ruby platforms without C extension support? (e.g. BlueRuby,
MagLev). I would propose Ruby implementers add some check to their
implementation RubyGems can use to determine if MRI-style C extensions are
supported, and if they are not supported for this platform, the "pure"
implementation be used in lieu of the "ruby" implementation.

Tony Arcieri
Medioh! A Kudelski Brand

More information about the Rubygems-developers mailing list