Project

General

Profile

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

evanphx (Evan Phoenix), 07/07/2010 03:40 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
        return if @loaded_full_rubygems_library
156

  
157
        remove
158

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

  
180 185
      GemPaths = {}
181 186
      GemVersions = {}
187
      GemLoadPaths = []
182 188

  
183 189
      def push_gem_version_on_load_path(gem_name, *version_requirements)
184 190
        if version_requirements.empty?
......
241 247
          end
242 248
        end
243 249

  
244
        require_paths = []
245

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

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

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

  
269 273
      def const_missing(constant)
......
289 293

  
290 294
  begin
291 295
    Gem.push_all_highest_version_gems_on_load_path
292
    Gem::QuickLoader.fake_rubygems_as_loaded
293 296
  rescue Exception => e
294 297
    puts "Error loading gem paths on load path in gem_prelude"
295 298
    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'
......
100 105
# -The RubyGems Team
101 106

  
102 107
module Gem
108
  if defined?(VERSION)
109
    puts caller
110
  end
103 111
  RubyGemsVersion = VERSION = '1.3.7'
104 112

  
105 113
  ##
......
579 587
    $LOAD_PATH.index { |p| p.instance_variable_defined? :@gem_prelude_index }
580 588
  end
581 589

  
590
  def self.remove_prelude_paths
591
    Gem::QuickLoader::GemLoadPaths.each do |path|
592
      $LOAD_PATH.delete(path)
593
    end
594
  end
595

  
582 596
  ##
583 597
  # The file name and line number of the caller of the caller of this method.
584 598

  
......
1098 1112

  
1099 1113
require 'rubygems/config_file'
1100 1114

  
1115
Gem.remove_prelude_paths
1116

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

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

  
1109 1124
Gem.clear_paths
1110 1125

  
1111 1126
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"