Index: gem_prelude.rb =================================================================== --- gem_prelude.rb (revision 28530) +++ gem_prelude.rb (working copy) @@ -136,9 +136,8 @@ @loaded_full_rubygems_library = false - def self.load_full_rubygems_library + def self.remove return if @loaded_full_rubygems_library - @loaded_full_rubygems_library = true class << Gem @@ -150,7 +149,11 @@ Kernel.module_eval do undef_method :gem if method_defined? :gem end + end + def self.load_full_rubygems_library + remove + $".delete path_to_full_rubygems_library if $".any? {|path| path.end_with?('/rubygems.rb')} raise LoadError, "another rubygems is already loaded from #{path}" @@ -179,6 +182,7 @@ GemPaths = {} GemVersions = {} + GemLoadPaths = [] def push_gem_version_on_load_path(gem_name, *version_requirements) if version_requirements.empty? @@ -241,29 +245,27 @@ end end - require_paths = [] - GemPaths.each_value do |path| if File.exist?(file = File.join(path, ".require_paths")) then paths = File.read(file).split.map do |require_path| File.join path, require_path end - require_paths.concat paths + GemLoadPaths.concat paths else - require_paths << file if File.exist?(file = File.join(path, "bin")) - require_paths << file if File.exist?(file = File.join(path, "lib")) + GemLoadPaths << file if File.exist?(file = File.join(path, "bin")) + GemLoadPaths << file if File.exist?(file = File.join(path, "lib")) end end # "tag" the first require_path inserted into the $LOAD_PATH to enable # indexing correctly with rubygems proper when it inserts an explicitly # gem version - unless require_paths.empty? then - require_paths.first.instance_variable_set(:@gem_prelude_index, true) + unless GemLoadPaths.empty? then + GemLoadPaths.first.instance_variable_set(:@gem_prelude_index, true) end # gem directories must come after -I and ENV['RUBYLIB'] - $:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = require_paths + $:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = GemLoadPaths end def const_missing(constant) @@ -289,7 +291,6 @@ begin Gem.push_all_highest_version_gems_on_load_path - Gem::QuickLoader.fake_rubygems_as_loaded rescue Exception => e puts "Error loading gem paths on load path in gem_prelude" puts e Index: lib/rubygems.rb =================================================================== --- lib/rubygems.rb (revision 28530) +++ lib/rubygems.rb (working copy) @@ -7,6 +7,11 @@ gem_disabled = !defined? Gem +unless gem_disabled + # Nuke the Quickloader stuff + Gem::QuickLoader.remove +end + require 'rubygems/defaults' require 'thread' require 'etc' @@ -579,6 +584,12 @@ $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index } end + def self.remove_prelude_paths + Gem::QuickLoader::GemLoadPaths.each do |path| + $LOAD_PATH.delete(path) + end + end + ## # The file name and line number of the caller of the caller of this method. @@ -1098,14 +1109,15 @@ require 'rubygems/config_file' +Gem.remove_prelude_paths + ## # Enables the require hook for RubyGems. # -# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem -# constant at rubygems.rb load time. +# We remove the paths prelude added, so we need custom require to get +# any gems now. +require 'rubygems/custom_require' -require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9' - Gem.clear_paths Gem.load_plugins Index: test/rubygems/test_gem_activation.rb =================================================================== --- test/rubygems/test_gem_activation.rb (revision 28530) +++ test/rubygems/test_gem_activation.rb (working copy) @@ -17,4 +17,4 @@ /can't activate rubygems-bug-child.*already activated rubygems-bug-child-1\.1/, [], bug3140) end -end if defined?(::Gem) +end if defined?(::Gem) and RUBY_VERSION < "1.9"