Closed djberg96 closed 6 months ago
Thank you for the report!
The gson
gem https://rubygems.org/gems/gson/versions/ https://github.com/avsej/gson.rb?tab=readme-ov-file only has releases with the "java" platform.
That platform should really be called the jruby platform, because it means such a gem depends on JRuby-specific APIs, for example
https://github.com/avsej/gson.rb/blob/7e2fc18be18da8fede00fac8bbc91e2d1a9fcd03/ext/gson_ext/GsonExtService.java#L20
So it is expected the gson gem cannot be installed on TruffleRuby, just like it cannot be installed on CRuby.
So
gem 'gson', '>= 0.6', platforms: [:jruby], require: false
should be the correct Gemfile line.
IOW, TruffleRuby does not support "java"-platform gems (which use e.g. import org.jruby.Ruby;
).
TruffleRuby supports "ruby"-platform gems (which are either pure-Ruby or native extensions, there is no difference in RubyGems if the gem is not precompiled). Many gems with native extensions work on TruffleRuby.
@eregon Got it, thanks. I didn't dig into the guts of gson, so didn't realize it was JRuby-specific.
truffleruby 24.0.0, like ruby 3.2.2, Oracle GraalVM Native [x86_64-darwin]
I was trying to update the multi_json gem to support java implementations in general (instead of only Jruby), and it defaults to using the 'gson' parser for JRuby. So I tried adding the platform but it fails.
Here's a simple example to demonstrate the issue:
With JRuby it works. With Truffleruby I get:
I'm thinking it's because JRuby defines
RUBY_PLATFORM
as "java" whereas Truffleruby is using the local platform, e.g. "x86_64-darwin20", but that's a guess.