<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -286,30 +286,30 @@ subdir 'test' do
 	
 	desc &quot;Run unit tests for the Ruby libraries&quot;
 	task 'test:ruby' =&gt; [:native_support] do
-		if PlatformInfo::RSPEC.nil?
+		if PlatformInfo.rspec.nil?
 			abort &quot;RSpec is not installed for Ruby interpreter '#{PlatformInfo::RUBY}'. Please install it.&quot;
 		else
-			ruby &quot;#{PlatformInfo::RSPEC} -c -f s ruby/*.rb ruby/*/*.rb&quot;
+			ruby &quot;#{PlatformInfo.rspec} -c -f s ruby/*.rb ruby/*/*.rb&quot;
 		end
 	end
 	
 	task 'test:rcov' =&gt; [:native_support] do
-		if PlatformInfo::RSPEC.nil?
+		if PlatformInfo.rspec.nil?
 			abort &quot;RSpec is not installed for Ruby interpreter '#{PlatformInfo::RUBY}'. Please install it.&quot;
 		else
 			sh &quot;rcov&quot;, &quot;--exclude&quot;,
 				&quot;lib\/spec,\/spec$,_spec\.rb$,support\/,platform_info,integration_tests&quot;,
-				PlatformInfo::RSPEC, &quot;--&quot;, &quot;-c&quot;, &quot;-f&quot;, &quot;s&quot;,
+				PlatformInfo.rspec, &quot;--&quot;, &quot;-c&quot;, &quot;-f&quot;, &quot;s&quot;,
 				*Dir[&quot;ruby/*.rb&quot;, &quot;ruby/*/*.rb&quot;, &quot;integration_tests.rb&quot;]
 		end
 	end
 	
 	desc &quot;Run integration tests&quot;
 	task 'test:integration' =&gt; [:apache2, :native_support] do
-		if PlatformInfo::RSPEC.nil?
+		if PlatformInfo.rspec.nil?
 			abort &quot;RSpec is not installed for Ruby interpreter '#{PlatformInfo::RUBY}'. Please install it.&quot;
 		else
-			ruby &quot;#{PlatformInfo::RSPEC} -c -f s integration_tests.rb&quot;
+			ruby &quot;#{PlatformInfo.rspec} -c -f s integration_tests.rb&quot;
 		end
 	end
 	</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -200,11 +200,11 @@ private
 		color_puts '&lt;banner&gt;Compiling and installing Apache 2 module...&lt;/banner&gt;'
 		puts &quot;cd #{PASSENGER_ROOT}&quot;
 		if ENV['TRACE']
-			puts &quot;#{RUBY} -S #{RAKE} --trace clean apache2&quot;
-			return system(RUBY, &quot;-S&quot;, RAKE, &quot;--trace&quot;, &quot;clean&quot;, &quot;apache2&quot;)
+			puts &quot;#{RUBY} -S #{PlatformInfo.rake} --trace clean apache2&quot;
+			return system(RUBY, &quot;-S&quot;, PlatformInfo.rake, &quot;--trace&quot;, &quot;clean&quot;, &quot;apache2&quot;)
 		else
-			puts &quot;#{RUBY} -S #{RAKE} clean apache2&quot;
-			return system(RUBY, &quot;-S&quot;, RAKE, &quot;clean&quot;, &quot;apache2&quot;)
+			puts &quot;#{RUBY} -S #{PlatformInfo.rake} clean apache2&quot;
+			return system(RUBY, &quot;-S&quot;, PlatformInfo.rake, &quot;clean&quot;, &quot;apache2&quot;)
 		end
 	end
 	</diff>
      <filename>bin/passenger-install-apache2-module</filename>
    </modified>
    <modified>
      <diff>@@ -190,11 +190,10 @@ module Dependencies # :nodoc: all
 	Rake = Dependency.new do |dep|
 		dep.name = &quot;Rake&quot;
 		dep.define_checker do |result|
-			rake = PlatformInfo::RAKE
-			if File.executable?(rake)
-				result.found(rake)
-			else
+			if PlatformInfo.rake.nil?
 				result.not_found
+			else
+				result.found(PlatformInfo.rake)
 			end
 		end
 		dep.website = &quot;http://rake.rubyforge.org/&quot;</diff>
      <filename>lib/phusion_passenger/dependencies.rb</filename>
    </modified>
    <modified>
      <diff>@@ -88,7 +88,20 @@ private
 		if File.file?(filename) &amp;&amp; File.executable?(filename)
 			return filename
 		else
-			return nil
+			# RubyGems might put binaries in a directory other
+			# than Ruby's bindir. Debian packaged RubyGems and
+			# DebGem packaged RubyGems are the prime examples.
+			begin
+				require 'rubygems' unless defined?(Gem)
+				filename = Gem.bindir + &quot;/#{name}&quot;
+				if File.file?(filename) &amp;&amp; File.executable?(filename)
+					return filename
+				else
+					return nil
+				end
+			rescue LoadError
+				return nil
+			end
 		end
 	end
 	
@@ -157,10 +170,8 @@ private
 public
 	# The absolute path to the current Ruby interpreter.
 	RUBY = Config::CONFIG['bindir'] + '/' + Config::CONFIG['RUBY_INSTALL_NAME'] + Config::CONFIG['EXEEXT']
-	# The correct 'gem', 'rake' and 'spec' commands for this Ruby interpreter.
+	# The correct 'gem' command for this Ruby interpreter.
 	GEM = locate_ruby_executable('gem')
-	RAKE = locate_ruby_executable('rake')
-	RSPEC = locate_ruby_executable('spec')
 	
 	# Check whether the specified command is in $PATH, and return its
 	# absolute filename. Returns nil if the command is not found.
@@ -181,6 +192,22 @@ public
 	################ Programs ################
 	
 	
+	# Returns the absolute path to the Rake executable that
+	# belongs to the current Ruby interpreter. Returns nil if it
+	# doesn't exist.
+	def self.rake
+		return locate_ruby_executable('rake')
+	end
+	memoize :rake
+	
+	# Returns the absolute path to the RSpec runner program that
+	# belongs to the current Ruby interpreter. Returns nil if it
+	# doesn't exist.
+	def self.rspec
+		return locate_ruby_executable('spec')
+	end
+	memoize :rspec
+	
 	# The absolute path to the 'apxs' or 'apxs2' executable, or nil if not found.
 	def self.apxs2
 		if env_defined?(&quot;APXS2&quot;)</diff>
      <filename>lib/phusion_passenger/platform_info.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>01c0f89a805878f741cb871de30d30b563c4a26d</id>
    </parent>
  </parents>
  <author>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </author>
  <url>http://github.com/FooBarWidget/passenger/commit/2b958c3e2e10ddf68502461ba7f00345341ad2f9</url>
  <id>2b958c3e2e10ddf68502461ba7f00345341ad2f9</id>
  <committed-date>2009-03-13T11:09:56-07:00</committed-date>
  <authored-date>2009-03-13T11:09:56-07:00</authored-date>
  <message>Also look in Gem.bindir for Ruby executables, because Gem.bindir may be different from Ruby's bindir.</message>
  <tree>0d091cc3d90398d11e851271e6230c6e1a5bcc0a</tree>
  <committer>
    <name>Hongli Lai (Phusion)</name>
    <email>hongli@phusion.nl</email>
  </committer>
</commit>
