Recommend
If you like my work with RVM, please recommend me *with a comment as to why you recommend me* on
Working With Rails – Thank You!
IRC
I am 'wayneeseguin' in #rvm on irc.freenode.net
If I do not respond right away, leave a message and I'll respond or leave you a memo when I am around.
Sponsors
$ rvm help # Documentation Index

'rvm ruby' - Running ruby commands with RVM

Given:

$ cat test.rb
  puts "patchlevel: #{RUBY_PATCHLEVEL}, release_date: #{RUBY_RELEASE_DATE}, ruby_version: #{RUBY_VERSION}, ruby_platform: #{RUBY_PLATFORM}"

$ rvm list

  ruby:

     ruby-1.8.6-p383 : ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.0.0]
     ruby-1.8.7-p174 : ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]
     ruby-1.9.1-head : ruby 1.9.2dev (2009-09-26 trunk 25103) [x86_64-darwin10.0.0]
  => ruby-1.9.1-p243 : ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]
     ruby-1.9.2-preview1 : ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-darwin10.0.0]

  jruby:

     jruby-1.3.1 : jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]
     jruby-1.4.0RC3 : jruby 1.4.0RC3 (ruby 1.8.7 patchlevel 174) (2009-09-30 80c263b) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]

  ree:

     ree-1.8.6-20090610 : ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin10.0.0] Ruby Enterprise Edition 20090610
     ree-1.8.7-20090928 : ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 20090928

  system:

     ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]

We can run the ruby program 'test.rb' against all versions of ruby installed and managed by RVM (NOTE: RVM does not manage 'system') as follows.

$ rvm do ruby test.rb

  jruby-1.3.1: jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]

  patchlevel: 287, release_date: 2009-06-15, ruby_version: 1.8.6, ruby_platform: java


  jruby-1.4.0RC3: jruby 1.4.0RC3 (ruby 1.8.7 patchlevel 174) (2009-09-30 80c263b) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_15) [x86_64-java]

  patchlevel: 174, release_date: 2009-09-30, ruby_version: 1.8.7, ruby_platform: java


  ree-1.8.6-20090610: ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin10.0.0] Ruby Enterprise Edition 20090610

  patchlevel: 287, release_date: 2008-08-11, ruby_version: 1.8.6, ruby_platform: i686-darwin10.0.0


  ree-1.8.7-20090928: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 20090928

  patchlevel: 174, release_date: 2009-06-12, ruby_version: 1.8.7, ruby_platform: i686-darwin10.0.0


  ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.0.0]

  patchlevel: 383, release_date: 2009-08-04, ruby_version: 1.8.6, ruby_platform: i686-darwin10.0.0


  ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]

  patchlevel: 174, release_date: 2009-06-12, ruby_version: 1.8.7, ruby_platform: i686-darwin10.0.0


  ruby-1.9.1-head: ruby 1.9.2dev (2009-09-26 trunk 25103) [x86_64-darwin10.0.0]

  patchlevel: -1, release_date: 2009-09-26, ruby_version: 1.9.2, ruby_platform: x86_64-darwin10.0.0


  ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]

  patchlevel: 243, release_date: 2009-07-16, ruby_version: 1.9.1, ruby_platform: i386-darwin10.0.0


  ruby-1.9.2-preview1: ruby 1.9.2dev (2009-07-18 trunk 24186) [i386-darwin10.0.0]

  patchlevel: -1, release_date: 2009-07-18, ruby_version: 1.9.2, ruby_platform: i386-darwin10.0.0

  ree-1.8.7-20090928: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 20090928

  patchlevel: 174, release_date: 2009-06-12, ruby_version: 1.8.7, ruby_platform: i686-darwin10.0.0

If we want we can also restrict to a subset of named top level selections:

$ rvm 1.9.1,1.8.6,1.8.7,jruby,ree do ruby test.rb

  ruby-1.9.1-p243: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10.0.0]

  patchlevel: 243, release_date: 2009-07-16, ruby_version: 1.9.1, ruby_platform: i386-darwin10.0.0

  ruby-1.8.6-p383: ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin10.0.0]

  patchlevel: 383, release_date: 2009-08-04, ruby_version: 1.8.6, ruby_platform: i686-darwin10.0.0

  ruby-1.8.7-p174: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]

  patchlevel: 174, release_date: 2009-06-12, ruby_version: 1.8.7, ruby_platform: i686-darwin10.0.0
RVM Documentation Index