@@ -136,7 +136,7 @@ module QuickLoader
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
141
142
142
@loaded_full_rubygems_library = true
@@ -150,6 +150,12 @@ class << Gem
150
150
Kernel . module_eval do
151
151
undef_method :gem if method_defined? :gem
152
152
end
153
+ end
154
+
155
+ def self . load_full_rubygems_library
156
+ return if @loaded_full_rubygems_library
157
+
158
+ remove
153
159
154
160
$". delete path_to_full_rubygems_library
155
161
if $". any? { |path | path . end_with? ( '/rubygems.rb' ) }
@@ -179,6 +185,7 @@ def self.path_to_full_rubygems_library
179
185
180
186
GemPaths = { }
181
187
GemVersions = { }
188
+ GemLoadPaths = [ ]
182
189
183
190
def push_gem_version_on_load_path ( gem_name , *version_requirements )
184
191
if version_requirements . empty?
@@ -241,29 +248,27 @@ def push_all_highest_version_gems_on_load_path
241
248
end
242
249
end
243
250
244
- require_paths = [ ]
245
-
246
251
GemPaths . each_value do |path |
247
252
if File . exist? ( file = File . join ( path , ".require_paths" ) ) then
248
253
paths = File . read ( file ) . split . map do |require_path |
249
254
File . join path , require_path
250
255
end
251
256
252
- require_paths . concat paths
257
+ GemLoadPaths . concat paths
253
258
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" ) )
259
+ GemLoadPaths << file if File . exist? ( file = File . join ( path , "bin" ) )
260
+ GemLoadPaths << file if File . exist? ( file = File . join ( path , "lib" ) )
256
261
end
257
262
end
258
263
259
264
# "tag" the first require_path inserted into the $LOAD_PATH to enable
260
265
# indexing correctly with rubygems proper when it inserts an explicitly
261
266
# gem version
262
- unless require_paths . empty? then
263
- require_paths . first . instance_variable_set ( :@gem_prelude_index , true )
267
+ unless GemLoadPaths . empty? then
268
+ GemLoadPaths . first . instance_variable_set ( :@gem_prelude_index , true )
264
269
end
265
270
# gem directories must come after -I and ENV['RUBYLIB']
266
- $:[ $:. index { |e |e . instance_variable_defined? ( :@gem_prelude_index ) } ||-1 , 0 ] = require_paths
271
+ $:[ $:. index { |e |e . instance_variable_defined? ( :@gem_prelude_index ) } ||-1 , 0 ] = GemLoadPaths
267
272
end
268
273
269
274
def const_missing ( constant )
@@ -289,7 +294,6 @@ def method_missing(method, *args, &block)
289
294
290
295
begin
291
296
Gem . push_all_highest_version_gems_on_load_path
292
- Gem ::QuickLoader . fake_rubygems_as_loaded
293
297
rescue Exception => e
294
298
puts "Error loading gem paths on load path in gem_prelude"
295
299
puts e
0 commit comments