rubygems-update 3.5.22 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -0
  3. data/Manifest.txt +23 -16
  4. data/README.md +14 -9
  5. data/bundler/CHANGELOG.md +83 -0
  6. data/bundler/bundler.gemspec +2 -2
  7. data/bundler/lib/bundler/build_metadata.rb +2 -2
  8. data/bundler/lib/bundler/cli/add.rb +2 -0
  9. data/bundler/lib/bundler/cli/check.rb +2 -2
  10. data/bundler/lib/bundler/cli/console.rb +0 -4
  11. data/bundler/lib/bundler/cli/doctor.rb +4 -4
  12. data/bundler/lib/bundler/cli/exec.rb +1 -0
  13. data/bundler/lib/bundler/cli/gem.rb +1 -1
  14. data/bundler/lib/bundler/cli/info.rb +2 -2
  15. data/bundler/lib/bundler/cli/inject.rb +1 -1
  16. data/bundler/lib/bundler/cli/install.rb +4 -0
  17. data/bundler/lib/bundler/cli/lock.rb +20 -1
  18. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  19. data/bundler/lib/bundler/cli/show.rb +2 -2
  20. data/bundler/lib/bundler/cli.rb +23 -53
  21. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  22. data/bundler/lib/bundler/compact_index_client/updater.rb +0 -11
  23. data/bundler/lib/bundler/definition.rb +143 -76
  24. data/bundler/lib/bundler/dependency.rb +1 -1
  25. data/bundler/lib/bundler/dsl.rb +33 -28
  26. data/bundler/lib/bundler/endpoint_specification.rb +10 -1
  27. data/bundler/lib/bundler/errors.rb +10 -0
  28. data/bundler/lib/bundler/feature_flag.rb +1 -0
  29. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  30. data/bundler/lib/bundler/fetcher.rb +10 -3
  31. data/bundler/lib/bundler/gem_helpers.rb +21 -5
  32. data/bundler/lib/bundler/injector.rb +2 -2
  33. data/bundler/lib/bundler/inline.rb +12 -8
  34. data/bundler/lib/bundler/installer/standalone.rb +2 -2
  35. data/bundler/lib/bundler/installer.rb +4 -38
  36. data/bundler/lib/bundler/lazy_specification.rb +74 -26
  37. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  38. data/bundler/lib/bundler/lockfile_parser.rb +9 -1
  39. data/bundler/lib/bundler/man/bundle-add.1 +17 -11
  40. data/bundler/lib/bundler/man/bundle-add.1.ronn +16 -10
  41. data/bundler/lib/bundler/man/bundle-binstubs.1 +7 -4
  42. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  43. data/bundler/lib/bundler/man/bundle-cache.1 +30 -2
  44. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  45. data/bundler/lib/bundler/man/bundle-check.1 +3 -3
  46. data/bundler/lib/bundler/man/bundle-check.1.ronn +4 -2
  47. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-config.1 +3 -5
  49. data/bundler/lib/bundler/man/bundle-config.1.ronn +2 -7
  50. data/bundler/lib/bundler/man/bundle-console.1 +2 -4
  51. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  52. data/bundler/lib/bundler/man/bundle-doctor.1 +2 -2
  53. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  54. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  55. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  56. data/bundler/lib/bundler/man/bundle-exec.1 +5 -2
  57. data/bundler/lib/bundler/man/bundle-exec.1.ronn +4 -1
  58. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  59. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  60. data/bundler/lib/bundler/man/bundle-gem.1 +17 -5
  61. data/bundler/lib/bundler/man/bundle-gem.1.ronn +27 -6
  62. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-info.1 +5 -2
  64. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  65. data/bundler/lib/bundler/man/bundle-init.1 +3 -3
  66. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  67. data/bundler/lib/bundler/man/bundle-inject.1 +10 -2
  68. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  69. data/bundler/lib/bundler/man/bundle-install.1 +15 -12
  70. data/bundler/lib/bundler/man/bundle-install.1.ronn +22 -18
  71. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  72. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  73. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  74. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  75. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  77. data/bundler/lib/bundler/man/bundle-lock.1 +21 -6
  78. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  79. data/bundler/lib/bundler/man/bundle-open.1 +2 -2
  80. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  81. data/bundler/lib/bundler/man/bundle-outdated.1 +8 -5
  82. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  83. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  84. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  85. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  86. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  87. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  88. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  89. data/bundler/lib/bundler/man/bundle-show.1 +5 -2
  90. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  91. data/bundler/lib/bundler/man/bundle-update.1 +13 -7
  92. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  93. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  94. data/bundler/lib/bundler/man/bundle-viz.1 +4 -4
  95. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  96. data/bundler/lib/bundler/man/bundle.1 +1 -1
  97. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  98. data/bundler/lib/bundler/man/index.txt +4 -0
  99. data/bundler/lib/bundler/materialization.rb +59 -0
  100. data/bundler/lib/bundler/plugin/events.rb +24 -0
  101. data/bundler/lib/bundler/plugin/installer.rb +1 -1
  102. data/bundler/lib/bundler/plugin.rb +20 -1
  103. data/bundler/lib/bundler/process_lock.rb +10 -14
  104. data/bundler/lib/bundler/remote_specification.rb +6 -1
  105. data/bundler/lib/bundler/resolver/base.rb +6 -6
  106. data/bundler/lib/bundler/resolver/candidate.rb +2 -2
  107. data/bundler/lib/bundler/resolver/spec_group.rb +4 -3
  108. data/bundler/lib/bundler/resolver.rb +5 -5
  109. data/bundler/lib/bundler/rubygems_ext.rb +30 -27
  110. data/bundler/lib/bundler/rubygems_gem_installer.rb +3 -2
  111. data/bundler/lib/bundler/rubygems_integration.rb +23 -40
  112. data/bundler/lib/bundler/runtime.rb +27 -7
  113. data/bundler/lib/bundler/self_manager.rb +2 -3
  114. data/bundler/lib/bundler/settings.rb +6 -1
  115. data/bundler/lib/bundler/shared_helpers.rb +29 -17
  116. data/bundler/lib/bundler/source/git/git_proxy.rb +0 -6
  117. data/bundler/lib/bundler/source/git.rb +56 -31
  118. data/bundler/lib/bundler/source/metadata.rb +2 -3
  119. data/bundler/lib/bundler/source/path.rb +2 -2
  120. data/bundler/lib/bundler/source_list.rb +1 -1
  121. data/bundler/lib/bundler/spec_set.rb +81 -56
  122. data/bundler/lib/bundler/stub_specification.rb +8 -0
  123. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +0 -3
  124. data/bundler/lib/bundler/templates/newgem/README.md.tt +1 -1
  125. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  126. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -4
  127. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -1
  128. data/bundler/lib/bundler/vendor/fileutils/COPYING +56 -0
  129. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  130. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  131. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  132. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  133. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  134. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  135. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  136. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  137. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  138. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  139. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  140. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  141. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  142. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  143. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  144. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  145. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  146. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  147. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  148. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  149. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  150. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  151. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  152. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  153. data/bundler/lib/bundler/vendored_securerandom.rb +0 -2
  154. data/bundler/lib/bundler/version.rb +1 -1
  155. data/bundler/lib/bundler.rb +38 -14
  156. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +9 -9
  157. data/{POLICIES.md → doc/rubygems/POLICIES.md} +11 -11
  158. data/lib/rubygems/basic_specification.rb +5 -4
  159. data/lib/rubygems/commands/cleanup_command.rb +2 -2
  160. data/lib/rubygems/commands/contents_command.rb +4 -4
  161. data/lib/rubygems/commands/exec_command.rb +3 -0
  162. data/lib/rubygems/commands/pristine_command.rb +2 -2
  163. data/lib/rubygems/commands/push_command.rb +29 -5
  164. data/lib/rubygems/commands/rdoc_command.rb +2 -2
  165. data/lib/rubygems/commands/rebuild_command.rb +0 -2
  166. data/lib/rubygems/commands/setup_command.rb +7 -16
  167. data/lib/rubygems/commands/unpack_command.rb +0 -6
  168. data/lib/rubygems/commands/update_command.rb +2 -8
  169. data/lib/rubygems/config_file.rb +12 -0
  170. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  171. data/lib/rubygems/defaults.rb +1 -1
  172. data/lib/rubygems/exceptions.rb +0 -6
  173. data/lib/rubygems/ext/builder.rb +6 -4
  174. data/lib/rubygems/ext/cargo_builder.rb +7 -4
  175. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  176. data/lib/rubygems/ext/configure_builder.rb +7 -2
  177. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  178. data/lib/rubygems/ext/rake_builder.rb +6 -1
  179. data/lib/rubygems/gem_runner.rb +9 -0
  180. data/lib/rubygems/gemcutter_utilities.rb +8 -2
  181. data/lib/rubygems/install_update_options.rb +5 -0
  182. data/lib/rubygems/installer.rb +8 -9
  183. data/lib/rubygems/package/tar_header.rb +11 -0
  184. data/lib/rubygems/package/tar_reader/entry.rb +1 -5
  185. data/lib/rubygems/platform.rb +4 -3
  186. data/lib/rubygems/psych_tree.rb +4 -0
  187. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  188. data/lib/rubygems/requirement.rb +0 -4
  189. data/lib/rubygems/resolver/composed_set.rb +3 -3
  190. data/lib/rubygems/resolver/git_set.rb +0 -1
  191. data/lib/rubygems/resolver/index_set.rb +2 -2
  192. data/lib/rubygems/resolver.rb +3 -3
  193. data/lib/rubygems/source/git.rb +13 -10
  194. data/lib/rubygems/spec_fetcher.rb +46 -7
  195. data/lib/rubygems/specification.rb +38 -32
  196. data/lib/rubygems/target_rbconfig.rb +50 -0
  197. data/lib/rubygems/uri.rb +1 -1
  198. data/lib/rubygems/util/licenses.rb +10 -1
  199. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  200. data/lib/rubygems/vendor/net-http/lib/net/http/header.rb +1 -1
  201. data/lib/rubygems/vendor/net-http/lib/net/http/requests.rb +5 -0
  202. data/lib/rubygems/vendor/net-http/lib/net/http.rb +120 -36
  203. data/lib/rubygems/vendor/optparse/lib/optparse/ac.rb +16 -0
  204. data/lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb +8 -3
  205. data/lib/rubygems/vendor/optparse/lib/optparse/version.rb +9 -0
  206. data/lib/rubygems/vendor/optparse/lib/optparse.rb +147 -51
  207. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  208. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -37
  209. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  210. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +5 -5
  211. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  212. data/lib/rubygems/vendor/timeout/lib/timeout.rb +5 -8
  213. data/lib/rubygems/vendor/uri/COPYING +56 -0
  214. data/lib/rubygems/vendor/uri/lib/uri/common.rb +37 -16
  215. data/lib/rubygems/vendor/uri/lib/uri/file.rb +3 -3
  216. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +1 -1
  217. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +16 -26
  218. data/lib/rubygems/vendor/uri/lib/uri/http.rb +2 -2
  219. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  220. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  221. data/lib/rubygems/vendor/uri/lib/uri/version.rb +1 -1
  222. data/lib/rubygems/vendor/uri/lib/uri.rb +9 -9
  223. data/lib/rubygems/vendored_securerandom.rb +0 -1
  224. data/lib/rubygems/version.rb +0 -4
  225. data/lib/rubygems.rb +30 -20
  226. data/rubygems-update.gemspec +5 -5
  227. data/setup.rb +1 -1
  228. metadata +36 -27
  229. data/bundler/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  230. data/bundler/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  231. data/bundler/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  232. data/bundler/lib/bundler/vendor/uri/LICENSE.txt +0 -22
  233. data/lib/rubygems/vendor/net-http/LICENSE.txt +0 -22
  234. data/lib/rubygems/vendor/net-http/lib/net/http/backward.rb +0 -40
  235. data/lib/rubygems/vendor/resolv/LICENSE.txt +0 -22
  236. data/lib/rubygems/vendor/securerandom/LICENSE.txt +0 -22
  237. data/lib/rubygems/vendor/securerandom/lib/random/formatter.rb +0 -373
  238. data/lib/rubygems/vendor/timeout/LICENSE.txt +0 -22
  239. data/lib/rubygems/vendor/uri/LICENSE.txt +0 -22
  240. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  241. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  242. /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
 
@@ -365,9 +350,15 @@ By default, this RubyGems will install gem as:
365
350
  def install_default_bundler_gem(bin_dir)
366
351
  current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
367
352
  specs_dir = if current_default_spec && default_dir == Gem.default_dir
353
+ all_specs_current_version = Gem::Specification.stubs.select {|s| s.full_name == current_default_spec.full_name }
354
+
368
355
  Gem::Specification.remove_spec current_default_spec
369
356
  loaded_from = current_default_spec.loaded_from
370
357
  File.delete(loaded_from)
358
+
359
+ # Remove previous default gem executables if they were not shadowed by a regular gem
360
+ FileUtils.rm_rf current_default_spec.full_gem_path if all_specs_current_version.size == 1
361
+
371
362
  File.dirname(loaded_from)
372
363
  else
373
364
  target_specs_dir = File.join(default_dir, "specifications", "default")
@@ -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
@@ -29,6 +29,7 @@ class Gem::GemRunner
29
29
  # Run the gem command with the following arguments.
30
30
 
31
31
  def run(args)
32
+ validate_encoding args
32
33
  build_args = extract_build_args args
33
34
 
34
35
  do_configuration args
@@ -72,6 +73,14 @@ class Gem::GemRunner
72
73
 
73
74
  private
74
75
 
76
+ def validate_encoding(args)
77
+ invalid_arg = args.find {|arg| !arg.valid_encoding? }
78
+
79
+ if invalid_arg
80
+ raise Gem::OptionParser::InvalidArgument.new("'#{invalid_arg.scrub}' has invalid encoding")
81
+ end
82
+ end
83
+
75
84
  def do_configuration(args)
76
85
  Gem.configuration = @config_file_class.new(args)
77
86
  Gem.use_paths Gem.configuration[:gemhome], Gem.configuration[:gempath]
@@ -62,6 +62,10 @@ module Gem::GemcutterUtilities
62
62
  options[:otp] || ENV["GEM_HOST_OTP_CODE"]
63
63
  end
64
64
 
65
+ def webauthn_enabled?
66
+ options[:webauthn]
67
+ end
68
+
65
69
  ##
66
70
  # The host to connect to either from the RUBYGEMS_HOST environment variable
67
71
  # or from the user's configuration
@@ -136,7 +140,6 @@ module Gem::GemcutterUtilities
136
140
  response = rubygems_api_request(:put, "api/v1/api_key",
137
141
  sign_in_host, scope: scope) do |request|
138
142
  request.basic_auth identifier, password
139
- request["OTP"] = otp if otp
140
143
  request.body = Gem::URI.encode_www_form({ api_key: api_key }.merge(update_scope_params))
141
144
  end
142
145
 
@@ -176,7 +179,6 @@ module Gem::GemcutterUtilities
176
179
  response = rubygems_api_request(:post, "api/v1/api_key",
177
180
  sign_in_host, credentials: credentials, scope: scope) do |request|
178
181
  request.basic_auth identifier, password
179
- request["OTP"] = otp if otp
180
182
  request.body = Gem::URI.encode_www_form({ name: key_name }.merge(all_params))
181
183
  end
182
184
 
@@ -251,6 +253,8 @@ module Gem::GemcutterUtilities
251
253
  req["OTP"] = otp if otp
252
254
  block.call(req)
253
255
  end
256
+ ensure
257
+ options[:otp] = nil if webauthn_enabled?
254
258
  end
255
259
 
256
260
  def fetch_otp(credentials)
@@ -271,6 +275,8 @@ module Gem::GemcutterUtilities
271
275
  terminate_interaction(1)
272
276
  end
273
277
 
278
+ options[:webauthn] = true
279
+
274
280
  say "You are verified with a security device. You may close the browser window."
275
281
  otp_thread[:otp]
276
282
  else
@@ -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
@@ -998,18 +998,17 @@ TEXT
998
998
 
999
999
  def bash_prolog_script
1000
1000
  if load_relative_enabled?
1001
- script = +<<~EOS
1002
- bindir="${0%/*}"
1003
- EOS
1004
-
1005
- script << %(exec "$bindir/#{ruby_install_name}" "-x" "$0" "$@"\n)
1006
-
1007
1001
  <<~EOS
1008
1002
  #!/bin/sh
1009
1003
  # -*- ruby -*-
1010
1004
  _=_\\
1011
1005
  =begin
1012
- #{script.chomp}
1006
+ bindir="${0%/*}"
1007
+ ruby="$bindir/#{ruby_install_name}"
1008
+ if [ ! -f "$ruby" ]; then
1009
+ ruby="#{ruby_install_name}"
1010
+ fi
1011
+ exec "$ruby" "-x" "$0" "$@"
1013
1012
  =end
1014
1013
  EOS
1015
1014
  else
@@ -228,6 +228,17 @@ class Gem::Package::TarHeader
228
228
  @checksum = oct calculate_checksum(header), 6
229
229
  end
230
230
 
231
+ ##
232
+ # Header's full name, including prefix
233
+
234
+ def full_name
235
+ if prefix != ""
236
+ File.join prefix, name
237
+ else
238
+ name
239
+ end
240
+ end
241
+
231
242
  private
232
243
 
233
244
  def calculate_checksum(header)
@@ -87,11 +87,7 @@ class Gem::Package::TarReader::Entry
87
87
  # Full name of the tar entry
88
88
 
89
89
  def full_name
90
- if @header.prefix != ""
91
- File.join @header.prefix, @header.name
92
- else
93
- @header.name
94
- end
90
+ @header.full_name.force_encoding(Encoding::UTF_8)
95
91
  rescue ArgumentError => e
96
92
  raise unless e.message == "string contains null byte"
97
93
  raise Gem::Package::TarInvalidError,
@@ -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
  ##