rubygems-update 3.5.23 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +74 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +15 -10
  5. data/bundler/CHANGELOG.md +66 -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 +155 -74
  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 +28 -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 +11 -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/query_utils.rb +1 -1
  175. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  176. data/lib/rubygems/requirement.rb +0 -4
  177. data/lib/rubygems/resolver/composed_set.rb +3 -3
  178. data/lib/rubygems/resolver/git_set.rb +0 -1
  179. data/lib/rubygems/resolver/index_set.rb +2 -2
  180. data/lib/rubygems/resolver.rb +3 -3
  181. data/lib/rubygems/source/git.rb +13 -10
  182. data/lib/rubygems/spec_fetcher.rb +16 -5
  183. data/lib/rubygems/specification.rb +37 -31
  184. data/lib/rubygems/target_rbconfig.rb +50 -0
  185. data/lib/rubygems/uri.rb +1 -1
  186. data/lib/rubygems/util/licenses.rb +10 -1
  187. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  188. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  189. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  190. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  191. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  192. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  193. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  194. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  195. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  196. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  197. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  198. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +11 -5
  199. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  200. data/lib/rubygems/vendor/timeout/lib/timeout.rb +9 -10
  201. data/lib/rubygems/vendor/uri/COPYING +56 -0
  202. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  203. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  204. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  205. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  206. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  207. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  208. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  209. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  210. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  211. data/lib/rubygems/vendored_securerandom.rb +0 -1
  212. data/lib/rubygems/version.rb +0 -4
  213. data/lib/rubygems.rb +30 -21
  214. data/rubygems-update.gemspec +5 -5
  215. data/setup.rb +1 -1
  216. metadata +36 -27
  217. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  218. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  219. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  220. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  221. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  222. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  223. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  224. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  225. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  226. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  227. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  228. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  229. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  230. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
@@ -30,7 +30,7 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
30
30
  end
31
31
 
32
32
  def initialize
33
- super "push", "Push a gem up to the gem server", host: host
33
+ super "push", "Push a gem up to the gem server", host: host, attestations: []
34
34
 
35
35
  @user_defined_host = false
36
36
 
@@ -45,6 +45,11 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
45
45
  @user_defined_host = true
46
46
  end
47
47
 
48
+ add_option("--attestation FILE",
49
+ "Push with sigstore attestations") do |value, options|
50
+ options[:attestations] << value
51
+ end
52
+
48
53
  @host = nil
49
54
  end
50
55
 
@@ -88,10 +93,18 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
88
93
 
89
94
  def send_push_request(name, args)
90
95
  rubygems_api_request(*args, scope: get_push_scope) do |request|
91
- request.body = Gem.read_binary name
92
- request.add_field "Content-Length", request.body.size
93
- request.add_field "Content-Type", "application/octet-stream"
94
- request.add_field "Authorization", api_key
96
+ body = Gem.read_binary name
97
+ if options[:attestations].any?
98
+ request.set_form([
99
+ ["gem", body, { filename: name, content_type: "application/octet-stream" }],
100
+ get_attestations_part,
101
+ ], "multipart/form-data")
102
+ else
103
+ request.body = body
104
+ request.add_field "Content-Type", "application/octet-stream"
105
+ request.add_field "Content-Length", request.body.size
106
+ end
107
+ request.add_field "Authorization", api_key
95
108
  end
96
109
  end
97
110
 
@@ -107,4 +120,15 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
107
120
  def get_push_scope
108
121
  :push_rubygem
109
122
  end
123
+
124
+ def get_attestations_part
125
+ bundles = "[" + options[:attestations].map do |attestation|
126
+ Gem.read_binary(attestation)
127
+ end.join(",") + "]"
128
+ [
129
+ "attestations",
130
+ bundles,
131
+ { content_type: "application/json" },
132
+ ]
133
+ end
110
134
  end
@@ -64,9 +64,9 @@ Use --overwrite to force rebuilding of documentation.
64
64
  specs = if options[:all]
65
65
  Gem::Specification.to_a
66
66
  else
67
- get_all_gem_names.map do |name|
67
+ get_all_gem_names.flat_map do |name|
68
68
  Gem::Specification.find_by_name name, options[:version]
69
- end.flatten.uniq
69
+ end.uniq
70
70
  end
71
71
 
72
72
  if specs.empty?
@@ -10,8 +10,6 @@ require_relative "../package"
10
10
  class Gem::Commands::RebuildCommand < Gem::Command
11
11
  include Gem::GemspecHelpers
12
12
 
13
- DATE_FORMAT = "%Y-%m-%d %H:%M:%S.%N Z"
14
-
15
13
  def initialize
16
14
  super "rebuild", "Attempt to reproduce a build of a gem."
17
15
 
@@ -107,15 +107,6 @@ class Gem::Commands::SetupCommand < Gem::Command
107
107
  @verbose = nil
108
108
  end
109
109
 
110
- def check_ruby_version
111
- required_version = Gem::Requirement.new ">= 2.6.0"
112
-
113
- unless required_version.satisfied_by? Gem.ruby_version
114
- alert_error "Expected Ruby version #{required_version}, is #{Gem.ruby_version}"
115
- terminate_interaction 1
116
- end
117
- end
118
-
119
110
  def defaults_str # :nodoc:
120
111
  "--format-executable --document ri --regenerate-binstubs"
121
112
  end
@@ -148,8 +139,6 @@ By default, this RubyGems will install gem as:
148
139
  def execute
149
140
  @verbose = Gem.configuration.really_verbose
150
141
 
151
- check_ruby_version
152
-
153
142
  require "fileutils"
154
143
  if Gem.configuration.really_verbose
155
144
  extend FileUtils::Verbose
@@ -279,11 +268,7 @@ By default, this RubyGems will install gem as:
279
268
  File.open bin_cmd_file, "w" do |file|
280
269
  file.puts <<-TEXT
281
270
  @ECHO OFF
282
- IF NOT "%~f0" == "~f0" GOTO :WinNT
283
- @"#{File.basename(Gem.ruby).chomp('"')}" "#{dest_file}" %1 %2 %3 %4 %5 %6 %7 %8 %9
284
- GOTO :EOF
285
- :WinNT
286
- @"#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
271
+ @"%~dp0#{File.basename(Gem.ruby).chomp('"')}" "%~dpn0" %*
287
272
  TEXT
288
273
  end
289
274
 
@@ -143,12 +143,6 @@ command help for an example.
143
143
  # get_path 'rake', '< 0.1' # nil
144
144
  # get_path 'rak' # nil (exact name required)
145
145
  #--
146
- # TODO: This should be refactored so that it's a general service. I don't
147
- # think any of our existing classes are the right place though. Just maybe
148
- # 'Cache'?
149
- #
150
- # TODO: It just uses Gem.dir for now. What's an easy way to get the list of
151
- # source directories?
152
146
 
153
147
  def get_path(dependency)
154
148
  return dependency.name if /\.gem$/i.match?(dependency.name)
@@ -317,16 +317,10 @@ command to remove old versions.
317
317
 
318
318
  #
319
319
  # Oldest version we support downgrading to. This is the version that
320
- # originally ships with the first patch version of each ruby, because we never
321
- # test each ruby against older rubygems, so we can't really guarantee it
322
- # works. Version list can be checked here: https://stdgems.org/rubygems
320
+ # originally ships with the oldest supported patch version of ruby.
323
321
  #
324
322
  def oldest_supported_version
325
323
  @oldest_supported_version ||=
326
- if Gem.ruby_version > Gem::Version.new("3.1.a")
327
- Gem::Version.new("3.3.3")
328
- else
329
- Gem::Version.new("3.2.3")
330
- end
324
+ Gem::Version.new("3.3.3")
331
325
  end
332
326
  end
@@ -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
@@ -311,7 +311,7 @@ module Gem::QueryUtils
311
311
  label = "Installed at"
312
312
  specs.each do |s|
313
313
  version = s.version.to_s
314
- default = ", default" if s.default_gem?
314
+ default = s.default_gem? ? ", default" : ""
315
315
  entry << "\n" << " #{label} (#{version}#{default}): #{s.base_dir}"
316
316
  label = " " * label.length
317
317
  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)