Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jRuby and Matz's Ruby on the same machine?

Tags:

linux

ruby

jruby

Is it possible to run jRuby and native ruby on the same machine?

For example installing rake or gem under both it find's Matz Ruby extensions /usr/bin/gem or /usr/bin/rake

The MRI gems and jruby gems are mixed up.

Is there any experience in that constellation?

like image 329
erhard Avatar asked Apr 13 '26 00:04

erhard


2 Answers

Take a look at RVM (Ruby Version Manager), which

...is a command line tool which allows us to easily install, manage and work with multiple ruby environments from interpreters to sets of gems.

like image 64
Mike Woodhouse Avatar answered Apr 15 '26 22:04

Mike Woodhouse


rvm on Unix and pik on Windows are the most typical ways to handle multiple ruby versions on the same machine.

But it can be done without any external tools easily too. Just install JRuby in any location you want and add JRuby's bin directory to your PATH. I typically add jruby at the end of the PATH, so that when I type gem or rake, C-Ruby is used, and when I want to use jruby I type:

jruby -S gem  -- to run gem with JRuby
jruby -S rake -- to run rake with JRuby
jruby -S spec -- to run rspec with JRuby

Alternatively, you could use jgem, jrake launcher scripts or aliases, if that's easier to type.

like image 35
Vladimir Sizikov Avatar answered Apr 15 '26 21:04

Vladimir Sizikov