summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-04-15 12:47:18 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-04-15 15:36:15 +0900
commit96741765d880b700933526a97a67345dfcd90c47 (patch)
tree565766c43e97b7deb93f2390af955465a85ee668 /lib/rubygems
parented149dbf46d1a8b16e6de9c3dbbcc10f72c9c019 (diff)
Merge the master branch of RubyGems
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4383
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/commands/update_command.rb24
-rw-r--r--lib/rubygems/defaults.rb2
-rw-r--r--lib/rubygems/indexer.rb2
-rw-r--r--lib/rubygems/installer.rb7
-rw-r--r--lib/rubygems/package.rb9
-rw-r--r--lib/rubygems/platform.rb10
-rw-r--r--lib/rubygems/remote_fetcher.rb11
-rw-r--r--lib/rubygems/security/trust_dir.rb1
-rw-r--r--lib/rubygems/test_utilities.rb2
9 files changed, 37 insertions, 31 deletions
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 41770d9805..91d93e398c 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -81,7 +81,7 @@ command to remove old versions.
def check_oldest_rubygems(version) # :nodoc:
if oldest_supported_version > version
- alert_error "rubygems #{version} is not supported. The oldest supported version is #{oldest_supported_version}"
+ alert_error "rubygems #{version} is not supported on #{RUBY_VERSION}. The oldest version supported by this ruby is #{oldest_supported_version}"
terminate_interaction 1
end
end
@@ -327,8 +327,26 @@ command to remove old versions.
private
+ #
+ # Oldest version we support downgrading to. This is the version that
+ # originally ships with the first patch version of each ruby, because we never
+ # test each ruby against older rubygems, so we can't really guarantee it
+ # works. Version list can be checked here: https://stdgems.org/rubygems
+ #
def oldest_supported_version
- # for Ruby 2.3
- @oldest_supported_version ||= Gem::Version.new("2.5.2")
+ @oldest_supported_version ||=
+ if Gem.ruby_version > Gem::Version.new("3.0.a")
+ Gem::Version.new("3.2.3")
+ elsif Gem.ruby_version > Gem::Version.new("2.7.a")
+ Gem::Version.new("3.1.2")
+ elsif Gem.ruby_version > Gem::Version.new("2.6.a")
+ Gem::Version.new("3.0.1")
+ elsif Gem.ruby_version > Gem::Version.new("2.5.a")
+ Gem::Version.new("2.7.3")
+ elsif Gem.ruby_version > Gem::Version.new("2.4.a")
+ Gem::Version.new("2.6.8")
+ else
+ Gem::Version.new("2.5.2")
+ end
end
end
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb
index 8aae67cd6b..e95bc06792 100644
--- a/lib/rubygems/defaults.rb
+++ b/lib/rubygems/defaults.rb
@@ -198,7 +198,7 @@ module Gem
def self.default_bindir
if defined? RUBY_FRAMEWORK_VERSION # mac framework support
- '/usr/bin'
+ '/usr/local/bin'
else # generic install
RbConfig::CONFIG['bindir']
end
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 31285ca962..e595459c87 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -136,7 +136,7 @@ class Gem::Indexer
say "Generating #{name} index"
Gem.time "Generated #{name} index" do
- open(file, 'wb') do |io|
+ File.open(file, 'wb') do |io|
specs = index.map do |*spec|
# We have to splat here because latest_specs is an array, while the
# others are hashes.
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 3ec6d743a2..7af51056b7 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -484,8 +484,11 @@ class Gem::Installer
bin_path = File.join gem_dir, spec.bindir, filename
unless File.exist? bin_path
- # TODO change this to a more useful warning
- warn "`#{bin_path}` does not exist, maybe `gem pristine #{spec.name}` will fix it?"
+ if File.symlink? bin_path
+ alert_warning "`#{bin_path}` is dangling symlink pointing to `#{File.readlink bin_path}`"
+ else
+ alert_warning "`#{bin_path}` does not exist, maybe `gem pristine #{spec.name}` will fix it?"
+ end
next
end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 0587cd212b..a4ae3e9ea5 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -252,14 +252,7 @@ class Gem::Package
stat = File.lstat file
if stat.symlink?
- target_path = File.readlink(file)
-
- unless target_path.start_with? '.'
- relative_dir = File.dirname(file).sub("#{Dir.pwd}/", '')
- target_path = File.join(relative_dir, target_path)
- end
-
- tar.add_symlink file, target_path, stat.mode
+ tar.add_symlink file, File.readlink(file), stat.mode
end
next unless stat.file?
diff --git a/lib/rubygems/platform.rb b/lib/rubygems/platform.rb
index e01d0494d6..fd1c0a62ac 100644
--- a/lib/rubygems/platform.rb
+++ b/lib/rubygems/platform.rb
@@ -66,7 +66,7 @@ class Gem::Platform
when String then
arch = arch.split '-'
- if arch.length > 2 and arch.last !~ /\d+(\.\d+)?$/ # reassemble x86-linux-{libc}
+ if arch.length > 2 and arch.last !~ /\d/ # reassemble x86-linux-gnu
extra = arch.pop
arch.last << "-#{extra}"
end
@@ -146,8 +146,7 @@ class Gem::Platform
##
# Does +other+ match this platform? Two platforms match if they have the
# same CPU, or either has a CPU of 'universal', they have the same OS, and
- # they have the same version, or either has no version (except for 'linux'
- # where the version is the libc name, with no version standing for 'gnu')
+ # they have the same version, or either has no version.
#
# Additionally, the platform will match if the local CPU is 'arm' and the
# other CPU starts with "arm" (for generic ARM family support).
@@ -163,10 +162,7 @@ class Gem::Platform
@os == other.os and
# version
- (
- (@os != 'linux' and (@version.nil? or other.version.nil?)) or
- @version == other.version
- )
+ (@version.nil? or other.version.nil? or @version == other.version)
end
##
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index a14c42f00e..e3d4bfbeba 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -51,6 +51,7 @@ class Gem::RemoteFetcher
class UnknownHostError < FetchError
end
+ deprecate_constant(:UnknownHostError)
@fetcher = nil
@@ -262,15 +263,9 @@ class Gem::RemoteFetcher
end
data
- rescue Timeout::Error
- raise UnknownHostError.new('timed out', uri)
- rescue IOError, SocketError, SystemCallError,
+ rescue Timeout::Error, IOError, SocketError, SystemCallError,
*(OpenSSL::SSL::SSLError if Gem::HAVE_OPENSSL) => e
- if e.message =~ /getaddrinfo/
- raise UnknownHostError.new('no such name', uri)
- else
- raise FetchError.new("#{e.class}: #{e}", uri)
- end
+ raise FetchError.new("#{e.class}: #{e}", uri)
end
def fetch_s3(uri, mtime = nil, head = false)
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index 1d93ceabd1..456947274c 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -104,6 +104,7 @@ class Gem::Security::TrustDir
# permissions.
def verify
+ require 'fileutils'
if File.exist? @dir
raise Gem::Security::Exception,
"trust directory #{@dir} is not a directory" unless
diff --git a/lib/rubygems/test_utilities.rb b/lib/rubygems/test_utilities.rb
index 1371ae9b14..08faef6578 100644
--- a/lib/rubygems/test_utilities.rb
+++ b/lib/rubygems/test_utilities.rb
@@ -76,7 +76,7 @@ class Gem::FakeFetcher
def cache_update_path(uri, path = nil, update = true)
if data = fetch_path(uri)
- open(path, 'wb') {|io| io.write data } if path and update
+ File.open(path, 'wb') {|io| io.write data } if path and update
data
else
Gem.read_binary(path) if path