[Fedora-packaging] Ruby vs. JRuby - alternatives or not?

Toshio Kuratomi a.badger at gmail.com
Mon Jan 7 19:10:49 UTC 2013


On Mon, Jan 07, 2013 at 06:23:34AM -0500, Bohuslav Kabrda wrote:
> Hi all,
> as I'm working on packaging new JRuby for F19, I've started thinking about approach to coexistence of JRuby and cRuby - and I'd like to hear some opinions on that.
> On the first look, cRuby and JRuby seem to be an appropriate candidates for using alternatives (which solves the problem of automatically generated dependencies from shebangs and switching interpreters by root). But - thinking of it further, I'm not sure whether cRuby and JRuby are alternatives. Reasons:
> 
> 1. extension gems - there are gems with extensions
> a) only for cRuby
> b) only for JRuby
> c) for both implementations.
> Obviously, most of the cRuby-only extension gems are only usable with cRuby and vice versa for JRuby (exceptions are gems that contain pure Ruby fallback when extension cannot be loaded). For these extension gems, cRuby and JRuby are not alternatives, AFAICS.
> 2. pure Ruby gems using cRuby specific functions - some Ruby functions, for example fork(), cannot be used on JRuby, because JRuby doesn't support fork() - so if a gem uses fork, it only works on cRuby.
> 
> So cRuby and JRuby are mostly alternatives, but not completely. Therefore we (ruby-sig folks) came up with an idea that we call multiruby [1], which allows user (a user who knows what he's doing - for RPM packaged applications, packager will choose how to run them, possibly modifying shebangs) to choose the interpreter on invocation. The intepreter defaults to cRuby (also, compared to alternatives, this approach brings the benefit on non-root user being able to choose/switch the interpreter). In this scheme, /usr/bin/ruby would be a shell script that would route the commands either to /usr/bin/ruby-mri or /usr/bin/jruby. I know that this is no standard mechanism, but it doesn't break any expectations and brings some interesting functionality.
> 
> For example
> ruby foo.rb # behaves as it now does
> gem install foo # behaves as it now does
> ruby _jruby_ foo.rb # invokes foo.rb with jruby
> gem _jruby_ install foo # runs "gem install" with jruby
> 
> The inspiration for this approach is actually taken from RubyGems binary wrappers (as documented in [2]). The wrappers let you choose gem version on the wrapper execution, e.g. "rake _0.7.3_" will run rake 0.7.3, so the multiruby concept would not be anything strange to Ruby folks.
> Thoughts? Would this be an acceptable approach?
>
I don't think this would be acceptable.  But there might be specific use
cases that you want to solve that could be solved in similar ways.

As you say, alternatives definitely does not fit here.  Environment modules
may be able to fit some of the use cases, though.

I'm also not 100% against this idea.  Having a list of use cases would
probably be the place to start evaluating this.

-Toshio 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.fedoraproject.org/pipermail/packaging/attachments/20130107/00761f0b/attachment.sig>


More information about the packaging mailing list