Project

General

Profile

Bug #3140 ยป undo-prelude-paths.diff

tenderlovemaking (Aaron Patterson), 07/03/2010 03:47 AM

View differences:

gem_prelude.rb (working copy)
179 179

  
180 180
      GemPaths = {}
181 181
      GemVersions = {}
182
      GemLoadPaths = []
182 183

  
183 184
      def push_gem_version_on_load_path(gem_name, *version_requirements)
184 185
        if version_requirements.empty?
......
241 242
          end
242 243
        end
243 244

  
244
        require_paths = []
245

  
246 245
        GemPaths.each_value do |path|
247 246
          if File.exist?(file = File.join(path, ".require_paths")) then
248 247
            paths = File.read(file).split.map do |require_path|
249 248
              File.join path, require_path
250 249
            end
251 250

  
252
            require_paths.concat paths
251
            GemLoadPaths.concat paths
253 252
          else
254
            require_paths << file if File.exist?(file = File.join(path, "bin"))
255
            require_paths << file if File.exist?(file = File.join(path, "lib"))
253
            GemLoadPaths << file if File.exist?(file = File.join(path, "bin"))
254
            GemLoadPaths << file if File.exist?(file = File.join(path, "lib"))
256 255
          end
257 256
        end
258 257

  
259 258
        # "tag" the first require_path inserted into the $LOAD_PATH to enable
260 259
        # indexing correctly with rubygems proper when it inserts an explicitly
261 260
        # gem version
262
        unless require_paths.empty? then
263
          require_paths.first.instance_variable_set(:@gem_prelude_index, true)
261
        unless GemLoadPaths.empty? then
262
          GemLoadPaths.first.instance_variable_set(:@gem_prelude_index, true)
264 263
        end
265 264
        # gem directories must come after -I and ENV['RUBYLIB']
266
        $:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = require_paths
265
        $:[$:.index{|e|e.instance_variable_defined?(:@gem_prelude_index)}||-1,0] = GemLoadPaths
267 266
      end
268 267

  
269 268
      def const_missing(constant)
......
289 288

  
290 289
  begin
291 290
    Gem.push_all_highest_version_gems_on_load_path
292
    Gem::QuickLoader.fake_rubygems_as_loaded
293 291
  rescue Exception => e
294 292
    puts "Error loading gem paths on load path in gem_prelude"
295 293
    puts e
lib/rubygems.rb (working copy)
579 579
    $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
580 580
  end
581 581

  
582
  def self.remove_prelude_paths
583
    Gem::QuickLoader::GemLoadPaths.each do |path|
584
      $LOAD_PATH.delete(path)
585
    end
586
  end
587

  
582 588
  ##
583 589
  # The file name and line number of the caller of the caller of this method.
584 590

  
......
1098 1104

  
1099 1105
require 'rubygems/config_file'
1100 1106

  
1107
Gem.remove_prelude_paths
1108

  
1101 1109
##
1102 1110
# Enables the require hook for RubyGems.
1103 1111
#
1104
# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
1105
# constant at rubygems.rb load time.
1112
# We remove the paths prelude added, so we need custom require to get
1113
# any gems now.
1114
require 'rubygems/custom_require'
1106 1115

  
1107
require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'
1108

  
1109 1116
Gem.clear_paths
1110 1117

  
1111 1118
Gem.load_plugins