5

I've seen this thread, but my question is maybe more basic:

Given that the response from the accepted answer in that thread[1] is for me, "/Users/username/.rvm/rubies/ruby-2.3.0/bin/ruby", how do I know if that's MRI, JRuby, etc? What would it look like if it were each of the other major interpreters?


[1] To save a few seconds, RbConfig.ruby

Arepo
  • 825
  • 1
  • 9
  • 23

2 Answers2

11

Nowadays, all mainstream Ruby implementations set the RUBY_ENGINE pseudo-constant. The values for the various implementations which I can remember off the top of my head are:

  • Rubinius: rbx
  • JRuby: jruby
  • TruffleRuby: truffleruby
  • Opal: opal
  • MRuby: mruby
  • YARV: confusingly, ruby
  • MRI: even more confusingly, also ruby
  • MagLev: maglev
  • IronRuby: ironruby
  • MacRuby: macruby
  • Topaz: topaz
Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653
  • 2
    Unraveling the MRI vs YARV thread a bit: It looks like _YARV replaced MRI_ over the course of 2007. The YARV codebase was merged into the MRI codebase, and ultimately the MRI implementation was replaced by the YARV implementation. Hence the confusion. Context here: https://archive.is/yCFB – Chris Betti Apr 11 '19 at 13:33
  • `ruby -e "puts RUBY_ENGINE"` – spyle Jun 06 '23 at 16:59
6

Based on the thread in the ruby-forum this works form me with Ruby:

irb(main):010:0> RbConfig.ruby
=> "/Users/<user>/.rbenv/versions/2.1.2/bin/ruby"
irb(main):011:0> RbConfig::CONFIG["RUBY_INSTALL_NAME"]
=> "ruby"

and with JRuby:

RbConfig.ruby
=> "/Users/<user>/.rbenv/versions/jruby-9.1.8.0/bin/jruby"
irb(main):008:0> RbConfig::CONFIG["RUBY_INSTALL_NAME"]
=> "jruby"

Depending on how you installed the different ruby versions you can either user the differences in the installation path (JRuby has a prefix) or use RbConfig::CONFIG["RUBY_INSTALL_NAME"].

To see all configuration keys type:

RbConfig::CONFIG.keys