Permalink
Browse files

When trying to load Win32API, don't load full rubygems on non-windows…

… systems
  • Loading branch information...
1 parent 2004d59 commit 44f5d96abc03ee1589ea66c8d2b09324502864f6 @fabien committed Oct 11, 2008
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/minigems.rb
View
@@ -57,6 +57,8 @@ def require(path) # :nodoc:
rescue LoadError => load_error
if File.basename(path).match(Gem::MiniGems::INLINE_REGEXP)
return true # RubyInline dynamicly created .so/.bundle
+ elsif path == 'Win32API' && !Gem.win_platform?
+ raise load_error
elsif load_error.message =~ /#{Regexp.escape path}\z/
if !path.include?('/') && (match = Gem.find_name(path))
Gem.activate_gem_from_path(match.first)
@@ -267,7 +269,6 @@ def self.find_in_source_path(path)
# Find a file in the Gem source index - loads up the full rubygems!
def self.find_in_source_index(path)
- return nil if path == 'Win32API' && !Gem.win_platform?
show_notification "Switching from minigems to full rubygems..."
Gem.searcher.find(path)
end
@@ -305,7 +306,7 @@ def self.report_activate_error(gem)
# Load the full rubygems suite, at which point all minigems logic
# is being overridden, so all regular methods and classes are available.
def self.load_full_rubygems!
- show_notification 'Loaded full RubyGems'
+ show_notification 'Loaded full RubyGems instead of MiniGems'
if !caller.first.to_s.match(/`const_missing'$/) && (require_entry = get_require_caller(caller))
show_notification "A gem was possibly implicitly loaded from #{require_entry}"
end
@@ -315,6 +316,9 @@ class << self
undef_method method_name
end
end
+ # Fix some constants from throwing already initialized warnings
+ Gem.send(:remove_const, :RubyGemsPackageVersion)
+ Gem.send(:remove_const, :WIN_PATTERNS)
# Re-alias the 'require' method back to its original.
::Kernel.module_eval { alias_method :require, :gem_original_require }
require $LOADED_FEATURES.delete("rubygems.rb")

0 comments on commit 44f5d96

Please sign in to comment.