summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 21:27:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-07 21:27:16 +0000
commit2b322524cdd0a5b6767eb72422cacc04b71902f2 (patch)
treedaf4c7bfef89cecedf5ae4ce4eb124a620697b4a /lib
parentc9331864f847a78550da88a780a5981bd283a6c7 (diff)
downloadbundler-2b322524cdd0a5b6767eb72422cacc04b71902f2.tar.gz
* gem_prelude.rb: load full rubygems at LoadError for activation
check. [ruby-core:29486] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb25
-rw-r--r--lib/rubygems/custom_require.rb17
2 files changed, 33 insertions, 9 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index d2e0f2cb5d..1dee815a15 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1020,8 +1020,6 @@ end
module Kernel
- undef gem if respond_to? :gem # defined in gem_prelude.rb on 1.9
-
##
# Use Kernel#gem to activate a specific version of +gem_name+.
#
@@ -1098,13 +1096,34 @@ end
require 'rubygems/config_file'
+class << Gem
+ verbose, debug = $VERBOSE, $DEBUG
+ $VERBOSE = $DEBUG = nil
+
+ ##
+ #
+ # Called from the custom_require to attempt to activate +path+
+ # Internal use only.
+
+ def try_activate(path) # :doc:
+ spec = Gem.searcher.find(path)
+ return false unless spec
+
+ Gem.activate(spec.name, "= #{spec.version}")
+ return true
+ end
+
+ensure
+ $VERBOSE, $DEBUG = verbose, debug
+end
+
##
# Enables the require hook for RubyGems.
#
# Ruby 1.9 allows --disable-gems, so we require it when we didn't detect a Gem
# constant at rubygems.rb load time.
-require 'rubygems/custom_require' if gem_disabled or RUBY_VERSION < '1.9'
+require 'rubygems/custom_require'
Gem.clear_paths
diff --git a/lib/rubygems/custom_require.rb b/lib/rubygems/custom_require.rb
index 43b3136b60..36e3c78911 100644
--- a/lib/rubygems/custom_require.rb
+++ b/lib/rubygems/custom_require.rb
@@ -4,8 +4,6 @@
# See LICENSE.txt for permissions.
#++
-require 'rubygems'
-
module Kernel
##
@@ -31,10 +29,17 @@ module Kernel
gem_original_require path
rescue LoadError => load_error
if load_error.message.end_with?(path) and
- spec = Gem.searcher.find(path) then
- Gem.activate(spec.name, "= #{spec.version}")
- gem_original_require path
+ begin
+ Gem.try_activate(path)
+ rescue Gem::LoadError => load_error
+ pat = "#{__FILE__}:#{__LINE__-2}:in "
+ bt = load_error.backtrace
+ num = bt.index {|e| e.start_with?(pat)} and bt.shift(num+2)
+ raise load_error
+ end
+ retry
else
+ load_error.backtrace.shift(2)
raise load_error
end
end
@@ -42,5 +47,5 @@ module Kernel
private :require
private :gem_original_require
-end
+end unless Kernel.private_method_defined?(:gem_original_require)