summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--ext/purelib.rb9
-rw-r--r--gem_prelude.rb33
3 files changed, 49 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index dbd1db2d27..ab4194d33a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Wed Jul 15 17:33:52 2009 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * ext/purelib.rb: translates a fake path to rubygems in $" into
+ an alternative in $: so that Kernel.#require does not load
+ more rubygems.rb.
+ Resolves many failures in test/rubygems/*.
+
+ * gem_prelude.rb (Gem.load_full_rubygems_library): supports case
+ the rubygems to load is not in $(rubylibprefix).
+ (Gem.path_to_full_rubygems_library): new method for the changes in
+ purelib.rb and Gem.load_full_rubygems_library.
+ (Gem.fake_rubygems_as_loaded): new method.
+
Wed Jul 15 16:29:35 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/Makefile.sub (LIBPATHFLAG): path is already quoted in mkmf.rb.
diff --git a/ext/purelib.rb b/ext/purelib.rb
index dbe514c34a..6418fd618d 100644
--- a/ext/purelib.rb
+++ b/ext/purelib.rb
@@ -6,5 +6,12 @@ $:.each_with_index {|path, index|
end
}
if nul
- $:[nul..-1] = ["."]
+ removed, $:[nul..-1] = $:[nul..-1], ["."]
+ if defined?(Gem::QuickLoader)
+ removed.each do |path|
+ # replaces a fake rubygems by gem_prelude.rb with an alternative path
+ index = $".index(File.join(path, 'rubygems.rb'))
+ $"[index] = Gem::QuickLoader.path_to_full_rubygems_library if index
+ end
+ end
end
diff --git a/gem_prelude.rb b/gem_prelude.rb
index 63c70653d0..e93f6045f9 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -235,18 +235,42 @@ if defined?(Gem) then
Gem::GEM_PRELUDE_METHODS.each do |method_name|
undef_method method_name
end
+ undef_method :const_missing
+ undef_method :method_missing
end
Kernel.module_eval do
undef_method :gem if method_defined? :gem
end
- $".delete File.join(Gem::ConfigMap[:rubylibprefix],
- Gem::ConfigMap[:ruby_version], 'rubygems.rb')
-
+ $".delete path_to_full_rubygems_library
+ $".each do |path|
+ if /#{Regexp.escape File::SEPARATOR}rubygems\.rb\z/ =~ path
+ raise LoadError, "another rubygems is already loaded from #{path}"
+ end
+ end
require 'rubygems'
end
+ def self.fake_rubygems_as_loaded
+ path = path_to_full_rubygems_library
+ $" << path unless $".include?(path)
+ end
+
+ def self.path_to_full_rubygems_library
+ installed_path = File.join(Gem::ConfigMap[:rubylibprefix], Gem::ConfigMap[:ruby_version])
+ if $:.include?(installed_path)
+ return File.join(installed_path, 'rubygems.rb')
+ else # e.g., on test-all
+ $:.each do |dir|
+ if File.exist?( path = File.join(dir, 'rubygems.rb') )
+ return path
+ end
+ end
+ raise LoadError, 'rubygems.rb'
+ end
+ end
+
GemPaths = {}
GemVersions = {}
@@ -367,8 +391,7 @@ if defined?(Gem) then
begin
Gem.push_all_highest_version_gems_on_load_path
- $" << File.join(Gem::ConfigMap[:rubylibprefix],
- Gem::ConfigMap[:ruby_version], "rubygems.rb")
+ Gem::QuickLoader.fake_rubygems_as_loaded
rescue Exception => e
puts "Error loading gem paths on load path in gem_prelude"
puts e