diff options
| author | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2024-10-17 16:12:09 +0900 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2024-10-17 08:55:01 -0700 |
| commit | 494fcc507b3bc218beb6638d33476b647d55969e (patch) | |
| tree | d685c173f72dd5cc3be063d0fe2fa5ee958d99f0 | |
| parent | d03e4228aaeb1bdd3432119e683aa259b028c5b2 (diff) | |
Merge RubyGems-3.5.22 and Bundler-2.5.22
39 files changed, 371 insertions, 202 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index aad8759652..24a9a7683a 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -589,21 +589,21 @@ module Bundler trace_line = backtrace.find {|l| l.include?(dsl_path) } || trace_line return m unless trace_line - line_numer = trace_line.split(":")[1].to_i - 1 - return m unless line_numer + line_number = trace_line.split(":")[1].to_i - 1 + return m unless line_number lines = contents.lines.to_a indent = " # " indicator = indent.tr("#", ">") - first_line = line_numer.zero? - last_line = (line_numer == (lines.count - 1)) + first_line = line_number.zero? + last_line = (line_number == (lines.count - 1)) m << "\n" m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n" m << "#{indent}-------------------------------------------\n" - m << "#{indent}#{lines[line_numer - 1]}" unless first_line - m << "#{indicator}#{lines[line_numer]}" - m << "#{indent}#{lines[line_numer + 1]}" unless last_line + m << "#{indent}#{lines[line_number - 1]}" unless first_line + m << "#{indicator}#{lines[line_number]}" + m << "#{indent}#{lines[line_number + 1]}" unless last_line m << "\n" unless m.end_with?("\n") m << "#{indent}-------------------------------------------\n" end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 216d437d05..0d7f26f9b7 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -221,7 +221,7 @@ module Bundler requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) } path_plugin_files = requested_path_gems.map do |spec| - Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}") + spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}") rescue TypeError error_message = "#{spec.name} #{spec.version} has an invalid gemspec" raise Gem::InvalidSpecificationException, error_message diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index f91b263875..690f379389 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -131,7 +131,7 @@ module Bundler Bundler::Index.build do |index| files.each do |file| next unless spec = Bundler.load_gemspec(file) - Bundler.rubygems.set_installed_by_version(spec) + spec.installed_by_version = Gem::VERSION spec.source = self Bundler.rubygems.validate(spec) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index d4cc4f6216..56d18f28fd 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -36,15 +36,14 @@ module Gem remove_method :open_file_with_flock if Gem.respond_to?(:open_file_with_flock) def open_file_with_flock(path, &block) - mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY + # read-write mode is used rather than read-only in order to support NFS + mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE) File.open(path, mode) do |io| begin io.flock(File::LOCK_EX) rescue Errno::ENOSYS, Errno::ENOTSUP - rescue Errno::ENOLCK # NFS - raise unless Thread.main == Thread.current end yield io end @@ -267,6 +266,16 @@ module Gem end out end + + if Gem.rubygems_version < Gem::Version.new("3.5.22") + module FilterIgnoredSpecs + def matching_specs(platform_only = false) + super.reject(&:ignored?) + end + end + + prepend FilterIgnoredSpecs + end end # Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6 @@ -389,6 +398,15 @@ module Gem end end end + + # Can be removed once RubyGems 3.5.22 support is dropped + unless new.respond_to?(:ignored?) + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + end + end end require "rubygems/name_tuple" diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index ebe55a7e7a..5944ab86e0 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -57,28 +57,6 @@ module Bundler nil end - def set_installed_by_version(spec, installed_by_version = Gem::VERSION) - return unless spec.respond_to?(:installed_by_version=) - spec.installed_by_version = Gem::Version.create(installed_by_version) - end - - def spec_missing_extensions?(spec, default = true) - return spec.missing_extensions? if spec.respond_to?(:missing_extensions?) - - return false if spec.default_gem? - return false if spec.extensions.empty? - - default - end - - def spec_matches_for_glob(spec, glob) - return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob) - - spec.load_paths.flat_map do |lp| - Dir["#{lp}/#{glob}#{suffix_pattern}"] - end - end - def stub_set_spec(stub, spec) stub.instance_variable_set(:@spec, spec) end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 267878f83b..ef36efb3f4 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -210,7 +210,7 @@ module Bundler checkout end - generate_bin_options = { disable_extensions: !Bundler.rubygems.spec_missing_extensions?(spec), build_args: options[:build_args] } + generate_bin_options = { disable_extensions: !spec.missing_extensions?, build_args: options[:build_args] } generate_bin(spec, generate_bin_options) requires_checkout? ? spec.post_install_message : nil @@ -299,7 +299,7 @@ module Bundler # The gemspecs we cache should already be evaluated. spec = Bundler.load_gemspec(spec_path) next unless spec - Bundler.rubygems.set_installed_by_version(spec) + spec.installed_by_version = Gem::VERSION Bundler.rubygems.validate(spec) File.open(spec_path, "wb") {|file| file.write(spec.to_ruby) } end diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 4fd439d877..d4c530e922 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -150,7 +150,7 @@ module Bundler def load_gemspec(file) return unless spec = Bundler.load_gemspec(file) - Bundler.rubygems.set_installed_by_version(spec) + spec.installed_by_version = Gem::VERSION spec end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 3b6ef8bd58..36185561fa 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -357,10 +357,7 @@ module Bundler @installed_specs ||= Index.build do |idx| Bundler.rubygems.installed_specs.reverse_each do |spec| spec.source = self - if Bundler.rubygems.spec_missing_extensions?(spec, false) - Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions" - next - end + next if spec.ignored? idx << spec end end diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index dc5d38580a..718920f091 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -28,6 +28,17 @@ module Bundler # @!group Stub Delegates + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + return false unless @ignored + + warn "Source #{source} is ignoring #{self} because it is missing extensions" + + true + end + def manually_installed? # This is for manually installed gems which are gems that were fixed in place after a # failed installation. Once the issue was resolved, the user then manually created diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb index c15b346330..cfc0f48197 100644 --- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb @@ -68,6 +68,8 @@ autoload :OpenSSL, 'openssl' # #verify_callback :: For server certificate verification # #verify_depth :: Depth of certificate verification # #verify_mode :: How connections should be verified +# #verify_hostname :: Use hostname verification for server certificate +# during the handshake # # == Proxies # @@ -174,7 +176,7 @@ class Gem::Net::HTTP::Persistent ## # The version of Gem::Net::HTTP::Persistent you are using - VERSION = '4.0.2' + VERSION = '4.0.4' ## # Error class for errors raised by Gem::Net::HTTP::Persistent. Various @@ -450,6 +452,21 @@ class Gem::Net::HTTP::Persistent attr_reader :verify_mode ## + # HTTPS verify_hostname. + # + # If a client sets this to true and enables SNI with SSLSocket#hostname=, + # the hostname verification on the server certificate is performed + # automatically during the handshake using + # OpenSSL::SSL.verify_certificate_identity(). + # + # You can set +verify_hostname+ as true to use hostname verification + # during the handshake. + # + # NOTE: This works with Ruby > 3.0. + + attr_reader :verify_hostname + + ## # Creates a new Gem::Net::HTTP::Persistent. # # Set a +name+ for fun. Your library name should be good enough, but this @@ -508,6 +525,7 @@ class Gem::Net::HTTP::Persistent @verify_callback = nil @verify_depth = nil @verify_mode = nil + @verify_hostname = nil @cert_store = nil @generation = 0 # incremented when proxy Gem::URI changes @@ -607,13 +625,23 @@ class Gem::Net::HTTP::Persistent return yield connection rescue Errno::ECONNREFUSED - address = http.proxy_address || http.address - port = http.proxy_port || http.port + if http.proxy? + address = http.proxy_address + port = http.proxy_port + else + address = http.address + port = http.port + end raise Error, "connection refused: #{address}:#{port}" rescue Errno::EHOSTDOWN - address = http.proxy_address || http.address - port = http.proxy_port || http.port + if http.proxy? + address = http.proxy_address + port = http.proxy_port + else + address = http.address + port = http.port + end raise Error, "host down: #{address}:#{port}" ensure @@ -948,8 +976,10 @@ class Gem::Net::HTTP::Persistent connection.min_version = @min_version if @min_version connection.max_version = @max_version if @max_version - connection.verify_depth = @verify_depth - connection.verify_mode = @verify_mode + connection.verify_depth = @verify_depth + connection.verify_mode = @verify_mode + connection.verify_hostname = @verify_hostname if + @verify_hostname != nil && connection.respond_to?(:verify_hostname=) if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then @@ -1059,6 +1089,15 @@ application: end ## + # Sets the HTTPS verify_hostname. + + def verify_hostname= verify_hostname + @verify_hostname = verify_hostname + + reconnect_ssl + end + + ## # SSL verification callback. def verify_callback= callback @@ -1070,4 +1109,3 @@ end require_relative 'persistent/connection' require_relative 'persistent/pool' - diff --git a/lib/bundler/vendor/uri/lib/uri/common.rb b/lib/bundler/vendor/uri/lib/uri/common.rb index 93f4f226ad..89044da036 100644 --- a/lib/bundler/vendor/uri/lib/uri/common.rb +++ b/lib/bundler/vendor/uri/lib/uri/common.rb @@ -19,6 +19,8 @@ module Bundler::URI Parser = RFC2396_Parser RFC3986_PARSER = RFC3986_Parser.new Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor) + RFC2396_PARSER = RFC2396_Parser.new + Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor) # Bundler::URI::Parser.new DEFAULT_PARSER = Parser.new diff --git a/lib/bundler/vendor/uri/lib/uri/version.rb b/lib/bundler/vendor/uri/lib/uri/version.rb index 1fa1c7c09a..ac94e15221 100644 --- a/lib/bundler/vendor/uri/lib/uri/version.rb +++ b/lib/bundler/vendor/uri/lib/uri/version.rb @@ -1,6 +1,6 @@ module Bundler::URI # :stopdoc: - VERSION_CODE = '001300'.freeze + VERSION_CODE = '001301'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb index 6b66f72607..b8bfd4fc18 100644 --- a/lib/bundler/version.rb +++ b/lib/bundler/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: false module Bundler - VERSION = "2.5.21".freeze + VERSION = "2.5.22".freeze def self.bundler_major_version @bundler_major_version ||= VERSION.split(".").first.to_i diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 467cdcefa1..b739c8074f 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -9,7 +9,7 @@ require "rbconfig" module Gem - VERSION = "3.5.21" + VERSION = "3.5.22" end # Must be first since it unloads the prelude from 1.9.2 @@ -788,15 +788,14 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} # Open a file with given flags, and protect access with flock def self.open_file_with_flock(path, &block) - mode = IO::RDONLY | IO::APPEND | IO::CREAT | IO::BINARY + # read-write mode is used rather than read-only in order to support NFS + mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE) File.open(path, mode) do |io| begin io.flock(File::LOCK_EX) rescue Errno::ENOSYS, Errno::ENOTSUP - rescue Errno::ENOLCK # NFS - raise unless Thread.main == Thread.current end yield io end diff --git a/lib/rubygems/basic_specification.rb b/lib/rubygems/basic_specification.rb index 0eee52492f..308d94b0fc 100644 --- a/lib/rubygems/basic_specification.rb +++ b/lib/rubygems/basic_specification.rb @@ -71,11 +71,7 @@ class Gem::BasicSpecification # Return true if this spec can require +file+. def contains_requirable_file?(file) - if @ignored - return false - elsif missing_extensions? - @ignored = true - + if ignored? if platform == Gem::Platform::RUBY || Gem::Platform.local === platform warn "Ignoring #{full_name} because its extensions are not built. " \ "Try: gem pristine #{name} --version #{version}" @@ -93,8 +89,17 @@ class Gem::BasicSpecification end end + ## + # Return true if this spec should be ignored because it's missing extensions. + + def ignored? + return @ignored unless @ignored.nil? + + @ignored = missing_extensions? + end + def default_gem? - loaded_from && + !loaded_from.nil? && File.dirname(loaded_from) == Gem.default_specifications_dir end diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb index 4d54d1d49d..15834ce4dd 100644 --- a/lib/rubygems/command_manager.rb +++ b/lib/rubygems/command_manager.rb @@ -232,9 +232,14 @@ class Gem::CommandManager const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command" begin - require "rubygems/commands/#{command_name}_command" + begin + require "rubygems/commands/#{command_name}_command" + rescue LoadError + # it may have been defined from a rubygems_plugin.rb file + end + Gem::Commands.const_get(const_name).new - rescue StandardError, LoadError => e + rescue StandardError => e alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}") ui.backtrace e end diff --git a/lib/rubygems/commands/contents_command.rb b/lib/rubygems/commands/contents_command.rb index 807158d9c9..bd0cbce8ba 100644 --- a/lib/rubygems/commands/contents_command.rb +++ b/lib/rubygems/commands/contents_command.rb @@ -103,16 +103,23 @@ prefix or only the files that are requireable. def files_in_default_gem(spec) spec.files.map do |file| - case file - when %r{\A#{spec.bindir}/} - # $' is POSTMATCH - [RbConfig::CONFIG["bindir"], $'] - when /\.so\z/ - [RbConfig::CONFIG["archdir"], file] + if file.start_with?("#{spec.bindir}/") + [RbConfig::CONFIG["bindir"], file.delete_prefix("#{spec.bindir}/")] else - [RbConfig::CONFIG["rubylibdir"], file] + gem spec.name, spec.version + + require_path = spec.require_paths.find do |path| + file.start_with?("#{path}/") + end + + requirable_part = file.delete_prefix("#{require_path}/") + + resolve = $LOAD_PATH.resolve_feature_path(requirable_part)&.last + next unless resolve + + [resolve.delete_suffix(requirable_part), requirable_part] end - end + end.compact end def gem_contents(name) diff --git a/lib/rubygems/commands/pristine_command.rb b/lib/rubygems/commands/pristine_command.rb index 999c9fef0f..ec791d310a 100644 --- a/lib/rubygems/commands/pristine_command.rb +++ b/lib/rubygems/commands/pristine_command.rb @@ -134,10 +134,14 @@ extensions will be restored. say "Restoring gems to pristine condition..." - specs.each do |spec| - if spec.default_gem? - say "Skipped #{spec.full_name}, it is a default gem" - next + specs.group_by(&:full_name_with_location).values.each do |grouped_specs| + spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first + + unless only_executables_or_plugins? + # Default gemspecs include changes provided by ruby-core installer that + # can't currently be pristined (inclusion of compiled extension targets in + # the file list). So stick to resetting executables if it's a default gem. + options[:only_executables] = true if spec.default_gem? end if options.key? :skip @@ -147,14 +151,14 @@ extensions will be restored. end end - unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins] + unless spec.extensions.empty? || options[:extensions] || only_executables_or_plugins? say "Skipped #{spec.full_name_with_location}, it needs to compile an extension" next end gem = spec.cache_file - unless File.exist?(gem) || options[:only_executables] || options[:only_plugins] + unless File.exist?(gem) || only_executables_or_plugins? require_relative "../remote_fetcher" say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..." @@ -204,4 +208,10 @@ extensions will be restored. say "Restored #{spec.full_name_with_location}" end end + + private + + def only_executables_or_plugins? + options[:only_executables] || options[:only_plugins] + end end diff --git a/lib/rubygems/dependency.rb b/lib/rubygems/dependency.rb index ecb4824d7e..d1ec9222af 100644 --- a/lib/rubygems/dependency.rb +++ b/lib/rubygems/dependency.rb @@ -279,7 +279,7 @@ class Gem::Dependency end end - matches + matches.reject(&:ignored?) end ## diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 996c41825d..e438669945 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -2470,7 +2470,7 @@ class Gem::Specification < Gem::BasicSpecification if @installed_by_version result << nil - result << " s.installed_by_version = #{ruby_code Gem::VERSION} if s.respond_to? :installed_by_version" + result << " s.installed_by_version = #{ruby_code Gem::VERSION}" end unless dependencies.empty? diff --git a/lib/rubygems/specification_record.rb b/lib/rubygems/specification_record.rb index 664d506265..195a355496 100644 --- a/lib/rubygems/specification_record.rb +++ b/lib/rubygems/specification_record.rb @@ -30,7 +30,7 @@ module Gem # Returns the list of all specifications in the record def all - @all ||= Gem.loaded_specs.values | stubs.map(&:to_spec) + @all ||= stubs.map(&:to_spec) end ## diff --git a/lib/rubygems/stub_specification.rb b/lib/rubygems/stub_specification.rb index ea66fbc3f6..4f6a70ba4b 100644 --- a/lib/rubygems/stub_specification.rb +++ b/lib/rubygems/stub_specification.rb @@ -83,11 +83,7 @@ class Gem::StubSpecification < Gem::BasicSpecification # True when this gem has been activated def activated? - @activated ||= - begin - loaded = Gem.loaded_specs[name] - loaded && loaded.version == version - end + @activated ||= !loaded_spec.nil? end def default_gem? @@ -187,11 +183,7 @@ class Gem::StubSpecification < Gem::BasicSpecification # The full Gem::Specification for this gem, loaded from evalling its gemspec def spec - @spec ||= if @data - loaded = Gem.loaded_specs[name] - loaded if loaded && loaded.version == version - end - + @spec ||= loaded_spec if @data @spec ||= Gem::Specification.load(loaded_from) end alias_method :to_spec, :spec @@ -231,4 +223,13 @@ class Gem::StubSpecification < Gem::BasicSpecification def sort_obj # :nodoc: [name, version, Gem::Platform.sort_priority(platform)] end + + private + + def loaded_spec + spec = Gem.loaded_specs[name] + return unless spec && spec.version == version && spec.default_gem? == default_gem? + + spec + end end diff --git a/lib/rubygems/vendor/net-http/lib/net/http.rb b/lib/rubygems/vendor/net-http/lib/net/http.rb index 25c870a591..1a7074819d 100644 --- a/lib/rubygems/vendor/net-http/lib/net/http.rb +++ b/lib/rubygems/vendor/net-http/lib/net/http.rb @@ -46,7 +46,7 @@ module Gem::Net #:nodoc: # == Strategies # # - If you will make only a few GET requests, - # consider using {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html]. + # consider using {OpenURI}[rdoc-ref:OpenURI]. # - If you will make only a few requests of all kinds, # consider using the various singleton convenience methods in this class. # Each of the following methods automatically starts and finishes @@ -106,7 +106,7 @@ module Gem::Net #:nodoc: # It consists of some or all of: scheme, hostname, path, query, and fragment; # see {URI syntax}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax]. # - # A Ruby {Gem::URI::Generic}[https://docs.ruby-lang.org/en/master/Gem/URI/Generic.html] object + # A Ruby {Gem::URI::Generic}[rdoc-ref:Gem::URI::Generic] object # represents an internet URI. # It provides, among others, methods # +scheme+, +hostname+, +path+, +query+, and +fragment+. @@ -722,7 +722,7 @@ module Gem::Net #:nodoc: class HTTP < Protocol # :stopdoc: - VERSION = "0.4.0" + VERSION = "0.4.1" HTTPVersion = '1.1' begin require 'zlib' @@ -1217,7 +1217,7 @@ module Gem::Net #:nodoc: # - The name of an encoding. # - An alias for an encoding name. # - # See {Encoding}[https://docs.ruby-lang.org/en/master/Encoding.html]. + # See {Encoding}[rdoc-ref:Encoding]. # # Examples: # @@ -1490,11 +1490,11 @@ module Gem::Net #:nodoc: attr_accessor :cert_store # Sets or returns the available SSL ciphers. - # See {OpenSSL::SSL::SSLContext#ciphers=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D]. + # See {OpenSSL::SSL::SSLContext#ciphers=}[rdoc-ref:OpenSSL::SSL::SSLContext#ciphers-3D]. attr_accessor :ciphers # Sets or returns the extra X509 certificates to be added to the certificate chain. - # See {OpenSSL::SSL::SSLContext#add_certificate}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-add_certificate]. + # See {OpenSSL::SSL::SSLContext#add_certificate}[rdoc-ref:OpenSSL::SSL::SSLContext#add_certificate]. attr_accessor :extra_chain_cert # Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object. @@ -1504,15 +1504,15 @@ module Gem::Net #:nodoc: attr_accessor :ssl_timeout # Sets or returns the SSL version. - # See {OpenSSL::SSL::SSLContext#ssl_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D]. + # See {OpenSSL::SSL::SSLContext#ssl_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#ssl_version-3D]. attr_accessor :ssl_version # Sets or returns the minimum SSL version. - # See {OpenSSL::SSL::SSLContext#min_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D]. + # See {OpenSSL::SSL::SSLContext#min_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#min_version-3D]. attr_accessor :min_version # Sets or returns the maximum SSL version. - # See {OpenSSL::SSL::SSLContext#max_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D]. + # See {OpenSSL::SSL::SSLContext#max_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#max_version-3D]. attr_accessor :max_version # Sets or returns the callback for the server certification verification. @@ -1528,7 +1528,7 @@ module Gem::Net #:nodoc: # Sets or returns whether to verify that the server certificate is valid # for the hostname. - # See {OpenSSL::SSL::SSLContext#verify_hostname=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#attribute-i-verify_mode]. + # See {OpenSSL::SSL::SSLContext#verify_hostname=}[rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_mode]. attr_accessor :verify_hostname # Returns the X509 certificate chain (an array of strings) diff --git a/lib/rubygems/vendor/uri/lib/uri/common.rb b/lib/rubygems/vendor/uri/lib/uri/common.rb index 921fb9dd28..02b12d06e6 100644 --- a/lib/rubygems/vendor/uri/lib/uri/common.rb +++ b/lib/rubygems/vendor/uri/lib/uri/common.rb @@ -19,6 +19,8 @@ module Gem::URI Parser = RFC2396_Parser RFC3986_PARSER = RFC3986_Parser.new Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor) + RFC2396_PARSER = RFC2396_Parser.new + Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor) # Gem::URI::Parser.new DEFAULT_PARSER = Parser.new @@ -401,7 +403,7 @@ module Gem::URI private_class_method :_decode_uri_component # Returns a URL-encoded string derived from the given - # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes] + # {Enumerable}[rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes] # +enum+. # # The result is suitable for use as form data @@ -470,7 +472,7 @@ module Gem::URI # each +key+/+value+ pair is converted to one or more fields: # # - If +value+ is - # {Array-convertible}[https://docs.ruby-lang.org/en/master/implicit_conversion_rdoc.html#label-Array-Convertible+Objects], + # {Array-convertible}[rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects], # each element +ele+ in +value+ is paired with +key+ to form a field: # # name = Gem::URI.encode_www_form_component(key, enc) @@ -528,7 +530,7 @@ module Gem::URI # each subarray is a name/value pair (both are strings). # Each returned string has encoding +enc+, # and has had invalid characters removed via - # {String#scrub}[https://docs.ruby-lang.org/en/master/String.html#method-i-scrub]. + # {String#scrub}[rdoc-ref:String#scrub]. # # A simple example: # diff --git a/lib/rubygems/vendor/uri/lib/uri/version.rb b/lib/rubygems/vendor/uri/lib/uri/version.rb index 3c80c334d4..080744095c 100644 --- a/lib/rubygems/vendor/uri/lib/uri/version.rb +++ b/lib/rubygems/vendor/uri/lib/uri/version.rb @@ -1,6 +1,6 @@ module Gem::URI # :stopdoc: - VERSION_CODE = '001300'.freeze + VERSION_CODE = '001301'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index ee8d9c6d3a..9a46af1946 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -144,7 +144,6 @@ RSpec.shared_examples "bundle install --standalone" do skip "Does not work on old Windows Rubies" if Gem.ruby_version < Gem::Version.new("3.2") && Gem.win_platform? necessary_system_gems = ["tsort --version 0.1.0"] - necessary_system_gems += ["etc --version 1.4.3"] if Gem.ruby_version >= Gem::Version.new("3.3.2") && Gem.win_platform? realworld_system_gems(*necessary_system_gems) end @@ -176,7 +175,16 @@ RSpec.shared_examples "bundle install --standalone" do bundle "lock", dir: cwd bundle "config set --local path #{bundled_app("bundle")}" - bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s } + + # Make sure rubyinstaller2 does not activate the etc gem in its + # `operating_system.rb` file, but completely disable that since it's not + # really needed here + if Gem.win_platform? + FileUtils.mkdir_p bundled_app("rubygems/defaults") + FileUtils.touch bundled_app("rubygems/defaults/operating_system.rb") + end + + bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }, load_path: bundled_app load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") } @@ -187,28 +195,36 @@ RSpec.shared_examples "bundle install --standalone" do end it "works for gems with extensions and points to the vendored copies, not to the default copies" do - necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0", "shellwords --version 0.2.0", "open3 --version 0.2.1"] - necessary_gems_in_bundle_path += ["base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a") - necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a") - realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle"))) + simulate_platform "arm64-darwin-23" do + necessary_gems_in_bundle_path = ["optparse --version 0.1.1", "psych --version 3.3.2", "logger --version 1.4.3", "etc --version 1.4.3", "stringio --version 3.1.0", "shellwords --version 0.2.0", "open3 --version 0.2.1"] + necessary_gems_in_bundle_path += ["base64 --version 0.1.0", "resolv --version 0.2.1"] if Gem.rubygems_version < Gem::Version.new("3.3.a") + necessary_gems_in_bundle_path += ["yaml --version 0.1.1"] if Gem.rubygems_version < Gem::Version.new("3.4.a") + realworld_system_gems(*necessary_gems_in_bundle_path, path: scoped_gem_path(bundled_app("bundle"))) - build_gem "baz", "1.0.0", to_system: true, default: true, &:add_c_extension + build_gem "baz", "1.0.0", to_system: true, default: true, &:add_c_extension - build_repo4 do - build_gem "baz", "1.0.0", &:add_c_extension - end + build_repo4 do + build_gem "baz", "1.0.0", &:add_c_extension + end - gemfile <<-G - source "https://gem.repo4" - gem "baz" - G + gemfile <<-G + source "https://gem.repo4" + gem "baz" + G - bundle "config set --local path #{bundled_app("bundle")}" + bundle "config set --local path #{bundled_app("bundle")}" - simulate_platform "arm64-darwin-23" do bundle "lock", dir: cwd - bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s } + # Make sure rubyinstaller2 does not activate the etc gem in its + # `operating_system.rb` file, but completely disable that since it's not + # really needed here + if Gem.win_platform? + FileUtils.mkdir_p bundled_app("rubygems/defaults") + FileUtils.touch bundled_app("rubygems/defaults/operating_system.rb") + end + + bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s }, load_path: bundled_app end load_path_lines = bundled_app("bundle/bundler/setup.rb").read.split("\n").select {|line| line.start_with?("$:.unshift") } diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 175e2551f1..31ac110880 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -865,7 +865,6 @@ end it "should clean $LOAD_PATH properly" do gem_name = "very_simple_binary" full_gem_name = gem_name + "-1.0" - ext_dir = File.join(tmp("extensions", full_gem_name)) system_gems full_gem_name @@ -874,12 +873,6 @@ end G ruby <<-R - s = Gem::Specification.find_by_name '#{gem_name}' - s.extension_dir = '#{ext_dir}' - - # Don't build extensions. - s.class.send(:define_method, :build_extensions) { nil } - require 'bundler' gem '#{gem_name}' diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index a187d2ae48..4d713d8708 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -497,7 +497,7 @@ module Spec write "ext/#{name}.c", <<-C #include "ruby.h" - void Init_#{name}_c() { + void Init_#{name}_c(void) { rb_define_module("#{Builders.constantize(name)}_IN_C"); } C diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index 145008ab42..da75c0d6d1 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -76,9 +76,11 @@ module Spec requires = options.delete(:requires) || [] dir = options.delete(:dir) || bundled_app + custom_load_path = options.delete(:load_path) load_path = [] load_path << spec_dir + load_path << custom_load_path if custom_load_path build_ruby_options = { load_path: load_path, requires: requires, env: env } build_ruby_options.merge!(artifice: options.delete(:artifice)) if options.key?(:artifice) @@ -186,6 +188,12 @@ module Spec env = options[:env] || {} env["RUBYOPT"] = opt_add(opt_add("-r#{spec_dir}/support/hax.rb", env["RUBYOPT"]), ENV["RUBYOPT"]) options[:env] = env + + # Sometimes `gem install` commands hang at dns resolution, which has a + # default timeout of 60 seconds. When that happens, the timeout for a + # command is expired too. So give `gem install` commands a bit more time. + options[:timeout] = 120 + output = sys_exec("#{Path.gem_bin} #{command}", options) stderr = last_command.stderr raise stderr if stderr.include?("WARNING") && !allowed_rubygems_warning?(stderr) @@ -290,18 +298,16 @@ module Spec options = gems.last.is_a?(Hash) ? gems.pop : {} install_dir = options.fetch(:path, system_gem_path) default = options.fetch(:default, false) - with_gem_path_as(install_dir) do - gem_repo = options.fetch(:gem_repo, gem_repo1) - gems.each do |g| - gem_name = g.to_s - if gem_name.start_with?("bundler") - version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler" - with_built_bundler(version) {|gem_path| install_gem(gem_path, install_dir, default) } - elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name) - install_gem(gem_name, install_dir, default) - else - install_gem("#{gem_repo}/gems/#{gem_name}.gem", install_dir, default) - end + gems.each do |g| + gem_name = g.to_s + if gem_name.start_with?("bundler") + version = gem_name.match(/\Abundler-(?<version>.*)\z/)[:version] if gem_name != "bundler" + with_built_bundler(version) {|gem_path| install_gem(gem_path, install_dir, default) } + elsif %r{\A(?:[a-zA-Z]:)?/.*\.gem\z}.match?(gem_name) + install_gem(gem_name, install_dir, default) + else + gem_repo = options.fetch(:gem_repo, gem_repo1) + install_gem("#{gem_repo}/gems/#{gem_name}.gem", install_dir, default) end end end @@ -388,10 +394,8 @@ module Spec opts = gems.last.is_a?(Hash) ? gems.pop : {} path = opts.fetch(:path, system_gem_path) - with_gem_path_as(path) do - gems.each do |gem| - gem_command "install --no-document #{gem}" - end + gems.each do |gem| + gem_command "install --no-document --verbose --install-dir #{path} #{gem}" end end diff --git a/spec/bundler/support/subprocess.rb b/spec/bundler/support/subprocess.rb index ade18e7805..a4842166b9 100644 --- a/spec/bundler/support/subprocess.rb +++ b/spec/bundler/support/subprocess.rb @@ -34,7 +34,7 @@ module Spec dir = options[:dir] env = options[:env] || {} - command_execution = CommandExecution.new(cmd.to_s, working_directory: dir, timeout: 60) + command_execution = CommandExecution.new(cmd.to_s, working_directory: dir, timeout: options[:timeout] || 60) require "open3" require "shellwords" diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 0d048b08b7..cdc3479e37 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1026,6 +1026,20 @@ class TestGem < Gem::TestCase Gem.refresh end + def test_activated_specs_does_not_cause_duplicates_when_looping_through_specs + util_make_gems + + s = Gem::Specification.first + s.activate + + Gem.refresh + + assert_equal 1, Gem::Specification.count {|spec| spec.full_name == s.full_name } + + Gem.loaded_specs.delete(s) + Gem.refresh + end + def test_self_ruby_escaping_spaces_in_path with_clean_path_to_ruby do with_rb_config_ruby("C:/Ruby 1.8/bin/ruby.exe") do diff --git a/test/rubygems/test_gem_commands_contents_command.rb b/test/rubygems/test_gem_commands_contents_command.rb index d8e6ba3dec..049afe8a01 100644 --- a/test/rubygems/test_gem_commands_contents_command.rb +++ b/test/rubygems/test_gem_commands_contents_command.rb @@ -227,7 +227,6 @@ lib/foo.rb default_gem_spec = new_default_spec("default", "2.0.0.0", nil, "default/gem.rb") default_gem_spec.executables = ["default_command"] - default_gem_spec.files += ["default_gem.so"] install_default_gems(default_gem_spec) @cmd.options[:args] = %w[default] @@ -237,9 +236,8 @@ lib/foo.rb end expected = [ - [RbConfig::CONFIG["bindir"], "default_command"], - [RbConfig::CONFIG["rubylibdir"], "default/gem.rb"], - [RbConfig::CONFIG["archdir"], "default_gem.so"], + [File.join(@gemhome, "bin"), "default_command"], + [File.join(@tempdir, "default_gems", "lib"), "default/gem.rb"], ].sort.map {|a|File.join a }.join "\n" assert_equal expected, @ui.output.chomp diff --git a/test/rubygems/test_gem_commands_exec_command.rb b/test/rubygems/test_gem_commands_exec_command.rb index c632ce62b2..b9d5888068 100644 --- a/test/rubygems/test_gem_commands_exec_command.rb +++ b/test/rubygems/test_gem_commands_exec_command.rb @@ -215,7 +215,7 @@ class TestGemCommandsExecCommand < Gem::TestCase end def test_gem_with_platform_and_platform_dependencies - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? pend "terminates on mswin" if vc_windows? && ruby_repo? spec_fetcher do |fetcher| diff --git a/test/rubygems/test_gem_commands_pristine_command.rb b/test/rubygems/test_gem_commands_pristine_command.rb index b8b39133ff..46c06db014 100644 --- a/test/rubygems/test_gem_commands_pristine_command.rb +++ b/test/rubygems/test_gem_commands_pristine_command.rb @@ -630,8 +630,16 @@ class TestGemCommandsPristineCommand < Gem::TestCase def test_execute_default_gem default_gem_spec = new_default_spec("default", "2.0.0.0", - nil, "default/gem.rb") - install_default_gems(default_gem_spec) + nil, "exe/executable") + default_gem_spec.executables = "executable" + install_default_gems default_gem_spec + + exe = File.join @gemhome, "bin", "executable" + + assert_path_exist exe, "default gem's executable not installed" + + content_with_replaced_shebang = File.read(exe).gsub(/^#![^\n]+ruby/, "#!/usr/bin/env ruby_executable_hooks") + File.write(exe, content_with_replaced_shebang) @cmd.options[:args] = %w[default] @@ -642,11 +650,13 @@ class TestGemCommandsPristineCommand < Gem::TestCase assert_equal( [ "Restoring gems to pristine condition...", - "Skipped default-2.0.0.0, it is a default gem", + "Restored default-2.0.0.0", ], @ui.output.split("\n") ) assert_empty(@ui.error) + + refute_includes "ruby_executable_hooks", File.read(exe) end def test_execute_multi_platform diff --git a/test/rubygems/test_gem_dependency_installer.rb b/test/rubygems/test_gem_dependency_installer.rb index 8999723ba1..56b84160c4 100644 --- a/test/rubygems/test_gem_dependency_installer.rb +++ b/test/rubygems/test_gem_dependency_installer.rb @@ -819,6 +819,48 @@ class TestGemDependencyInstaller < Gem::TestCase assert_equal %w[a-1], inst.installed_gems.map(&:full_name) end + def test_install_dual_repository_and_done_installing_hooks + util_setup_gems + + FileUtils.mv @a1_gem, @tempdir + FileUtils.mv @b1_gem, @tempdir + inst = nil + + # Make sure gem is installed to standard GEM_HOME + + Dir.chdir @tempdir do + inst = Gem::DependencyInstaller.new install_dir: @gemhome + inst.install "b" + end + + # and also to an additional GEM_PATH + + gemhome2 = "#{@gemhome}2" + + Dir.chdir @tempdir do + inst = Gem::DependencyInstaller.new install_dir: gemhome2 + inst.install "b" + end + + # Now install the local gem with the additional GEM_PATH + + ENV["GEM_HOME"] = @gemhome + ENV["GEM_PATH"] = [@gemhome, gemhome2].join File::PATH_SEPARATOR + Gem.clear_paths + + Gem.done_installing do |installer, specs| + refute_nil installer + assert_equal [@b1], specs + end + + Dir.chdir @tempdir do + inst = Gem::DependencyInstaller.new + inst.install "b-1.gem" + end + + assert_equal %w[b-1], inst.installed_gems.map(&:full_name) + end + def test_install_remote util_setup_gems diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index 326aee147c..b7b2342c6a 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -1567,7 +1567,7 @@ end end def test_find_lib_file_after_install - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? @spec = setup_base_spec @spec.extensions << "extconf.rb" @@ -1655,7 +1655,7 @@ end end def test_install_extension_flat - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? begin @spec = setup_base_spec @@ -1706,7 +1706,7 @@ end end def test_install_extension_clean_intermediate_files - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? @spec = setup_base_spec @spec.require_paths = ["."] @spec.extensions << "extconf.rb" diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index fbe52aa317..b2ca2b368e 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -1334,7 +1334,6 @@ dependencies: [] end def test_build_args - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec assert_empty @ext.build_args @@ -1351,7 +1350,6 @@ dependencies: [] end def test_build_extensions - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec assert_path_not_exist @ext.extension_dir, "sanity check" @@ -1387,7 +1385,6 @@ dependencies: [] end def test_build_extensions_built - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec refute_empty @ext.extensions, "sanity check" @@ -1426,7 +1423,6 @@ dependencies: [] end def test_build_extensions_error - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec refute_empty @ext.extensions, "sanity check" @@ -1440,7 +1436,7 @@ dependencies: [] pend "chmod not supported" if Gem.win_platform? pend "skipped in root privilege" if Process.uid.zero? - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? ext_spec refute_empty @ext.extensions, "sanity check" @@ -1473,7 +1469,6 @@ dependencies: [] def test_build_extensions_no_extensions_dir_unwritable pend "chmod not supported" if Gem.win_platform? - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec refute_empty @ext.extensions, "sanity check" @@ -1512,7 +1507,6 @@ dependencies: [] end def test_build_extensions_preview - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec extconf_rb = File.join @ext.gem_dir, @ext.extensions.first @@ -1547,7 +1541,6 @@ dependencies: [] end def test_contains_requirable_file_eh_extension - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec _, err = capture_output do @@ -2368,7 +2361,7 @@ Gem::Specification.new do |s| s.rubygems_version = "#{Gem::VERSION}".freeze s.summary = "this is a summary".freeze - s.installed_by_version = "#{Gem::VERSION}".freeze if s.respond_to? :installed_by_version + s.installed_by_version = "#{Gem::VERSION}".freeze s.specification_version = #{Gem::Specification::CURRENT_SPECIFICATION_VERSION} @@ -3823,7 +3816,6 @@ end end def test_missing_extensions_eh - pend "extensions don't quite work on jruby" if Gem.java_platform? ext_spec assert @ext.missing_extensions? diff --git a/test/rubygems/test_gem_stub_specification.rb b/test/rubygems/test_gem_stub_specification.rb index fe30a78c0b..4b2d4c570a 100644 --- a/test/rubygems/test_gem_stub_specification.rb +++ b/test/rubygems/test_gem_stub_specification.rb @@ -66,7 +66,6 @@ class TestStubSpecification < Gem::TestCase end def test_contains_requirable_file_eh_extension - pend "I guess making the stub match the running platform should work" if Gem.java_platform? stub_with_extension do |stub| _, err = capture_output do refute stub.contains_requirable_file? "nonexistent" @@ -123,7 +122,6 @@ class TestStubSpecification < Gem::TestCase end def test_missing_extensions_eh - pend "I guess making the stub match the running platform should work" if Gem.java_platform? stub = stub_with_extension do |s| extconf_rb = File.join s.gem_dir, s.extensions.first FileUtils.mkdir_p File.dirname extconf_rb @@ -173,6 +171,35 @@ class TestStubSpecification < Gem::TestCase assert_same real_foo, @foo.to_spec end + def test_to_spec_default + bar_default_spec = File.join(@gemhome, "specifications", "default", "bar-0.0.2.gemspec") + File.open bar_default_spec, "w" do |io| + io.write <<~STUB + # -*- encoding: utf-8 -*- + # stub: bar 0.0.2 ruby lib + + Gem::Specification.new do |s| + s.name = "bar" + s.version = "0.0.2" + s.platform = "ruby" + s.require_paths = ["lib"] + s.summary = "A very bar gem" + end + STUB + end + + bar = Gem::StubSpecification.gemspec_stub BAR, @base_dir, @gems_dir + bar_default = Gem::StubSpecification.default_gemspec_stub bar_default_spec, @base_dir, @gems_dir + + real_bar = util_spec bar_default.name, bar_default.version + real_bar.activate + + assert_equal bar.version, Gem.loaded_specs[bar.name].version, + "sanity check" + + refute_same real_bar, bar_default.to_spec + end + def test_to_spec_with_other_specs_loaded_does_not_warn real_foo = util_spec @foo.name, @foo.version real_foo.activate @@ -184,14 +211,14 @@ class TestStubSpecification < Gem::TestCase def stub_with_version spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" File.open spec, "w" do |io| - io.write <<-STUB -# -*- encoding: utf-8 -*- -# stub: stub_v 2 ruby lib + io.write <<~STUB + # -*- encoding: utf-8 -*- + # stub: stub_v 2 ruby lib -Gem::Specification.new do |s| - s.name = 'stub_v' - s.version = Gem::Version.new '2' -end + Gem::Specification.new do |s| + s.name = 'stub_v' + s.version = Gem::Version.new '2' + end STUB io.flush @@ -207,14 +234,14 @@ end def stub_without_version spec = File.join @gemhome, "specifications", "stub-2.gemspec" File.open spec, "w" do |io| - io.write <<-STUB -# -*- encoding: utf-8 -*- -# stub: stub_v ruby lib + io.write <<~STUB + # -*- encoding: utf-8 -*- + # stub: stub_v ruby lib -Gem::Specification.new do |s| - s.name = 'stub_v' - s.version = "" -end + Gem::Specification.new do |s| + s.name = 'stub_v' + s.version = "" + end STUB io.flush @@ -230,17 +257,17 @@ end def stub_with_extension spec = File.join @gemhome, "specifications", "stub_e-2.gemspec" File.open spec, "w" do |io| - io.write <<-STUB -# -*- encoding: utf-8 -*- -# stub: stub_e 2 ruby lib -# stub: ext/stub_e/extconf.rb - -Gem::Specification.new do |s| - s.name = 'stub_e' - s.version = Gem::Version.new '2' - s.extensions = ['ext/stub_e/extconf.rb'] - s.installed_by_version = '2.2' -end + io.write <<~STUB + # -*- encoding: utf-8 -*- + # stub: stub_e 2 ruby lib + # stub: ext/stub_e/extconf.rb + + Gem::Specification.new do |s| + s.name = 'stub_e' + s.version = Gem::Version.new '2' + s.extensions = ['ext/stub_e/extconf.rb'] + s.installed_by_version = '2.2' + end STUB io.flush @@ -256,14 +283,14 @@ end def stub_without_extension spec = File.join @gemhome, "specifications", "stub-2.gemspec" File.open spec, "w" do |io| - io.write <<-STUB -# -*- encoding: utf-8 -*- -# stub: stub 2 ruby lib + io.write <<~STUB + # -*- encoding: utf-8 -*- + # stub: stub 2 ruby lib -Gem::Specification.new do |s| - s.name = 'stub' - s.version = Gem::Version.new '2' -end + Gem::Specification.new do |s| + s.name = 'stub' + s.version = Gem::Version.new '2' + end STUB io.flush diff --git a/test/rubygems/test_require.rb b/test/rubygems/test_require.rb index f15e9b6243..f63c23c315 100644 --- a/test/rubygems/test_require.rb +++ b/test/rubygems/test_require.rb @@ -130,7 +130,7 @@ class TestGemRequire < Gem::TestCase end def test_dash_i_respects_default_library_extension_priority - pend "extensions don't quite work on jruby" if Gem.java_platform? + pend "needs investigation" if Gem.java_platform? pend "not installed yet" unless RbConfig::TOPDIR dash_i_ext_arg = util_install_extension_file("a") |
