Project

General

Profile

Bug #3140 ยป undo-prelude-loadpath-2.diff

evanphx (Evan Phoenix), 07/03/2010 08:45 AM

View differences:

gem_prelude.rb (working copy)
136 136

  
137 137
      @loaded_full_rubygems_library = false
138 138

  
139
      def self.load_full_rubygems_library
139
      def self.remove
140 140
        return if @loaded_full_rubygems_library
141

  
142 141
        @loaded_full_rubygems_library = true
143 142

  
144 143
        class << Gem
......
150 149
        Kernel.module_eval do
151 150
          undef_method :gem if method_defined? :gem
152 151
        end
152
      end
153 153

  
154
      def self.load_full_rubygems_library
155
        remove
156

  
154 157
        $".delete path_to_full_rubygems_library
155 158
        if $".any? {|path| path.end_with?('/rubygems.rb')}
156 159
          raise LoadError, "another rubygems is already loaded from #{path}"
......
179 182

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

  
183 187
      def push_gem_version_on_load_path(gem_name, *version_requirements)
184 188
        if version_requirements.empty?
......
241 245
          end
242 246
        end
243 247

  
244
        require_paths = []
245

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

  
252
            require_paths.concat paths
254
            GemLoadPaths.concat paths
253 255
          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"))
256
            GemLoadPaths << file if File.exist?(file = File.join(path, "bin"))
257
            GemLoadPaths << file if File.exist?(file = File.join(path, "lib"))
256 258
          end
257 259
        end
258 260

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

  
269 271
      def const_missing(constant)
......
289 291

  
290 292
  begin
291 293
    Gem.push_all_highest_version_gems_on_load_path
292
    Gem::QuickLoader.fake_rubygems_as_loaded
293 294
  rescue Exception => e
294 295
    puts "Error loading gem paths on load path in gem_prelude"
295 296
    puts e
lib/rubygems.rb (working copy)
7 7

  
8 8
gem_disabled = !defined? Gem
9 9

  
10
unless gem_disabled
11
  # Nuke the Quickloader stuff
12
  Gem::QuickLoader.remove
13
end
14

  
10 15
require 'rubygems/defaults'
11 16
require 'thread'
12 17
require 'etc'
......
579 584
    $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
580 585
  end
581 586

  
587
  def self.remove_prelude_paths
588
    Gem::QuickLoader::GemLoadPaths.each do |path|
589
      $LOAD_PATH.delete(path)
590
    end
591
  end
592

  
582 593
  ##
583 594
  # The file name and line number of the caller of the caller of this method.
584 595

  
......
1098 1109

  
1099 1110
require 'rubygems/config_file'
1100 1111

  
1112
Gem.remove_prelude_paths
1113

  
1101 1114
##
1102 1115
# Enables the require hook for RubyGems.
1103 1116
#
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.
1117
# We remove the paths prelude added, so we need custom require to get
1118
# any gems now.
1119
require 'rubygems/custom_require'
1106 1120

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

  
1109 1121
Gem.clear_paths
1110 1122

  
1111 1123
Gem.load_plugins
test/rubygems/test_gem_activation.rb (working copy)
17 17
                      /can't activate rubygems-bug-child.*already activated rubygems-bug-child-1\.1/, [],
18 18
                      bug3140)
19 19
  end
20
end if defined?(::Gem)
20
end if defined?(::Gem) and RUBY_VERSION < "1.9"