summaryrefslogtreecommitdiff
path: root/gem_prelude.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 09:05:32 (GMT)
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 09:05:32 (GMT)
commit618cb2cab05ea0629c91dc5a5351fe3cfd6d0863 (patch)
treec3e74fd24a04258b6f39216a7b4d64373cf4dfcf /gem_prelude.rb
parentdc1327a6f2c779775e147fc3f020b0af114c4c19 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gem_prelude.rb')
-rw-r--r--gem_prelude.rb33
1 files changed, 28 insertions, 5 deletions
diff --git a/gem_prelude.rb b/gem_prelude.rb
index 63c7065..e93f604 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