Load gems properly. Fixes [ruby-core:31377]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6e2850aa46
commit
6113a5add0
@ -1,3 +1,8 @@
|
|||||||
|
Wed Jul 21 15:22:17 2010 Evan Phoenix <evan@fallingsnow.net>
|
||||||
|
|
||||||
|
* lib/rubygems/custom_require.rb, gem_prelude.rb: Load code from
|
||||||
|
from gems properly.
|
||||||
|
|
||||||
Wed Jul 21 15:15:02 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed Jul 21 15:15:02 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* sprintf.c: add short documentation about named reference.
|
* sprintf.c: add short documentation about named reference.
|
||||||
|
@ -155,7 +155,7 @@ if defined?(Gem) then
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.load_full_rubygems_library
|
def self.load_full_rubygems_library
|
||||||
return if @loaded_full_rubygems_library
|
return false if @loaded_full_rubygems_library
|
||||||
|
|
||||||
remove
|
remove
|
||||||
|
|
||||||
@ -163,7 +163,10 @@ if defined?(Gem) then
|
|||||||
if $".any? {|path| path.end_with?('/rubygems.rb')}
|
if $".any? {|path| path.end_with?('/rubygems.rb')}
|
||||||
raise LoadError, "another rubygems is already loaded from #{path}"
|
raise LoadError, "another rubygems is already loaded from #{path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.path_to_full_rubygems_library
|
def self.path_to_full_rubygems_library
|
||||||
@ -200,11 +203,21 @@ if defined?(Gem) then
|
|||||||
extend QuickLoader
|
extend QuickLoader
|
||||||
|
|
||||||
def self.try_activate(path)
|
def self.try_activate(path)
|
||||||
# Just a stub to make sure rubygems is loaded
|
# This method is only hit when the custom require is hit the first time.
|
||||||
QuickLoader.load_full_rubygems_library
|
# So we go off and dutifully load all of rubygems and retry the call
|
||||||
|
# to Gem.try_activate. We retry because full rubygems replaces this
|
||||||
|
# method with one that actually tries to find a gem for +path+ and load it.
|
||||||
|
#
|
||||||
|
# This is conditional because in the course of loading rubygems, the custom
|
||||||
|
# require will call back into here before all of rubygems is loaded. So
|
||||||
|
# we must not always retry the call. We only redo the call when
|
||||||
|
# load_full_rubygems_library returns true, which it only does the first
|
||||||
|
# time it's called.
|
||||||
|
#
|
||||||
|
if QuickLoader.load_full_rubygems_library
|
||||||
|
return Gem.try_activate(path)
|
||||||
|
end
|
||||||
|
|
||||||
# But doesn't actually load anything, so that custom_require
|
|
||||||
# can always call try_activate and get some decent response
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -29,7 +29,9 @@ module Kernel
|
|||||||
gem_original_require path
|
gem_original_require path
|
||||||
rescue LoadError => load_error
|
rescue LoadError => load_error
|
||||||
if load_error.message.end_with?(path)
|
if load_error.message.end_with?(path)
|
||||||
return true if Gem.try_activate(path)
|
if Gem.try_activate(path)
|
||||||
|
return gem_original_require(path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
raise load_error
|
raise load_error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user