def dump_ruby_environment
if dir = ENV['PASSENGER_DEBUG_DIR']
File.open("#{dir}/ruby_info", "w") do |f|
f.puts "RUBY_VERSION = #{RUBY_VERSION}"
f.puts "RUBY_PLATFORM = #{RUBY_PLATFORM}"
f.puts "RUBY_ENGINE = #{defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'nil'}"
end
File.open("#{dir}/load_path", "wb") do |f|
$LOAD_PATH.each do |path|
f.puts path
end
end
File.open("#{dir}/loaded_libs", "wb") do |f|
$LOADED_FEATURES.each do |filename|
f.puts filename
end
end
require 'rbconfig' if !defined?(RbConfig::CONFIG)
File.open("#{dir}/rbconfig", "wb") do |f|
RbConfig::CONFIG.each_pair do |key, value|
f.puts "#{key} = #{value}"
end
end
begin
require 'rubygems' if !defined?(Gem)
rescue LoadError
end
if defined?(Gem)
File.open("#{dir}/ruby_info", "a") do |f|
f.puts "RubyGems version = #{Gem::VERSION}"
if Gem.respond_to?(:path)
f.puts "RubyGems paths = #{Gem.path.inspect}"
else
f.puts "RubyGems paths = unknown; incompatible RubyGems API"
end
end
File.open("#{dir}/activated_gems", "wb") do |f|
if Gem.respond_to?(:loaded_specs)
Gem.loaded_specs.each_pair do |name, spec|
f.puts "#{name} => #{spec.version}"
end
else
f.puts "Unable to query this information; incompatible RubyGems API."
end
end
end
end
rescue SystemCallError
end