aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems')
-rwxr-xr-xlib/rubygems/core_ext/kernel_require.rb13
-rw-r--r--lib/rubygems/dependency.rb13
-rw-r--r--lib/rubygems/installer.rb5
-rw-r--r--lib/rubygems/installer_test_case.rb2
-rw-r--r--lib/rubygems/resolver.rb4
-rw-r--r--lib/rubygems/test_case.rb11
6 files changed, 32 insertions, 16 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb
index 6c00f3fd9b..99093a1338 100755
--- a/lib/rubygems/core_ext/kernel_require.rb
+++ b/lib/rubygems/core_ext/kernel_require.rb
@@ -121,14 +121,17 @@ module Kernel
rescue LoadError => load_error
RUBYGEMS_ACTIVATION_MONITOR.enter
- if load_error.message.start_with?("Could not find") or
- (load_error.message.end_with?(path) and Gem.try_activate(path)) then
- RUBYGEMS_ACTIVATION_MONITOR.exit
- return gem_original_require(path)
- else
+ begin
+ if load_error.message.start_with?("Could not find") or
+ (load_error.message.end_with?(path) and Gem.try_activate(path)) then
+ require_again = true
+ end
+ ensure
RUBYGEMS_ACTIVATION_MONITOR.exit
end
+ return gem_original_require(path) if require_again
+
raise load_error
end
diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb
index bf24b6e724..b7aea4692b 100644
--- a/lib/rubygems/dependency.rb
+++ b/lib/rubygems/dependency.rb
@@ -286,7 +286,9 @@ class Gem::Dependency
}
end
- matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
+ # `stubs_for` returns oldest first, but `matching_specs` is supposed to
+ # return newest first, so just reverse the list
+ matches.reverse
end
##
@@ -302,14 +304,13 @@ class Gem::Dependency
# TODO: check Gem.activated_spec[self.name] in case matches falls outside
if matches.empty? then
- specs = Gem::Specification.find_all { |s|
- s.name == name
- }.map { |x| x.full_name }
+ specs = Gem::Specification.stubs_for name
if specs.empty?
- total = Gem::Specification.to_a.size
+ total = Gem::Specification.stubs.size
msg = "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n".dup
else
+ specs = specs.map(&:full_name)
msg = "Could not find '#{name}' (#{requirement}) - did find: [#{specs.join ','}]\n".dup
end
msg << "Checked in 'GEM_PATH=#{Gem.path.join(File::PATH_SEPARATOR)}', execute `gem env` for more information"
@@ -334,6 +335,6 @@ class Gem::Dependency
matches.delete_if { |spec| spec.nil? || spec.version.prerelease? } unless prerelease?
- matches.last
+ matches.first
end
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 85358e0d1a..a88d393336 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -216,7 +216,8 @@ class Gem::Installer
existing = io.read.slice(%r{
^(
gem \s |
- load \s Gem\.bin_path\(
+ load \s Gem\.bin_path\( |
+ load \s Gem\.activate_bin_path\(
)
(['"])(.*?)(\2),
}x, 3)
@@ -719,7 +720,7 @@ if ARGV.first
end
end
-load Gem.bin_path('#{spec.name}', '#{bin_file_name}', version)
+load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
TEXT
end
diff --git a/lib/rubygems/installer_test_case.rb b/lib/rubygems/installer_test_case.rb
index bdefedc9f6..eccd5711c2 100644
--- a/lib/rubygems/installer_test_case.rb
+++ b/lib/rubygems/installer_test_case.rb
@@ -170,6 +170,8 @@ class Gem::InstallerTestCase < Gem::TestCase
EOF
end
+ yield @spec if block_given?
+
use_ui ui do
FileUtils.rm_f @gem
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb
index 3a406d0444..50a547e1be 100644
--- a/lib/rubygems/resolver.rb
+++ b/lib/rubygems/resolver.rb
@@ -193,7 +193,7 @@ class Gem::Resolver
conflict = e.conflicts.values.first
raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)
ensure
- @output.close if @output and !debug?
+ @output.close if defined?(@output) and !debug?
end
##
@@ -233,7 +233,7 @@ class Gem::Resolver
exc.errors = @set.errors
raise exc
end
- possibles.sort_by { |s| [s.source, s.version, s.platform.to_s == Gem::Platform.local.to_s ? 1 : 0] }.
+ possibles.sort_by { |s| [s.source, s.version, Gem::Platform.local =~ s.platform ? 1 : 0] }.
map { |s| ActivationRequest.new s, dependency, [] }
end
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index bde4ed6713..f7ae97cd8d 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -223,6 +223,10 @@ class Gem::TestCase < MiniTest::Unit::TestCase
@orig_gem_spec_cache = ENV['GEM_SPEC_CACHE']
@orig_rubygems_gemdeps = ENV['RUBYGEMS_GEMDEPS']
@orig_rubygems_host = ENV['RUBYGEMS_HOST']
+ ENV.keys.find_all { |k| k.start_with?('GEM_REQUIREMENT_') }.each do |k|
+ ENV.delete k
+ end
+ @orig_gem_env_requirements = ENV.to_hash
ENV['GEM_VENDOR'] = nil
@@ -288,6 +292,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
ENV['HOME'] = @userhome
Gem.instance_variable_set :@user_home, nil
Gem.instance_variable_set :@gemdeps, nil
+ Gem.instance_variable_set :@env_requirements_by_name, nil
Gem.send :remove_instance_variable, :@ruby_version if
Gem.instance_variables.include? :@ruby_version
@@ -379,6 +384,11 @@ class Gem::TestCase < MiniTest::Unit::TestCase
FileUtils.rm_rf @tempdir unless ENV['KEEP_FILES']
+ ENV.clear
+ @orig_gem_env_requirements.each do |k,v|
+ ENV[k] = v
+ end
+
ENV['GEM_HOME'] = @orig_gem_home
ENV['GEM_PATH'] = @orig_gem_path
ENV['GEM_VENDOR'] = @orig_gem_vendor
@@ -1504,4 +1514,3 @@ tmpdirs << (ENV['GEM_PATH'] = Dir.mktmpdir("path"))
pid = $$
END {tmpdirs.each {|dir| Dir.rmdir(dir)} if $$ == pid}
Gem.clear_paths
-