It seems that JRuby requires the explicit require 'rubygems' to be able to use installed gems: $ /usr/bin/jruby -e "require 'gen'" :-1: no such file to load -- gen (LoadError) This specific gem is installed: $ ls /usr/share/jruby/lib/ruby/gems/1.8/gems/gen-0.41.0/ bin doc lib The gem can be found by explicitly requiring the rubygems package, $ /usr/bin/jruby -e "require 'rubygems'; require 'gen'" Which exits with no errors. Pure CRuby works without this requirement, so this bug may require changes to Ruby scripts run under JRuby. Reproducible: Always
Pure C ruby only works this way because of the RUBYOPT auto_gem hack we have in portage.
My vote would be to close this issue as WONTFIX. While the auto_gem hack is convenient, it also means that code won't be written portably (ie, using a require 'rubygems'). I guess that if JRuby has a similar mechanism we could add that, but... maybe we should consider removing our auto_gem hack from RUBYOPT altogether?
I don't see a problem with keeping the hack. JRuby includes its own modified copy of rubygems anyway. We didn't install this for a while but I've added it back because the modifications are important. rubygems wasn't actually working for JRuby at all when I tried it. I've created a separate site_ruby script for JRuby called gentoo.rb. It autoloads rubygems and also appends the regular Ruby site_ruby directory to the $LOAD_PATH. Check out 1.1.3 in java-overlay.
Moving to herd since nichoj left Gentoo.
gentoo.rb added in 1.2, I think we don't want automatic hacks