rubygems-update 3.5.23 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +14 -9
  5. data/bundler/CHANGELOG.md +59 -0
  6. data/bundler/bundler.gemspec +2 -2
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/cli/console.rb +0 -4
  9. data/bundler/lib/bundler/cli/doctor.rb +4 -4
  10. data/bundler/lib/bundler/cli/exec.rb +1 -0
  11. data/bundler/lib/bundler/cli/gem.rb +1 -1
  12. data/bundler/lib/bundler/cli/info.rb +2 -2
  13. data/bundler/lib/bundler/cli/inject.rb +1 -1
  14. data/bundler/lib/bundler/cli/install.rb +4 -0
  15. data/bundler/lib/bundler/cli/lock.rb +20 -1
  16. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  17. data/bundler/lib/bundler/cli/show.rb +2 -2
  18. data/bundler/lib/bundler/cli.rb +22 -53
  19. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  20. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -11
  21. data/bundler/lib/bundler/definition.rb +134 -61
  22. data/bundler/lib/bundler/dependency.rb +1 -1
  23. data/bundler/lib/bundler/dsl.rb +2 -13
  24. data/bundler/lib/bundler/endpoint_specification.rb +10 -1
  25. data/bundler/lib/bundler/errors.rb +10 -0
  26. data/bundler/lib/bundler/feature_flag.rb +1 -0
  27. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  28. data/bundler/lib/bundler/fetcher.rb +10 -3
  29. data/bundler/lib/bundler/gem_helpers.rb +21 -5
  30. data/bundler/lib/bundler/injector.rb +2 -2
  31. data/bundler/lib/bundler/installer/standalone.rb +2 -2
  32. data/bundler/lib/bundler/installer.rb +4 -38
  33. data/bundler/lib/bundler/lazy_specification.rb +65 -24
  34. data/bundler/lib/bundler/lockfile_parser.rb +9 -1
  35. data/bundler/lib/bundler/man/bundle-add.1 +13 -10
  36. data/bundler/lib/bundler/man/bundle-add.1.ronn +12 -9
  37. data/bundler/lib/bundler/man/bundle-binstubs.1 +7 -4
  38. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  39. data/bundler/lib/bundler/man/bundle-cache.1 +30 -2
  40. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  41. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  42. data/bundler/lib/bundler/man/bundle-check.1.ronn +4 -2
  43. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-config.1 +3 -1
  45. data/bundler/lib/bundler/man/bundle-config.1.ronn +2 -0
  46. data/bundler/lib/bundler/man/bundle-console.1 +2 -4
  47. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  48. data/bundler/lib/bundler/man/bundle-doctor.1 +2 -2
  49. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  50. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  51. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  52. data/bundler/lib/bundler/man/bundle-exec.1 +5 -2
  53. data/bundler/lib/bundler/man/bundle-exec.1.ronn +4 -1
  54. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  55. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  56. data/bundler/lib/bundler/man/bundle-gem.1 +17 -5
  57. data/bundler/lib/bundler/man/bundle-gem.1.ronn +27 -6
  58. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  59. data/bundler/lib/bundler/man/bundle-info.1 +5 -2
  60. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  61. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  62. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  63. data/bundler/lib/bundler/man/bundle-inject.1 +10 -2
  64. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  65. data/bundler/lib/bundler/man/bundle-install.1 +14 -11
  66. data/bundler/lib/bundler/man/bundle-install.1.ronn +21 -16
  67. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  68. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  69. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  70. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  71. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  73. data/bundler/lib/bundler/man/bundle-lock.1 +21 -6
  74. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  75. data/bundler/lib/bundler/man/bundle-open.1 +2 -2
  76. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  77. data/bundler/lib/bundler/man/bundle-outdated.1 +8 -5
  78. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  79. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  80. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  81. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  82. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  83. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  85. data/bundler/lib/bundler/man/bundle-show.1 +5 -2
  86. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  87. data/bundler/lib/bundler/man/bundle-update.1 +13 -7
  88. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  89. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  90. data/bundler/lib/bundler/man/bundle-viz.1 +4 -4
  91. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  92. data/bundler/lib/bundler/man/bundle.1 +1 -1
  93. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  94. data/bundler/lib/bundler/man/index.txt +4 -0
  95. data/bundler/lib/bundler/materialization.rb +59 -0
  96. data/bundler/lib/bundler/plugin/events.rb +24 -0
  97. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  98. data/bundler/lib/bundler/process_lock.rb +1 -1
  99. data/bundler/lib/bundler/remote_specification.rb +6 -1
  100. data/bundler/lib/bundler/resolver/base.rb +2 -6
  101. data/bundler/lib/bundler/resolver/candidate.rb +2 -2
  102. data/bundler/lib/bundler/resolver/spec_group.rb +4 -3
  103. data/bundler/lib/bundler/resolver.rb +5 -5
  104. data/bundler/lib/bundler/rubygems_ext.rb +17 -28
  105. data/bundler/lib/bundler/rubygems_gem_installer.rb +0 -1
  106. data/bundler/lib/bundler/rubygems_integration.rb +21 -11
  107. data/bundler/lib/bundler/runtime.rb +27 -7
  108. data/bundler/lib/bundler/self_manager.rb +2 -3
  109. data/bundler/lib/bundler/settings.rb +1 -0
  110. data/bundler/lib/bundler/shared_helpers.rb +2 -2
  111. data/bundler/lib/bundler/source/git/git_proxy.rb +0 -6
  112. data/bundler/lib/bundler/source/git.rb +56 -31
  113. data/bundler/lib/bundler/source/path.rb +2 -2
  114. data/bundler/lib/bundler/source_list.rb +1 -1
  115. data/bundler/lib/bundler/spec_set.rb +81 -56
  116. data/bundler/lib/bundler/stub_specification.rb +8 -0
  117. data/bundler/lib/bundler/templates/newgem/README.md.tt +1 -1
  118. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -1
  119. data/bundler/lib/bundler/vendor/fileutils/COPYING +56 -0
  120. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  121. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  122. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  123. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  124. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  125. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  127. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  128. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  129. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  130. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  131. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  132. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  133. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  134. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  135. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  136. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  137. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  138. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  139. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  140. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  141. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  142. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  143. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  144. data/bundler/lib/bundler/vendored_securerandom.rb +0 -2
  145. data/bundler/lib/bundler/version.rb +1 -1
  146. data/bundler/lib/bundler.rb +37 -13
  147. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +9 -9
  148. data/{POLICIES.md → doc/rubygems/POLICIES.md} +11 -11
  149. data/lib/rubygems/basic_specification.rb +5 -4
  150. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  151. data/lib/rubygems/commands/contents_command.rb +4 -4
  152. data/lib/rubygems/commands/exec_command.rb +3 -0
  153. data/lib/rubygems/commands/pristine_command.rb +2 -2
  154. data/lib/rubygems/commands/push_command.rb +29 -5
  155. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  156. data/lib/rubygems/commands/rebuild_command.rb +0 -2
  157. data/lib/rubygems/commands/setup_command.rb +1 -16
  158. data/lib/rubygems/commands/unpack_command.rb +0 -6
  159. data/lib/rubygems/commands/update_command.rb +2 -8
  160. data/lib/rubygems/config_file.rb +12 -0
  161. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  162. data/lib/rubygems/defaults.rb +1 -1
  163. data/lib/rubygems/exceptions.rb +0 -6
  164. data/lib/rubygems/ext/builder.rb +6 -4
  165. data/lib/rubygems/ext/cargo_builder.rb +7 -4
  166. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  167. data/lib/rubygems/ext/configure_builder.rb +7 -2
  168. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  169. data/lib/rubygems/ext/rake_builder.rb +6 -1
  170. data/lib/rubygems/install_update_options.rb +5 -0
  171. data/lib/rubygems/installer.rb +2 -2
  172. data/lib/rubygems/platform.rb +4 -3
  173. data/lib/rubygems/psych_tree.rb +4 -0
  174. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  175. data/lib/rubygems/requirement.rb +0 -4
  176. data/lib/rubygems/resolver/composed_set.rb +3 -3
  177. data/lib/rubygems/resolver/git_set.rb +0 -1
  178. data/lib/rubygems/resolver/index_set.rb +2 -2
  179. data/lib/rubygems/resolver.rb +3 -3
  180. data/lib/rubygems/source/git.rb +13 -10
  181. data/lib/rubygems/spec_fetcher.rb +16 -5
  182. data/lib/rubygems/specification.rb +37 -31
  183. data/lib/rubygems/target_rbconfig.rb +50 -0
  184. data/lib/rubygems/uri.rb +1 -1
  185. data/lib/rubygems/util/licenses.rb +10 -1
  186. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  187. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  188. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  189. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  190. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  191. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  192. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  193. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  194. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  195. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  196. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  197. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +5 -5
  198. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  199. data/lib/rubygems/vendor/timeout/lib/timeout.rb +5 -8
  200. data/lib/rubygems/vendor/uri/COPYING +56 -0
  201. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  202. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  203. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  204. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  205. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  206. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  207. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  208. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  209. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  210. data/lib/rubygems/vendored_securerandom.rb +0 -1
  211. data/lib/rubygems/version.rb +0 -4
  212. data/lib/rubygems.rb +29 -20
  213. data/rubygems-update.gemspec +5 -5
  214. data/setup.rb +1 -1
  215. metadata +36 -27
  216. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  217. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  218. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  219. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  220. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  221. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  222. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  223. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  224. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  225. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  226. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  227. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  228. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  229. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
@@ -47,6 +47,8 @@ class Gem::ConfigFile
47
47
  DEFAULT_CONCURRENT_DOWNLOADS = 8
48
48
  DEFAULT_CERT_EXPIRATION_LENGTH_DAYS = 365
49
49
  DEFAULT_IPV4_FALLBACK_ENABLED = false
50
+ # TODO: Use false as default value for this option in RubyGems 4.0
51
+ DEFAULT_INSTALL_EXTENSION_IN_LIB = true
50
52
 
51
53
  ##
52
54
  # For Ruby packagers to set configuration defaults. Set in
@@ -142,6 +144,11 @@ class Gem::ConfigFile
142
144
 
143
145
  attr_accessor :cert_expiration_length_days
144
146
 
147
+ ##
148
+ # Install extensions into lib as well as into the extension directory.
149
+
150
+ attr_accessor :install_extension_in_lib
151
+
145
152
  ##
146
153
  # == Experimental ==
147
154
  # Fallback to IPv4 when IPv6 is not reachable or slow (default: false)
@@ -183,6 +190,7 @@ class Gem::ConfigFile
183
190
  @update_sources = DEFAULT_UPDATE_SOURCES
184
191
  @concurrent_downloads = DEFAULT_CONCURRENT_DOWNLOADS
185
192
  @cert_expiration_length_days = DEFAULT_CERT_EXPIRATION_LENGTH_DAYS
193
+ @install_extension_in_lib = DEFAULT_INSTALL_EXTENSION_IN_LIB
186
194
  @ipv4_fallback_enabled = ENV["IPV4_FALLBACK_ENABLED"] == "true" || DEFAULT_IPV4_FALLBACK_ENABLED
187
195
 
188
196
  operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS)
@@ -220,6 +228,7 @@ class Gem::ConfigFile
220
228
  @update_sources = @hash[:update_sources] if @hash.key? :update_sources
221
229
  # TODO: We should handle concurrent_downloads same as other options
222
230
  @cert_expiration_length_days = @hash[:cert_expiration_length_days] if @hash.key? :cert_expiration_length_days
231
+ @install_extension_in_lib = @hash[:install_extension_in_lib] if @hash.key? :install_extension_in_lib
223
232
  @ipv4_fallback_enabled = @hash[:ipv4_fallback_enabled] if @hash.key? :ipv4_fallback_enabled
224
233
 
225
234
  @home = @hash[:gemhome] if @hash.key? :gemhome
@@ -476,6 +485,9 @@ if you believe they were disclosed to a third party.
476
485
  yaml_hash[:concurrent_downloads] =
477
486
  @hash.fetch(:concurrent_downloads, DEFAULT_CONCURRENT_DOWNLOADS)
478
487
 
488
+ yaml_hash[:install_extension_in_lib] =
489
+ @hash.fetch(:install_extension_in_lib, DEFAULT_INSTALL_EXTENSION_IN_LIB)
490
+
479
491
  yaml_hash[:ssl_verify_mode] =
480
492
  @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode
481
493
 
@@ -13,11 +13,7 @@ module Kernel
13
13
 
14
14
  module_function define_method(:warn) {|*messages, **kw|
15
15
  unless uplevel = kw[:uplevel]
16
- if Gem.java_platform? && RUBY_VERSION < "3.1"
17
- return original_warn.bind(self).call(*messages)
18
- else
19
- return original_warn.bind(self).call(*messages, **kw)
20
- end
16
+ return original_warn.bind_call(self, *messages, **kw)
21
17
  end
22
18
 
23
19
  # Ensure `uplevel` fits a `long`
@@ -44,6 +40,6 @@ module Kernel
44
40
  kw[:uplevel] = start
45
41
  end
46
42
 
47
- original_warn.bind(self).call(*messages, **kw)
43
+ original_warn.bind_call(self, *messages, **kw)
48
44
  }
49
45
  end
@@ -251,7 +251,7 @@ module Gem
251
251
  # Install extensions into lib as well as into the extension directory.
252
252
 
253
253
  def self.install_extension_in_lib # :nodoc:
254
- true
254
+ Gem.configuration.install_extension_in_lib
255
255
  end
256
256
 
257
257
  ##
@@ -291,9 +291,3 @@ class Gem::UnsatisfiableDependencyError < Gem::DependencyError
291
291
  @dependency.requirement
292
292
  end
293
293
  end
294
-
295
- ##
296
- # Backwards compatible typo'd exception class for early RubyGems 2.0.x
297
-
298
- Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
299
- Gem.deprecate_constant :UnsatisfiableDepedencyError
@@ -19,13 +19,14 @@ class Gem::Ext::Builder
19
19
  $1.downcase
20
20
  end
21
21
 
22
- def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"])
22
+ def self.make(dest_path, results, make_dir = Dir.pwd, sitedir = nil, targets = ["clean", "", "install"],
23
+ target_rbconfig: Gem.target_rbconfig)
23
24
  unless File.exist? File.join(make_dir, "Makefile")
24
25
  raise Gem::InstallError, "Makefile not found"
25
26
  end
26
27
 
27
28
  # try to find make program from Ruby configure arguments first
28
- RbConfig::CONFIG["configure_args"] =~ /with-make-prog\=(\w+)/
29
+ target_rbconfig["configure_args"] =~ /with-make-prog\=(\w+)/
29
30
  make_program_name = ENV["MAKE"] || ENV["make"] || $1
30
31
  make_program_name ||= RUBY_PLATFORM.include?("mswin") ? "nmake" : "make"
31
32
  make_program = Shellwords.split(make_program_name)
@@ -131,10 +132,11 @@ class Gem::Ext::Builder
131
132
  # have build arguments, saved, set +build_args+ which is an ARGV-style
132
133
  # array.
133
134
 
134
- def initialize(spec, build_args = spec.build_args)
135
+ def initialize(spec, build_args = spec.build_args, target_rbconfig = Gem.target_rbconfig)
135
136
  @spec = spec
136
137
  @build_args = build_args
137
138
  @gem_dir = spec.full_gem_path
139
+ @target_rbconfig = target_rbconfig
138
140
 
139
141
  @ran_rake = false
140
142
  end
@@ -191,7 +193,7 @@ EOF
191
193
  FileUtils.mkdir_p dest_path
192
194
 
193
195
  results = builder.build(extension, dest_path,
194
- results, @build_args, lib_dir, extension_dir)
196
+ results, @build_args, lib_dir, extension_dir, @target_rbconfig)
195
197
 
196
198
  verbose { results.join("\n") }
197
199
 
@@ -16,10 +16,15 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
16
16
  @profile = :release
17
17
  end
18
18
 
19
- def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd)
19
+ def build(extension, dest_path, results, args = [], lib_dir = nil, cargo_dir = Dir.pwd,
20
+ target_rbconfig=Gem.target_rbconfig)
20
21
  require "tempfile"
21
22
  require "fileutils"
22
23
 
24
+ if target_rbconfig.path
25
+ warn "--target-rbconfig is not yet supported for Rust extensions. Ignoring"
26
+ end
27
+
23
28
  # Where's the Cargo.toml of the crate we're building
24
29
  cargo_toml = File.join(cargo_dir, "Cargo.toml")
25
30
  # What's the crate's name
@@ -47,7 +52,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
47
52
 
48
53
  nesting = extension_nesting(extension)
49
54
 
50
- # TODO: remove in RubyGems 4
51
55
  if Gem.install_extension_in_lib && lib_dir
52
56
  nested_lib_dir = File.join(lib_dir, nesting)
53
57
  FileUtils.mkdir_p nested_lib_dir
@@ -248,8 +252,7 @@ EOF
248
252
 
249
253
  def rustc_dynamic_linker_flags(dest_dir, crate_name)
250
254
  split_flags("DLDFLAGS").
251
- map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }.
252
- compact.
255
+ filter_map {|arg| maybe_resolve_ldflag_variable(arg, dest_dir, crate_name) }.
253
256
  flat_map {|arg| ldflag_to_link_modifier(arg) }
254
257
  end
255
258
 
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
4
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd)
4
+ def self.build(extension, dest_path, results, args=[], lib_dir=nil, cmake_dir=Dir.pwd,
5
+ target_rbconfig=Gem.target_rbconfig)
6
+ if target_rbconfig.path
7
+ warn "--target-rbconfig is not yet supported for CMake extensions. Ignoring"
8
+ end
9
+
5
10
  unless File.exist?(File.join(cmake_dir, "Makefile"))
6
11
  require_relative "../command"
7
12
  cmd = ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=#{dest_path}", *Gem::Command.build_args]
@@ -9,7 +14,7 @@ class Gem::Ext::CmakeBuilder < Gem::Ext::Builder
9
14
  run cmd, results, class_name, cmake_dir
10
15
  end
11
16
 
12
- make dest_path, results, cmake_dir
17
+ make dest_path, results, cmake_dir, target_rbconfig: target_rbconfig
13
18
 
14
19
  results
15
20
  end
@@ -7,14 +7,19 @@
7
7
  #++
8
8
 
9
9
  class Gem::Ext::ConfigureBuilder < Gem::Ext::Builder
10
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, configure_dir=Dir.pwd)
10
+ def self.build(extension, dest_path, results, args=[], lib_dir=nil, configure_dir=Dir.pwd,
11
+ target_rbconfig=Gem.target_rbconfig)
12
+ if target_rbconfig.path
13
+ warn "--target-rbconfig is not yet supported for configure-based extensions. Ignoring"
14
+ end
15
+
11
16
  unless File.exist?(File.join(configure_dir, "Makefile"))
12
17
  cmd = ["sh", "./configure", "--prefix=#{dest_path}", *args]
13
18
 
14
19
  run cmd, results, class_name, configure_dir
15
20
  end
16
21
 
17
- make dest_path, results, configure_dir
22
+ make dest_path, results, configure_dir, target_rbconfig: target_rbconfig
18
23
 
19
24
  results
20
25
  end
@@ -7,7 +7,8 @@
7
7
  #++
8
8
 
9
9
  class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
10
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd)
10
+ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd,
11
+ target_rbconfig=Gem.target_rbconfig)
11
12
  require "fileutils"
12
13
  require "tempfile"
13
14
 
@@ -23,6 +24,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
23
24
 
24
25
  begin
25
26
  cmd = ruby << File.basename(extension)
27
+ cmd << "--target-rbconfig=#{target_rbconfig.path}" if target_rbconfig.path
26
28
  cmd.push(*args)
27
29
 
28
30
  run(cmd, results, class_name, extension_dir) do |s, r|
@@ -39,12 +41,14 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
39
41
 
40
42
  ENV["DESTDIR"] = nil
41
43
 
42
- make dest_path, results, extension_dir, tmp_dest_relative
44
+ make dest_path, results, extension_dir, tmp_dest_relative, target_rbconfig: target_rbconfig
43
45
 
44
46
  full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
45
47
 
46
- # TODO: remove in RubyGems 4
47
- if Gem.install_extension_in_lib && lib_dir
48
+ is_cross_compiling = target_rbconfig["platform"] != RbConfig::CONFIG["platform"]
49
+ # Do not copy extension libraries by default when cross-compiling
50
+ # not to conflict with the one already built for the host platform.
51
+ if Gem.install_extension_in_lib && lib_dir && !is_cross_compiling
48
52
  FileUtils.mkdir_p lib_dir
49
53
  entries = Dir.entries(full_tmp_dest) - %w[. ..]
50
54
  entries = entries.map {|entry| File.join full_tmp_dest, entry }
@@ -56,7 +60,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
56
60
  destent.exist? || FileUtils.mv(ent.path, destent.path)
57
61
  end
58
62
 
59
- make dest_path, results, extension_dir, tmp_dest_relative, ["clean"]
63
+ make dest_path, results, extension_dir, tmp_dest_relative, ["clean"], target_rbconfig: target_rbconfig
60
64
  ensure
61
65
  ENV["DESTDIR"] = destdir
62
66
  end
@@ -9,7 +9,12 @@ require_relative "../shellwords"
9
9
  #++
10
10
 
11
11
  class Gem::Ext::RakeBuilder < Gem::Ext::Builder
12
- def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd)
12
+ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=Dir.pwd,
13
+ target_rbconfig=Gem.target_rbconfig)
14
+ if target_rbconfig.path
15
+ warn "--target-rbconfig is not yet supported for Rake extensions. Ignoring"
16
+ end
17
+
13
18
  if /mkrf_conf/i.match?(File.basename(extension))
14
19
  run([Gem.ruby, File.basename(extension), *args], results, class_name, extension_dir)
15
20
  end
@@ -179,6 +179,11 @@ module Gem::InstallUpdateOptions
179
179
  "Suggest alternates when gems are not found") do |v,_o|
180
180
  options[:suggest_alternate] = v
181
181
  end
182
+
183
+ add_option(:"Install/Update", "--target-rbconfig [FILE]",
184
+ "rbconfig.rb for the deployment target platform") do |v, _o|
185
+ Gem.set_target_rbconfig(v)
186
+ end
182
187
  end
183
188
 
184
189
  ##
@@ -839,7 +839,7 @@ TEXT
839
839
  # configure scripts and rakefiles or mkrf_conf files.
840
840
 
841
841
  def build_extensions
842
- builder = Gem::Ext::Builder.new spec, build_args
842
+ builder = Gem::Ext::Builder.new spec, build_args, Gem.target_rbconfig
843
843
 
844
844
  builder.build_extensions
845
845
  end
@@ -985,7 +985,7 @@ TEXT
985
985
  end
986
986
 
987
987
  def rb_config
988
- RbConfig::CONFIG
988
+ Gem.target_rbconfig
989
989
  end
990
990
 
991
991
  def ruby_install_name
@@ -12,9 +12,10 @@ class Gem::Platform
12
12
 
13
13
  attr_accessor :cpu, :os, :version
14
14
 
15
- def self.local
16
- @local ||= begin
17
- arch = RbConfig::CONFIG["arch"]
15
+ def self.local(refresh: false)
16
+ return @local if @local && !refresh
17
+ @local = begin
18
+ arch = Gem.target_rbconfig["arch"]
18
19
  arch = "#{arch}_60" if /mswin(?:32|64)$/.match?(arch)
19
20
  new(arch)
20
21
  end
@@ -14,6 +14,10 @@ module Gem
14
14
  @emitter.scalar str, nil, nil, false, true, quote
15
15
  end
16
16
 
17
+ def visit_Hash(o)
18
+ super(o.compact)
19
+ end
20
+
17
21
  # Noop this out so there are no anchors
18
22
  def register(target, obj)
19
23
  end
@@ -330,7 +330,7 @@ class Gem::RequestSet::GemDependencyAPI
330
330
  # git: ::
331
331
  # Install this dependency from a git repository:
332
332
  #
333
- # gem 'private_gem', git: git@my.company.example:private_gem.git'
333
+ # gem 'private_gem', git: 'git@my.company.example:private_gem.git'
334
334
  #
335
335
  # gist: ::
336
336
  # Install this dependency from the gist ID:
@@ -214,10 +214,6 @@ class Gem::Requirement
214
214
  yaml_initialize coder.tag, coder.map
215
215
  end
216
216
 
217
- def to_yaml_properties # :nodoc:
218
- ["@requirements"]
219
- end
220
-
221
217
  def encode_with(coder) # :nodoc:
222
218
  coder.add "requirements", @requirements
223
219
  end
@@ -44,16 +44,16 @@ class Gem::Resolver::ComposedSet < Gem::Resolver::Set
44
44
  end
45
45
 
46
46
  def errors
47
- @errors + @sets.map(&:errors).flatten
47
+ @errors + @sets.flat_map(&:errors)
48
48
  end
49
49
 
50
50
  ##
51
51
  # Finds all specs matching +req+ in all sets.
52
52
 
53
53
  def find_all(req)
54
- @sets.map do |s|
54
+ @sets.flat_map do |s|
55
55
  s.find_all req
56
- end.flatten
56
+ end
57
57
  end
58
58
 
59
59
  ##
@@ -36,7 +36,6 @@ class Gem::Resolver::GitSet < Gem::Resolver::Set
36
36
  def initialize # :nodoc:
37
37
  super()
38
38
 
39
- @git = ENV["git"] || "git"
40
39
  @need_submodules = {}
41
40
  @repositories = {}
42
41
  @root_dir = Gem.dir
@@ -65,11 +65,11 @@ class Gem::Resolver::IndexSet < Gem::Resolver::Set
65
65
 
66
66
  q.breakable
67
67
 
68
- names = @all.values.map do |tuples|
68
+ names = @all.values.flat_map do |tuples|
69
69
  tuples.map do |_, tuple|
70
70
  tuple.full_name
71
71
  end
72
- end.flatten
72
+ end
73
73
 
74
74
  q.seplist names do |name|
75
75
  q.text name
@@ -59,7 +59,7 @@ class Gem::Resolver
59
59
  def self.compose_sets(*sets)
60
60
  sets.compact!
61
61
 
62
- sets = sets.map do |set|
62
+ sets = sets.flat_map do |set|
63
63
  case set
64
64
  when Gem::Resolver::BestSet then
65
65
  set
@@ -68,7 +68,7 @@ class Gem::Resolver
68
68
  else
69
69
  set
70
70
  end
71
- end.flatten
71
+ end
72
72
 
73
73
  case sets.length
74
74
  when 0 then
@@ -183,7 +183,7 @@ class Gem::Resolver
183
183
  # Proceed with resolution! Returns an array of ActivationRequest objects.
184
184
 
185
185
  def resolve
186
- Gem::Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }).tsort.map(&:payload).compact
186
+ Gem::Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }).tsort.filter_map(&:payload)
187
187
  rescue Gem::Molinillo::VersionConflict => e
188
188
  conflict = e.conflicts.values.first
189
189
  raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)
@@ -58,7 +58,6 @@ class Gem::Source::Git < Gem::Source
58
58
 
59
59
  @remote = true
60
60
  @root_dir = Gem.dir
61
- @git = ENV["git"] || "git"
62
61
  end
63
62
 
64
63
  def <=>(other)
@@ -81,6 +80,10 @@ class Gem::Source::Git < Gem::Source
81
80
  @need_submodules == other.need_submodules
82
81
  end
83
82
 
83
+ def git_command
84
+ ENV.fetch("git", "git")
85
+ end
86
+
84
87
  ##
85
88
  # Checks out the files for the repository into the install_dir.
86
89
 
@@ -90,18 +93,18 @@ class Gem::Source::Git < Gem::Source
90
93
  return false unless File.exist? repo_cache_dir
91
94
 
92
95
  unless File.exist? install_dir
93
- system @git, "clone", "--quiet", "--no-checkout",
96
+ system git_command, "clone", "--quiet", "--no-checkout",
94
97
  repo_cache_dir, install_dir
95
98
  end
96
99
 
97
100
  Dir.chdir install_dir do
98
- system @git, "fetch", "--quiet", "--force", "--tags", install_dir
101
+ system git_command, "fetch", "--quiet", "--force", "--tags", install_dir
99
102
 
100
- success = system @git, "reset", "--quiet", "--hard", rev_parse
103
+ success = system git_command, "reset", "--quiet", "--hard", rev_parse
101
104
 
102
105
  if @need_submodules
103
106
  require "open3"
104
- _, status = Open3.capture2e(@git, "submodule", "update", "--quiet", "--init", "--recursive")
107
+ _, status = Open3.capture2e(git_command, "submodule", "update", "--quiet", "--init", "--recursive")
105
108
 
106
109
  success &&= status.success?
107
110
  end
@@ -118,11 +121,11 @@ class Gem::Source::Git < Gem::Source
118
121
 
119
122
  if File.exist? repo_cache_dir
120
123
  Dir.chdir repo_cache_dir do
121
- system @git, "fetch", "--quiet", "--force", "--tags",
124
+ system git_command, "fetch", "--quiet", "--force", "--tags",
122
125
  @repository, "refs/heads/*:refs/heads/*"
123
126
  end
124
127
  else
125
- system @git, "clone", "--quiet", "--bare", "--no-hardlinks",
128
+ system git_command, "clone", "--quiet", "--bare", "--no-hardlinks",
126
129
  @repository, repo_cache_dir
127
130
  end
128
131
  end
@@ -182,7 +185,7 @@ class Gem::Source::Git < Gem::Source
182
185
  hash = nil
183
186
 
184
187
  Dir.chdir repo_cache_dir do
185
- hash = Gem::Util.popen(@git, "rev-parse", @reference).strip
188
+ hash = Gem::Util.popen(git_command, "rev-parse", @reference).strip
186
189
  end
187
190
 
188
191
  raise Gem::Exception,
@@ -201,7 +204,7 @@ class Gem::Source::Git < Gem::Source
201
204
  return [] unless install_dir
202
205
 
203
206
  Dir.chdir install_dir do
204
- Dir["{,*,*/*}.gemspec"].map do |spec_file|
207
+ Dir["{,*,*/*}.gemspec"].filter_map do |spec_file|
205
208
  directory = File.dirname spec_file
206
209
  file = File.basename spec_file
207
210
 
@@ -218,7 +221,7 @@ class Gem::Source::Git < Gem::Source
218
221
  end
219
222
  spec
220
223
  end
221
- end.compact
224
+ end
222
225
  end
223
226
  end
224
227
 
@@ -182,20 +182,31 @@ class Gem::SpecFetcher
182
182
  min_length = gem_name.length - max
183
183
  max_length = gem_name.length + max
184
184
 
185
+ gem_name_with_postfix = "#{gem_name}ruby"
186
+ gem_name_with_prefix = "ruby#{gem_name}"
187
+
185
188
  matches = names.filter_map do |n|
186
189
  len = n.name.length
187
- # If the length is min_length or shorter, we've done `max` deletions.
188
- # If the length is max_length or longer, we've done `max` insertions.
189
- # These would both be rejected later, so we skip early for performance.
190
- next if len <= min_length || len >= max_length
191
-
192
190
  # If the gem doesn't support the current platform, bail early.
193
191
  next unless n.match_platform?
194
192
 
193
+ # If the length is min_length or shorter, we've done `max` deletions.
194
+ # This would be rejected later, so we skip it for performance.
195
+ next if len <= min_length
196
+
195
197
  # The candidate name, normalized the same as gem_name.
196
198
  normalized_name = n.name.downcase
197
199
  normalized_name.tr!("_-", "")
198
200
 
201
+ # If the gem is "{NAME}-ruby" and "ruby-{NAME}", we want to return it.
202
+ # But we already removed hyphens, so we check "{NAME}ruby" and "ruby{NAME}".
203
+ next [n.name, 0] if normalized_name == gem_name_with_postfix
204
+ next [n.name, 0] if normalized_name == gem_name_with_prefix
205
+
206
+ # If the length is max_length or longer, we've done `max` insertions.
207
+ # This would be rejected later, so we skip it for performance.
208
+ next if len >= max_length
209
+
199
210
  # If we found an exact match (after stripping underscores and hyphens),
200
211
  # that's our most likely candidate.
201
212
  # Return it immediately, and skip the rest of the loop.