# File lib/phusion_passenger/platform_info/ruby.rb, line 189 def self.rvm_ruby_string if in_rvm? # RVM used to export the necessary information through # environment variables, but doesn't always do that anymore # in the latest versions in order to fight env var pollution. # Scanning $LOAD_PATH seems to be the only way to obtain # the information. # Getting the RVM name of the Ruby interpreter ("ruby-1.9.2") # isn't so hard, we can extract it from the #ruby_executable # string. Getting the gemset name is a bit harder, so let's # try various strategies... # $GEM_HOME usually contains the gem set name. if GEM_HOME && GEM_HOME.include?("rvm/gems/") return File.basename(GEM_HOME) end # User somehow managed to nuke $GEM_HOME. Extract info # from $LOAD_PATH. matching_path = $LOAD_PATH.find_all do |item| item.include?("rvm/gems/") end if matching_path subpath = matching_path.to_s.gsub(/^.*rvm\/gems\//, '') result = subpath.split('/').first return result if result end # On Ruby 1.9, $LOAD_PATH does not contain any gem paths until # at least one gem has been required so the above can fail. # We're out of options now, we can't detect the gem set. # Raise an exception so that the user knows what's going on # instead of having things fail in obscure ways later. STDERR.puts "Unable to autodetect the currently active RVM gem " + "set name. Please contact this program's author for support." exit 1 end return nil end