From: Stephen Bannasch Date: 2008-04-30T00:42:11+09:00 Subject: Re: determining what os is running In some of my work I'm writing code that works with different host OS systems AND runs on JRuby so I need to know both the RUBY_PLATFORM and the host OS. I'd love to know what people get on other Ruby VMs (1.8, 1.9. Rubinius) and other host OS's get as output running this script: require 'rbconfig' puts "Ruby Info:" puts " RUBY_PLATFORM: #{RUBY_PLATFORM}" puts " RUBY_VERSION: #{RUBY_VERSION}" puts " Config::CONFIG['RUBY_INSTALL_NAME']: #{Config::CONFIG['RUBY_INSTALL_NAME']}" puts " Config::CONFIG['host_os']: #{Config::CONFIG['host_os']}" Here's what I get on MacOS 10.5.2 using the Apple version of Ruby: Ruby Info: RUBY_PLATFORM: universal-darwin9.0 RUBY_VERSION: 1.8.6 Config::CONFIG['RUBY_INSTALL_NAME']: ruby Config::CONFIG['host_os']: darwin9.0 And here's JRuby version 1.1.1 running on MacOS 10.5.2 Ruby Info: RUBY_PLATFORM: java RUBY_VERSION: 1.8.6 Config::CONFIG['RUBY_INSTALL_NAME']: jruby Config::CONFIG['host_os']: darwin A subtlety with the JRuby VM is that the Ruby is running on both a Java OS (in effect) and a host OS and has strong capabilities for interacting with both systems. This doesn't usually matter for most Java programs because they often only deal with the host OS mediated through Java libraries -- but among many other things Ruby is a systems programming language and Ruby scripts written to support these tasks often have code written to operate differently on different host OS platforms. In these cases code written to also run on JRuby may need to take into account that it is running both in JRuby on Java AND on which host OS Windows, MacOS, etc.