rubygems-update 3.5.5 → 3.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (413) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +606 -1
  3. data/CODE_OF_CONDUCT.md +79 -28
  4. data/Manifest.txt +114 -73
  5. data/README.md +16 -11
  6. data/bundler/CHANGELOG.md +506 -6
  7. data/bundler/README.md +2 -2
  8. data/bundler/bundler.gemspec +2 -2
  9. data/bundler/lib/bundler/build_metadata.rb +2 -2
  10. data/bundler/lib/bundler/checksum.rb +22 -12
  11. data/bundler/lib/bundler/cli/add.rb +3 -1
  12. data/bundler/lib/bundler/cli/binstubs.rb +1 -1
  13. data/bundler/lib/bundler/cli/check.rb +3 -3
  14. data/bundler/lib/bundler/cli/console.rb +8 -10
  15. data/bundler/lib/bundler/cli/doctor/diagnose.rb +167 -0
  16. data/bundler/lib/bundler/cli/doctor/ssl.rb +249 -0
  17. data/bundler/lib/bundler/cli/doctor.rb +27 -151
  18. data/bundler/lib/bundler/cli/exec.rb +1 -0
  19. data/bundler/lib/bundler/cli/fund.rb +1 -1
  20. data/bundler/lib/bundler/cli/gem.rb +13 -17
  21. data/bundler/lib/bundler/cli/info.rb +6 -6
  22. data/bundler/lib/bundler/cli/inject.rb +3 -3
  23. data/bundler/lib/bundler/cli/install.rb +14 -5
  24. data/bundler/lib/bundler/cli/issue.rb +3 -3
  25. data/bundler/lib/bundler/cli/lock.rb +32 -11
  26. data/bundler/lib/bundler/cli/outdated.rb +22 -22
  27. data/bundler/lib/bundler/cli/plugin.rb +3 -2
  28. data/bundler/lib/bundler/cli/pristine.rb +1 -1
  29. data/bundler/lib/bundler/cli/show.rb +3 -3
  30. data/bundler/lib/bundler/cli.rb +51 -107
  31. data/bundler/lib/bundler/compact_index_client/cache.rb +48 -73
  32. data/bundler/lib/bundler/compact_index_client/cache_file.rb +0 -5
  33. data/bundler/lib/bundler/compact_index_client/parser.rb +84 -0
  34. data/bundler/lib/bundler/compact_index_client/updater.rb +2 -12
  35. data/bundler/lib/bundler/compact_index_client.rb +51 -80
  36. data/bundler/lib/bundler/constants.rb +8 -1
  37. data/bundler/lib/bundler/current_ruby.rb +23 -33
  38. data/bundler/lib/bundler/definition.rb +485 -313
  39. data/bundler/lib/bundler/dependency.rb +92 -46
  40. data/bundler/lib/bundler/dsl.rb +135 -101
  41. data/bundler/lib/bundler/endpoint_specification.rb +30 -3
  42. data/bundler/lib/bundler/env.rb +1 -1
  43. data/bundler/lib/bundler/environment_preserver.rb +5 -23
  44. data/bundler/lib/bundler/errors.rb +53 -5
  45. data/bundler/lib/bundler/feature_flag.rb +3 -6
  46. data/bundler/lib/bundler/fetcher/compact_index.rb +16 -25
  47. data/bundler/lib/bundler/fetcher/downloader.rb +1 -1
  48. data/bundler/lib/bundler/fetcher.rb +14 -7
  49. data/bundler/lib/bundler/force_platform.rb +0 -2
  50. data/bundler/lib/bundler/friendly_errors.rb +1 -1
  51. data/bundler/lib/bundler/gem_helper.rb +1 -1
  52. data/bundler/lib/bundler/gem_helpers.rb +36 -19
  53. data/bundler/lib/bundler/gem_version_promoter.rb +42 -40
  54. data/bundler/lib/bundler/injector.rb +14 -16
  55. data/bundler/lib/bundler/inline.rb +42 -17
  56. data/bundler/lib/bundler/installer/gem_installer.rb +4 -3
  57. data/bundler/lib/bundler/installer/parallel_installer.rb +3 -2
  58. data/bundler/lib/bundler/installer/standalone.rb +2 -5
  59. data/bundler/lib/bundler/installer.rb +17 -41
  60. data/bundler/lib/bundler/lazy_specification.rb +117 -46
  61. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  62. data/bundler/lib/bundler/lockfile_parser.rb +18 -7
  63. data/bundler/lib/bundler/man/bundle-add.1 +44 -27
  64. data/bundler/lib/bundler/man/bundle-add.1.ronn +52 -23
  65. data/bundler/lib/bundler/man/bundle-binstubs.1 +9 -6
  66. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  67. data/bundler/lib/bundler/man/bundle-cache.1 +32 -4
  68. data/bundler/lib/bundler/man/bundle-cache.1.ronn +31 -2
  69. data/bundler/lib/bundler/man/bundle-check.1 +7 -5
  70. data/bundler/lib/bundler/man/bundle-check.1.ronn +7 -2
  71. data/bundler/lib/bundler/man/bundle-clean.1 +3 -3
  72. data/bundler/lib/bundler/man/bundle-config.1 +11 -15
  73. data/bundler/lib/bundler/man/bundle-config.1.ronn +12 -15
  74. data/bundler/lib/bundler/man/bundle-console.1 +4 -6
  75. data/bundler/lib/bundler/man/bundle-console.1.ronn +2 -7
  76. data/bundler/lib/bundler/man/bundle-doctor.1 +4 -4
  77. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  78. data/bundler/lib/bundler/man/bundle-env.1 +9 -0
  79. data/bundler/lib/bundler/man/bundle-env.1.ronn +10 -0
  80. data/bundler/lib/bundler/man/bundle-exec.1 +9 -6
  81. data/bundler/lib/bundler/man/bundle-exec.1.ronn +6 -3
  82. data/bundler/lib/bundler/man/bundle-fund.1 +22 -0
  83. data/bundler/lib/bundler/man/bundle-fund.1.ronn +25 -0
  84. data/bundler/lib/bundler/man/bundle-gem.1 +25 -7
  85. data/bundler/lib/bundler/man/bundle-gem.1.ronn +38 -6
  86. data/bundler/lib/bundler/man/bundle-help.1 +3 -3
  87. data/bundler/lib/bundler/man/bundle-info.1 +7 -4
  88. data/bundler/lib/bundler/man/bundle-info.1.ronn +6 -2
  89. data/bundler/lib/bundler/man/bundle-init.1 +5 -5
  90. data/bundler/lib/bundler/man/bundle-init.1.ronn +3 -2
  91. data/bundler/lib/bundler/man/bundle-inject.1 +12 -4
  92. data/bundler/lib/bundler/man/bundle-inject.1.ronn +9 -1
  93. data/bundler/lib/bundler/man/bundle-install.1 +19 -16
  94. data/bundler/lib/bundler/man/bundle-install.1.ronn +24 -20
  95. data/bundler/lib/bundler/man/bundle-issue.1 +45 -0
  96. data/bundler/lib/bundler/man/bundle-issue.1.ronn +37 -0
  97. data/bundler/lib/bundler/man/bundle-licenses.1 +9 -0
  98. data/bundler/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  99. data/bundler/lib/bundler/man/bundle-list.1 +3 -3
  100. data/bundler/lib/bundler/man/bundle-list.1.ronn +4 -1
  101. data/bundler/lib/bundler/man/bundle-lock.1 +23 -8
  102. data/bundler/lib/bundler/man/bundle-lock.1.ronn +25 -4
  103. data/bundler/lib/bundler/man/bundle-open.1 +4 -4
  104. data/bundler/lib/bundler/man/bundle-open.1.ronn +2 -1
  105. data/bundler/lib/bundler/man/bundle-outdated.1 +10 -7
  106. data/bundler/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  107. data/bundler/lib/bundler/man/bundle-platform.1 +3 -3
  108. data/bundler/lib/bundler/man/bundle-plugin.1 +9 -6
  109. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +7 -3
  110. data/bundler/lib/bundler/man/bundle-pristine.1 +3 -3
  111. data/bundler/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  112. data/bundler/lib/bundler/man/bundle-remove.1 +3 -3
  113. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -1
  114. data/bundler/lib/bundler/man/bundle-show.1 +7 -4
  115. data/bundler/lib/bundler/man/bundle-show.1.ronn +4 -0
  116. data/bundler/lib/bundler/man/bundle-update.1 +15 -9
  117. data/bundler/lib/bundler/man/bundle-update.1.ronn +14 -6
  118. data/bundler/lib/bundler/man/bundle-version.1 +3 -3
  119. data/bundler/lib/bundler/man/bundle-viz.1 +6 -6
  120. data/bundler/lib/bundler/man/bundle-viz.1.ronn +7 -3
  121. data/bundler/lib/bundler/man/bundle.1 +3 -3
  122. data/bundler/lib/bundler/man/gemfile.5 +7 -5
  123. data/bundler/lib/bundler/man/gemfile.5.ronn +8 -2
  124. data/bundler/lib/bundler/man/index.txt +4 -0
  125. data/bundler/lib/bundler/match_metadata.rb +13 -0
  126. data/bundler/lib/bundler/materialization.rb +59 -0
  127. data/bundler/lib/bundler/mirror.rb +3 -3
  128. data/bundler/lib/bundler/plugin/api/source.rb +5 -4
  129. data/bundler/lib/bundler/plugin/events.rb +24 -0
  130. data/bundler/lib/bundler/plugin/index.rb +5 -1
  131. data/bundler/lib/bundler/plugin/installer/path.rb +26 -0
  132. data/bundler/lib/bundler/plugin/installer.rb +37 -17
  133. data/bundler/lib/bundler/plugin/source_list.rb +4 -4
  134. data/bundler/lib/bundler/plugin.rb +21 -2
  135. data/bundler/lib/bundler/process_lock.rb +10 -14
  136. data/bundler/lib/bundler/remote_specification.rb +6 -1
  137. data/bundler/lib/bundler/resolver/base.rb +14 -3
  138. data/bundler/lib/bundler/resolver/candidate.rb +18 -27
  139. data/bundler/lib/bundler/resolver/package.rb +20 -3
  140. data/bundler/lib/bundler/resolver/spec_group.rb +22 -27
  141. data/bundler/lib/bundler/resolver/strategy.rb +40 -0
  142. data/bundler/lib/bundler/resolver.rb +114 -50
  143. data/bundler/lib/bundler/retry.rb +1 -1
  144. data/bundler/lib/bundler/ruby_dsl.rb +12 -3
  145. data/bundler/lib/bundler/ruby_version.rb +7 -1
  146. data/bundler/lib/bundler/rubygems_ext.rb +282 -125
  147. data/bundler/lib/bundler/rubygems_gem_installer.rb +40 -5
  148. data/bundler/lib/bundler/rubygems_integration.rb +29 -67
  149. data/bundler/lib/bundler/runtime.rb +48 -35
  150. data/bundler/lib/bundler/self_manager.rb +27 -7
  151. data/bundler/lib/bundler/settings.rb +32 -21
  152. data/bundler/lib/bundler/setup.rb +6 -0
  153. data/bundler/lib/bundler/shared_helpers.rb +39 -21
  154. data/bundler/lib/bundler/source/gemspec.rb +1 -4
  155. data/bundler/lib/bundler/source/git/git_proxy.rb +23 -6
  156. data/bundler/lib/bundler/source/git.rb +113 -41
  157. data/bundler/lib/bundler/source/metadata.rb +4 -3
  158. data/bundler/lib/bundler/source/path.rb +7 -18
  159. data/bundler/lib/bundler/source/rubygems/remote.rb +12 -4
  160. data/bundler/lib/bundler/source/rubygems.rb +54 -48
  161. data/bundler/lib/bundler/source.rb +2 -0
  162. data/bundler/lib/bundler/source_list.rb +53 -7
  163. data/bundler/lib/bundler/spec_set.rb +187 -88
  164. data/bundler/lib/bundler/stub_specification.rb +29 -2
  165. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  166. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +1 -3
  167. data/bundler/lib/bundler/templates/newgem/README.md.tt +7 -3
  168. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  169. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -7
  170. data/bundler/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  171. data/bundler/lib/bundler/ui/shell.rb +24 -2
  172. data/bundler/lib/bundler/ui/silent.rb +12 -1
  173. data/bundler/lib/bundler/uri_credentials_filter.rb +3 -3
  174. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +53 -3
  175. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  176. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +11 -0
  177. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  178. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +68 -30
  179. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +4 -24
  180. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +1 -0
  181. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb +42 -0
  182. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +20 -8
  183. data/bundler/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +17 -29
  184. data/bundler/lib/bundler/vendor/securerandom/COPYING +56 -0
  185. data/bundler/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  196. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  197. data/bundler/lib/bundler/vendor/uri/COPYING +56 -0
  198. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +43 -16
  199. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  200. data/bundler/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  201. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +28 -37
  202. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  203. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -9
  204. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  205. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  206. data/bundler/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  207. data/bundler/lib/bundler/vendored_net_http.rb +20 -5
  208. data/bundler/lib/bundler/vendored_securerandom.rb +12 -0
  209. data/bundler/lib/bundler/vendored_timeout.rb +7 -3
  210. data/bundler/lib/bundler/vendored_uri.rb +18 -1
  211. data/bundler/lib/bundler/version.rb +1 -1
  212. data/bundler/lib/bundler/yaml_serializer.rb +12 -7
  213. data/bundler/lib/bundler.rb +89 -51
  214. data/{CONTRIBUTING.md → doc/rubygems/CONTRIBUTING.md} +10 -14
  215. data/{POLICIES.md → doc/rubygems/POLICIES.md} +81 -12
  216. data/exe/update_rubygems +1 -1
  217. data/lib/rubygems/basic_specification.rb +43 -10
  218. data/lib/rubygems/bundler_version_finder.rb +1 -1
  219. data/lib/rubygems/command.rb +1 -4
  220. data/lib/rubygems/command_manager.rb +5 -6
  221. data/lib/rubygems/commands/build_command.rb +2 -11
  222. data/lib/rubygems/commands/cleanup_command.rb +3 -13
  223. data/lib/rubygems/commands/contents_command.rb +17 -10
  224. data/lib/rubygems/commands/environment_command.rb +5 -0
  225. data/lib/rubygems/commands/exec_command.rb +18 -11
  226. data/lib/rubygems/commands/fetch_command.rb +14 -0
  227. data/lib/rubygems/commands/help_command.rb +2 -2
  228. data/lib/rubygems/commands/install_command.rb +0 -4
  229. data/lib/rubygems/commands/pristine_command.rb +30 -17
  230. data/lib/rubygems/commands/push_command.rb +31 -6
  231. data/lib/rubygems/commands/rdoc_command.rb +3 -10
  232. data/lib/rubygems/commands/rebuild_command.rb +262 -0
  233. data/lib/rubygems/commands/setup_command.rb +11 -16
  234. data/lib/rubygems/commands/sources_command.rb +2 -2
  235. data/lib/rubygems/commands/uninstall_command.rb +9 -4
  236. data/lib/rubygems/commands/unpack_command.rb +0 -6
  237. data/lib/rubygems/commands/update_command.rb +10 -17
  238. data/lib/rubygems/config_file.rb +45 -16
  239. data/lib/rubygems/core_ext/kernel_warn.rb +2 -6
  240. data/lib/rubygems/defaults.rb +6 -6
  241. data/lib/rubygems/dependency.rb +12 -16
  242. data/lib/rubygems/dependency_list.rb +1 -1
  243. data/lib/rubygems/deprecate.rb +79 -77
  244. data/lib/rubygems/errors.rb +2 -1
  245. data/lib/rubygems/exceptions.rb +2 -9
  246. data/lib/rubygems/ext/builder.rb +21 -8
  247. data/lib/rubygems/ext/cargo_builder.rb +12 -26
  248. data/lib/rubygems/ext/cmake_builder.rb +7 -2
  249. data/lib/rubygems/ext/configure_builder.rb +7 -2
  250. data/lib/rubygems/ext/ext_conf_builder.rb +9 -5
  251. data/lib/rubygems/ext/rake_builder.rb +7 -4
  252. data/lib/rubygems/gem_runner.rb +9 -0
  253. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +1 -1
  254. data/lib/rubygems/gemcutter_utilities/webauthn_poller.rb +3 -1
  255. data/lib/rubygems/gemcutter_utilities.rb +52 -26
  256. data/lib/rubygems/gemspec_helpers.rb +19 -0
  257. data/lib/rubygems/install_update_options.rb +5 -0
  258. data/lib/rubygems/installer.rb +31 -40
  259. data/lib/rubygems/local_remote_options.rb +8 -8
  260. data/lib/rubygems/package/tar_header.rb +31 -4
  261. data/lib/rubygems/package/tar_reader/entry.rb +1 -5
  262. data/lib/rubygems/package/tar_writer.rb +5 -4
  263. data/lib/rubygems/package.rb +13 -8
  264. data/lib/rubygems/platform.rb +7 -5
  265. data/lib/rubygems/psych_tree.rb +4 -0
  266. data/lib/rubygems/query_utils.rb +2 -2
  267. data/lib/rubygems/rdoc.rb +16 -3
  268. data/lib/rubygems/remote_fetcher.rb +3 -4
  269. data/lib/rubygems/request.rb +5 -5
  270. data/lib/rubygems/request_set/gem_dependency_api.rb +1 -1
  271. data/lib/rubygems/request_set.rb +1 -1
  272. data/lib/rubygems/requirement.rb +16 -12
  273. data/lib/rubygems/resolver/activation_request.rb +1 -1
  274. data/lib/rubygems/resolver/api_set/gem_parser.rb +2 -5
  275. data/lib/rubygems/resolver/api_set.rb +13 -8
  276. data/lib/rubygems/resolver/best_set.rb +0 -28
  277. data/lib/rubygems/resolver/composed_set.rb +3 -3
  278. data/lib/rubygems/resolver/git_set.rb +0 -1
  279. data/lib/rubygems/resolver/index_set.rb +2 -2
  280. data/lib/rubygems/resolver/spec_specification.rb +7 -0
  281. data/lib/rubygems/resolver.rb +7 -7
  282. data/lib/rubygems/s3_uri_signer.rb +3 -3
  283. data/lib/rubygems/safe_marshal/reader.rb +31 -14
  284. data/lib/rubygems/safe_marshal/visitors/to_ruby.rb +29 -16
  285. data/lib/rubygems/safe_yaml.rb +10 -1
  286. data/lib/rubygems/security.rb +1 -1
  287. data/lib/rubygems/source/git.rb +22 -17
  288. data/lib/rubygems/source/installed.rb +3 -1
  289. data/lib/rubygems/source/local.rb +8 -4
  290. data/lib/rubygems/source/specific_file.rb +5 -3
  291. data/lib/rubygems/source.rb +10 -8
  292. data/lib/rubygems/source_list.rb +1 -1
  293. data/lib/rubygems/spec_fetcher.rb +47 -15
  294. data/lib/rubygems/specification.rb +107 -180
  295. data/lib/rubygems/specification_policy.rb +33 -13
  296. data/lib/rubygems/specification_record.rb +212 -0
  297. data/lib/rubygems/stub_specification.rb +32 -10
  298. data/lib/rubygems/target_rbconfig.rb +50 -0
  299. data/lib/rubygems/uninstaller.rb +42 -22
  300. data/lib/rubygems/uri.rb +6 -6
  301. data/lib/rubygems/util/licenses.rb +97 -1
  302. data/lib/rubygems/util.rb +1 -1
  303. data/lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  304. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/delegates/specification_provider.rb +11 -11
  305. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/action.rb +1 -1
  306. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  307. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  308. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  309. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  310. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/log.rb +1 -1
  311. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  312. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  313. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph/vertex.rb +1 -1
  314. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  315. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/errors.rb +1 -1
  316. data/lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
  317. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/specification_provider.rb +2 -2
  318. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/modules/ui.rb +1 -1
  319. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolution.rb +4 -4
  320. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/resolver.rb +1 -1
  321. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo/state.rb +1 -1
  322. data/lib/rubygems/{resolver → vendor}/molinillo/lib/molinillo.rb +2 -2
  323. data/lib/rubygems/vendor/net-http/COPYING +56 -0
  324. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/generic_request.rb +9 -9
  325. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/header.rb +3 -3
  326. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/request.rb +3 -3
  327. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/requests.rb +35 -30
  328. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/response.rb +2 -2
  329. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/responses.rb +6 -6
  330. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/status.rb +1 -1
  331. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http.rb +135 -51
  332. data/lib/rubygems/{net-http → vendor/net-http}/lib/net/https.rb +1 -1
  333. data/lib/rubygems/vendor/optparse/COPYING +56 -0
  334. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/ac.rb +16 -0
  335. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/kwargs.rb +8 -3
  336. data/lib/rubygems/vendor/optparse/lib/optparse/uri.rb +7 -0
  337. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/version.rb +9 -0
  338. data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse.rb +158 -62
  339. data/lib/rubygems/vendor/resolv/COPYING +56 -0
  340. data/lib/rubygems/{resolv → vendor/resolv}/lib/resolv.rb +117 -49
  341. data/lib/rubygems/vendor/securerandom/COPYING +56 -0
  342. data/lib/rubygems/vendor/securerandom/lib/securerandom.rb +102 -0
  343. data/lib/rubygems/vendor/timeout/.document +1 -0
  344. data/lib/rubygems/vendor/timeout/COPYING +56 -0
  345. data/lib/rubygems/{timeout → vendor/timeout}/lib/timeout.rb +10 -11
  346. data/lib/rubygems/vendor/tsort/.document +1 -0
  347. data/lib/rubygems/{tsort → vendor/tsort}/lib/tsort.rb +2 -2
  348. data/lib/rubygems/vendor/uri/.document +1 -0
  349. data/lib/rubygems/vendor/uri/COPYING +56 -0
  350. data/lib/rubygems/vendor/uri/lib/uri/common.rb +880 -0
  351. data/lib/rubygems/vendor/uri/lib/uri/file.rb +100 -0
  352. data/lib/rubygems/vendor/uri/lib/uri/ftp.rb +267 -0
  353. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +1579 -0
  354. data/lib/rubygems/vendor/uri/lib/uri/http.rb +125 -0
  355. data/lib/rubygems/vendor/uri/lib/uri/https.rb +23 -0
  356. data/lib/rubygems/vendor/uri/lib/uri/ldap.rb +261 -0
  357. data/lib/rubygems/vendor/uri/lib/uri/ldaps.rb +22 -0
  358. data/lib/rubygems/vendor/uri/lib/uri/mailto.rb +293 -0
  359. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  360. data/lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  361. data/lib/rubygems/vendor/uri/lib/uri/version.rb +6 -0
  362. data/lib/rubygems/vendor/uri/lib/uri/ws.rb +83 -0
  363. data/lib/rubygems/vendor/uri/lib/uri/wss.rb +23 -0
  364. data/lib/rubygems/vendor/uri/lib/uri.rb +104 -0
  365. data/lib/rubygems/vendored_molinillo.rb +3 -0
  366. data/lib/rubygems/vendored_net_http.rb +5 -0
  367. data/lib/rubygems/vendored_optparse.rb +3 -0
  368. data/lib/rubygems/vendored_securerandom.rb +3 -0
  369. data/lib/rubygems/vendored_timeout.rb +5 -0
  370. data/lib/rubygems/vendored_tsort.rb +3 -0
  371. data/lib/rubygems/version.rb +26 -9
  372. data/lib/rubygems/yaml_serializer.rb +12 -7
  373. data/lib/rubygems.rb +82 -47
  374. data/rubygems-update.gemspec +11 -6
  375. data/setup.rb +1 -1
  376. metadata +131 -86
  377. data/bundler/lib/bundler/compact_index_client/gem_parser.rb +0 -32
  378. data/lib/rubygems/net/http.rb +0 -3
  379. data/lib/rubygems/net-http/LICENSE.txt +0 -22
  380. data/lib/rubygems/net-http/lib/net/http/backward.rb +0 -40
  381. data/lib/rubygems/net-protocol/LICENSE.txt +0 -22
  382. data/lib/rubygems/optparse/lib/optparse/uri.rb +0 -7
  383. data/lib/rubygems/optparse.rb +0 -3
  384. data/lib/rubygems/resolv/LICENSE.txt +0 -22
  385. data/lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  386. data/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  387. data/lib/rubygems/resolver/molinillo.rb +0 -3
  388. data/lib/rubygems/shellwords.rb +0 -3
  389. data/lib/rubygems/timeout/LICENSE.txt +0 -22
  390. data/lib/rubygems/timeout.rb +0 -3
  391. data/lib/rubygems/tsort/LICENSE.txt +0 -22
  392. data/lib/rubygems/tsort.rb +0 -3
  393. /data/{lib/rubygems/optparse → bundler/lib/bundler/vendor/fileutils}/COPYING +0 -0
  394. /data/{lib/rubygems/net-http → bundler/lib/bundler/vendor/securerandom}/.document +0 -0
  395. /data/{MAINTAINERS.txt → doc/MAINTAINERS.txt} +0 -0
  396. /data/{bundler → doc/bundler}/UPGRADING.md +0 -0
  397. /data/{UPGRADING.md → doc/rubygems/UPGRADING.md} +0 -0
  398. /data/lib/rubygems/{net-protocol → vendor/molinillo}/.document +0 -0
  399. /data/lib/rubygems/{resolver → vendor}/molinillo/LICENSE +0 -0
  400. /data/lib/rubygems/{optparse → vendor/net-http}/.document +0 -0
  401. /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/exceptions.rb +0 -0
  402. /data/lib/rubygems/{net-http → vendor/net-http}/lib/net/http/proxy_delta.rb +0 -0
  403. /data/lib/rubygems/{resolv → vendor/net-protocol}/.document +0 -0
  404. /data/{bundler/lib/bundler/vendor/fileutils → lib/rubygems/vendor/net-protocol}/LICENSE.txt +0 -0
  405. /data/lib/rubygems/{net-protocol → vendor/net-protocol}/lib/net/protocol.rb +0 -0
  406. /data/lib/rubygems/{resolver/molinillo → vendor/optparse}/.document +0 -0
  407. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optionparser.rb +0 -0
  408. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/date.rb +0 -0
  409. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/shellwords.rb +0 -0
  410. /data/lib/rubygems/{optparse → vendor/optparse}/lib/optparse/time.rb +0 -0
  411. /data/lib/rubygems/{timeout → vendor/resolv}/.document +0 -0
  412. /data/lib/rubygems/{tsort → vendor/securerandom}/.document +0 -0
  413. /data/{bundler/lib/bundler/vendor/uri → lib/rubygems/vendor/tsort}/LICENSE.txt +0 -0
@@ -57,7 +57,7 @@ class Gem::Commands::PristineCommand < Gem::Command
57
57
  end
58
58
 
59
59
  add_option("-i", "--install-dir DIR",
60
- "Gem repository to get binstubs and plugins installed") do |value, options|
60
+ "Gem repository to get gems restored") do |value, options|
61
61
  options[:install_dir] = File.expand_path(value)
62
62
  end
63
63
 
@@ -103,22 +103,26 @@ extensions will be restored.
103
103
  end
104
104
 
105
105
  def execute
106
+ install_dir = options[:install_dir]
107
+
108
+ specification_record = install_dir ? Gem::SpecificationRecord.from_path(install_dir) : Gem::Specification.specification_record
109
+
106
110
  specs = if options[:all]
107
- Gem::Specification.map
111
+ specification_record.map
108
112
 
109
113
  # `--extensions` must be explicitly given to pristine only gems
110
114
  # with extensions.
111
115
  elsif options[:extensions_set] &&
112
116
  options[:extensions] && options[:args].empty?
113
- Gem::Specification.select do |spec|
117
+ specification_record.select do |spec|
114
118
  spec.extensions && !spec.extensions.empty?
115
119
  end
116
120
  elsif options[:only_missing_extensions]
117
- Gem::Specification.select(&:missing_extensions?)
121
+ specification_record.select(&:missing_extensions?)
118
122
  else
119
- get_all_gem_names.sort.map do |gem_name|
120
- Gem::Specification.find_all_by_name(gem_name, options[:version]).reverse
121
- end.flatten
123
+ get_all_gem_names.sort.flat_map do |gem_name|
124
+ specification_record.find_all_by_name(gem_name, options[:version]).reverse
125
+ end
122
126
  end
123
127
 
124
128
  specs = specs.select {|spec| spec.platform == RUBY_ENGINE || Gem::Platform.local === spec.platform || spec.platform == Gem::Platform::RUBY }
@@ -130,10 +134,14 @@ extensions will be restored.
130
134
 
131
135
  say "Restoring gems to pristine condition..."
132
136
 
133
- specs.each do |spec|
134
- if spec.default_gem?
135
- say "Skipped #{spec.full_name}, it is a default gem"
136
- next
137
+ specs.group_by(&:full_name_with_location).values.each do |grouped_specs|
138
+ spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first
139
+
140
+ unless only_executables_or_plugins?
141
+ # Default gemspecs include changes provided by ruby-core installer that
142
+ # can't currently be pristined (inclusion of compiled extension targets in
143
+ # the file list). So stick to resetting executables if it's a default gem.
144
+ options[:only_executables] = true if spec.default_gem?
137
145
  end
138
146
 
139
147
  if options.key? :skip
@@ -143,17 +151,17 @@ extensions will be restored.
143
151
  end
144
152
  end
145
153
 
146
- unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
147
- say "Skipped #{spec.full_name}, it needs to compile an extension"
154
+ unless spec.extensions.empty? || options[:extensions] || only_executables_or_plugins?
155
+ say "Skipped #{spec.full_name_with_location}, it needs to compile an extension"
148
156
  next
149
157
  end
150
158
 
151
159
  gem = spec.cache_file
152
160
 
153
- unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
161
+ unless File.exist?(gem) || only_executables_or_plugins?
154
162
  require_relative "../remote_fetcher"
155
163
 
156
- say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
164
+ say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..."
157
165
 
158
166
  dep = Gem::Dependency.new spec.name, spec.version
159
167
  found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
@@ -176,7 +184,6 @@ extensions will be restored.
176
184
  end
177
185
 
178
186
  bin_dir = options[:bin_dir] if options[:bin_dir]
179
- install_dir = options[:install_dir] if options[:install_dir]
180
187
 
181
188
  installer_options = {
182
189
  wrappers: true,
@@ -198,7 +205,13 @@ extensions will be restored.
198
205
  installer.install
199
206
  end
200
207
 
201
- say "Restored #{spec.full_name}"
208
+ say "Restored #{spec.full_name_with_location}"
202
209
  end
203
210
  end
211
+
212
+ private
213
+
214
+ def only_executables_or_plugins?
215
+ options[:only_executables] || options[:only_plugins]
216
+ end
204
217
  end
@@ -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
 
@@ -87,11 +92,20 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
87
92
  private
88
93
 
89
94
  def send_push_request(name, args)
90
- 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
95
+ scope = get_push_scope
96
+ rubygems_api_request(*args, scope: scope) do |request|
97
+ body = Gem.read_binary name
98
+ if options[:attestations].any?
99
+ request.set_form([
100
+ ["gem", body, { filename: name, content_type: "application/octet-stream" }],
101
+ get_attestations_part,
102
+ ], "multipart/form-data")
103
+ else
104
+ request.body = body
105
+ request.add_field "Content-Type", "application/octet-stream"
106
+ request.add_field "Content-Length", request.body.size
107
+ end
108
+ request.add_field "Authorization", api_key
95
109
  end
96
110
  end
97
111
 
@@ -107,4 +121,15 @@ The push command will use ~/.gem/credentials to authenticate to a server, but yo
107
121
  def get_push_scope
108
122
  :push_rubygem
109
123
  end
124
+
125
+ def get_attestations_part
126
+ bundles = "[" + options[:attestations].map do |attestation|
127
+ Gem.read_binary(attestation)
128
+ end.join(",") + "]"
129
+ [
130
+ "attestations",
131
+ bundles,
132
+ { content_type: "application/json" },
133
+ ]
134
+ end
110
135
  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?
@@ -84,14 +84,7 @@ Use --overwrite to force rebuilding of documentation.
84
84
  FileUtils.rm_rf File.join(spec.doc_dir, "rdoc")
85
85
  end
86
86
 
87
- begin
88
- doc.generate
89
- rescue Errno::ENOENT => e
90
- match = / - /.match(e.message)
91
- alert_error "Unable to document #{spec.full_name}, " \
92
- " #{match.post_match} is missing, skipping"
93
- terminate_interaction 1 if specs.length == 1
94
- end
87
+ doc.generate
95
88
  end
96
89
  end
97
90
  end
@@ -0,0 +1,262 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "digest"
5
+ require "fileutils"
6
+ require "tmpdir"
7
+ require_relative "../gemspec_helpers"
8
+ require_relative "../package"
9
+
10
+ class Gem::Commands::RebuildCommand < Gem::Command
11
+ include Gem::GemspecHelpers
12
+
13
+ def initialize
14
+ super "rebuild", "Attempt to reproduce a build of a gem."
15
+
16
+ add_option "--diff", "If the files don't match, compare them using diffoscope." do |_value, options|
17
+ options[:diff] = true
18
+ end
19
+
20
+ add_option "--force", "Skip validation of the spec." do |_value, options|
21
+ options[:force] = true
22
+ end
23
+
24
+ add_option "--strict", "Consider warnings as errors when validating the spec." do |_value, options|
25
+ options[:strict] = true
26
+ end
27
+
28
+ add_option "--source GEM_SOURCE", "Specify the source to download the gem from." do |value, options|
29
+ options[:source] = value
30
+ end
31
+
32
+ add_option "--original GEM_FILE", "Specify a local file to compare against (instead of downloading it)." do |value, options|
33
+ options[:original_gem_file] = value
34
+ end
35
+
36
+ add_option "--gemspec GEMSPEC_FILE", "Specify the name of the gemspec file." do |value, options|
37
+ options[:gemspec_file] = value
38
+ end
39
+
40
+ add_option "-C PATH", "Run as if gem build was started in <PATH> instead of the current working directory." do |value, options|
41
+ options[:build_path] = value
42
+ end
43
+ end
44
+
45
+ def arguments # :nodoc:
46
+ "GEM_NAME gem name on gem server\n" \
47
+ "GEM_VERSION gem version you are attempting to rebuild"
48
+ end
49
+
50
+ def description # :nodoc:
51
+ <<-EOF
52
+ The rebuild command allows you to (attempt to) reproduce a build of a gem
53
+ from a ruby gemspec.
54
+
55
+ This command assumes the gemspec can be built with the `gem build` command.
56
+ If you use any of `gem build`, `rake build`, or`rake release` in the
57
+ build/release process for a gem, it is a potential candidate.
58
+
59
+ You will need to match the RubyGems version used, since this is included in
60
+ the Gem metadata.
61
+
62
+ If the gem includes lockfiles (e.g. Gemfile.lock) and similar, it will
63
+ require more effort to reproduce a build. For example, it might require
64
+ more precisely matched versions of Ruby and/or Bundler to be used.
65
+ EOF
66
+ end
67
+
68
+ def usage # :nodoc:
69
+ "#{program_name} GEM_NAME GEM_VERSION"
70
+ end
71
+
72
+ def execute
73
+ gem_name, gem_version = get_gem_name_and_version
74
+
75
+ old_dir, new_dir = prep_dirs
76
+
77
+ gem_filename = "#{gem_name}-#{gem_version}.gem"
78
+ old_file = File.join(old_dir, gem_filename)
79
+ new_file = File.join(new_dir, gem_filename)
80
+
81
+ if options[:original_gem_file]
82
+ FileUtils.copy_file(options[:original_gem_file], old_file)
83
+ else
84
+ download_gem(gem_name, gem_version, old_file)
85
+ end
86
+
87
+ rg_version = rubygems_version(old_file)
88
+ unless rg_version == Gem::VERSION
89
+ alert_error <<-EOF
90
+ You need to use the same RubyGems version #{gem_name} v#{gem_version} was built with.
91
+
92
+ #{gem_name} v#{gem_version} was built using RubyGems v#{rg_version}.
93
+ Gem files include the version of RubyGems used to build them.
94
+ This means in order to reproduce #{gem_filename}, you must also use RubyGems v#{rg_version}.
95
+
96
+ You're using RubyGems v#{Gem::VERSION}.
97
+
98
+ Please install RubyGems v#{rg_version} and try again.
99
+ EOF
100
+ terminate_interaction 1
101
+ end
102
+
103
+ source_date_epoch = get_timestamp(old_file).to_s
104
+
105
+ if build_path = options[:build_path]
106
+ Dir.chdir(build_path) { build_gem(gem_name, source_date_epoch, new_file) }
107
+ else
108
+ build_gem(gem_name, source_date_epoch, new_file)
109
+ end
110
+
111
+ compare(source_date_epoch, old_file, new_file)
112
+ end
113
+
114
+ private
115
+
116
+ def sha256(file)
117
+ Digest::SHA256.hexdigest(Gem.read_binary(file))
118
+ end
119
+
120
+ def get_timestamp(file)
121
+ mtime = nil
122
+ File.open(file, Gem.binary_mode) do |f|
123
+ Gem::Package::TarReader.new(f) do |tar|
124
+ mtime = tar.seek("metadata.gz") {|tf| tf.header.mtime }
125
+ end
126
+ end
127
+
128
+ mtime
129
+ end
130
+
131
+ def compare(source_date_epoch, old_file, new_file)
132
+ date = Time.at(source_date_epoch.to_i).strftime("%F %T %Z")
133
+
134
+ old_hash = sha256(old_file)
135
+ new_hash = sha256(new_file)
136
+
137
+ say
138
+ say "Built at: #{date} (#{source_date_epoch})"
139
+ say "Original build saved to: #{old_file}"
140
+ say "Reproduced build saved to: #{new_file}"
141
+ say "Working directory: #{options[:build_path] || Dir.pwd}"
142
+ say
143
+ say "Hash comparison:"
144
+ say " #{old_hash}\t#{old_file}"
145
+ say " #{new_hash}\t#{new_file}"
146
+ say
147
+
148
+ if old_hash == new_hash
149
+ say "SUCCESS - original and rebuild hashes matched"
150
+ else
151
+ say "FAILURE - original and rebuild hashes did not match"
152
+ say
153
+
154
+ if options[:diff]
155
+ if system("diffoscope", old_file, new_file).nil?
156
+ alert_error "error: could not find `diffoscope` executable"
157
+ end
158
+ else
159
+ say "Pass --diff for more details (requires diffoscope to be installed)."
160
+ end
161
+
162
+ terminate_interaction 1
163
+ end
164
+ end
165
+
166
+ def prep_dirs
167
+ rebuild_dir = Dir.mktmpdir("gem_rebuild")
168
+ old_dir = File.join(rebuild_dir, "old")
169
+ new_dir = File.join(rebuild_dir, "new")
170
+
171
+ FileUtils.mkdir_p(old_dir)
172
+ FileUtils.mkdir_p(new_dir)
173
+
174
+ [old_dir, new_dir]
175
+ end
176
+
177
+ def get_gem_name_and_version
178
+ args = options[:args] || []
179
+ if args.length == 2
180
+ gem_name, gem_version = args
181
+ elsif args.length > 2
182
+ raise Gem::CommandLineError, "Too many arguments"
183
+ else
184
+ raise Gem::CommandLineError, "Expected GEM_NAME and GEM_VERSION arguments (gem rebuild GEM_NAME GEM_VERSION)"
185
+ end
186
+
187
+ [gem_name, gem_version]
188
+ end
189
+
190
+ def build_gem(gem_name, source_date_epoch, output_file)
191
+ gemspec = options[:gemspec_file] || find_gemspec("#{gem_name}.gemspec")
192
+
193
+ if gemspec
194
+ build_package(gemspec, source_date_epoch, output_file)
195
+ else
196
+ alert_error error_message(gem_name)
197
+ terminate_interaction(1)
198
+ end
199
+ end
200
+
201
+ def build_package(gemspec, source_date_epoch, output_file)
202
+ with_source_date_epoch(source_date_epoch) do
203
+ spec = Gem::Specification.load(gemspec)
204
+ if spec
205
+ Gem::Package.build(
206
+ spec,
207
+ options[:force],
208
+ options[:strict],
209
+ output_file
210
+ )
211
+ else
212
+ alert_error "Error loading gemspec. Aborting."
213
+ terminate_interaction 1
214
+ end
215
+ end
216
+ end
217
+
218
+ def with_source_date_epoch(source_date_epoch)
219
+ old_sde = ENV["SOURCE_DATE_EPOCH"]
220
+ ENV["SOURCE_DATE_EPOCH"] = source_date_epoch.to_s
221
+
222
+ yield
223
+ ensure
224
+ ENV["SOURCE_DATE_EPOCH"] = old_sde
225
+ end
226
+
227
+ def error_message(gem_name)
228
+ if gem_name
229
+ "Couldn't find a gemspec file matching '#{gem_name}' in #{Dir.pwd}"
230
+ else
231
+ "Couldn't find a gemspec file in #{Dir.pwd}"
232
+ end
233
+ end
234
+
235
+ def download_gem(gem_name, gem_version, old_file)
236
+ # This code was based loosely off the `gem fetch` command.
237
+ version = "= #{gem_version}"
238
+ dep = Gem::Dependency.new gem_name, version
239
+
240
+ specs_and_sources, errors =
241
+ Gem::SpecFetcher.fetcher.spec_for_dependency dep
242
+
243
+ # There should never be more than one item in specs_and_sources,
244
+ # since we search for an exact version.
245
+ spec, source = specs_and_sources[0]
246
+
247
+ if spec.nil?
248
+ show_lookup_failure gem_name, version, errors, options[:domain]
249
+ terminate_interaction 1
250
+ end
251
+
252
+ download_path = source.download spec
253
+
254
+ FileUtils.move(download_path, old_file)
255
+
256
+ say "Downloaded #{gem_name} version #{gem_version} as #{old_file}."
257
+ end
258
+
259
+ def rubygems_version(gem_file)
260
+ Gem::Package.new(gem_file).spec.rubygems_version
261
+ end
262
+ end
@@ -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
 
@@ -340,6 +325,8 @@ By default, this RubyGems will install gem as:
340
325
 
341
326
  require_relative "../rdoc"
342
327
 
328
+ return false unless defined?(Gem::RDoc)
329
+
343
330
  fake_spec = Gem::Specification.new "rubygems", Gem::VERSION
344
331
  def fake_spec.full_gem_path
345
332
  File.expand_path "../../..", __dir__
@@ -363,9 +350,15 @@ By default, this RubyGems will install gem as:
363
350
  def install_default_bundler_gem(bin_dir)
364
351
  current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
365
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
+
366
355
  Gem::Specification.remove_spec current_default_spec
367
356
  loaded_from = current_default_spec.loaded_from
368
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
+
369
362
  File.dirname(loaded_from)
370
363
  else
371
364
  target_specs_dir = File.join(default_dir, "specifications", "default")
@@ -585,6 +578,8 @@ abort "#{deprecation_message}"
585
578
 
586
579
  args = %w[--all --only-executables --silent]
587
580
  args << "--bindir=#{bindir}"
581
+ args << "--install-dir=#{default_dir}"
582
+
588
583
  if options[:env_shebang]
589
584
  args << "--env-shebang"
590
585
  end
@@ -59,7 +59,7 @@ class Gem::Commands::SourcesCommand < Gem::Command
59
59
 
60
60
  say "#{source_uri} added to sources"
61
61
  end
62
- rescue URI::Error, ArgumentError
62
+ rescue Gem::URI::Error, ArgumentError
63
63
  say "#{source_uri} is not a URI"
64
64
  terminate_interaction 1
65
65
  rescue Gem::RemoteFetcher::FetchError => e
@@ -81,7 +81,7 @@ Do you want to add this source?
81
81
  end
82
82
 
83
83
  def check_rubygems_https(source_uri) # :nodoc:
84
- uri = URI source_uri
84
+ uri = Gem::URI source_uri
85
85
 
86
86
  if uri.scheme && uri.scheme.casecmp("http").zero? &&
87
87
  uri.host.casecmp("rubygems.org").zero?
@@ -157,9 +157,14 @@ that is a dependency of an existing gem. You can use the
157
157
 
158
158
  gem_specs = Gem::Specification.find_all_by_name(name, original_gem_version[name])
159
159
 
160
- say("Gem '#{name}' is not installed") if gem_specs.empty?
161
- gem_specs.each do |spec|
162
- deplist.add spec
160
+ if gem_specs.empty?
161
+ say("Gem '#{name}' is not installed")
162
+ else
163
+ gem_specs.reject!(&:default_gem?) if gem_specs.size > 1
164
+
165
+ gem_specs.each do |spec|
166
+ deplist.add spec
167
+ end
163
168
  end
164
169
  end
165
170
 
@@ -184,7 +189,7 @@ that is a dependency of an existing gem. You can use the
184
189
  rescue Gem::GemNotInHomeException => e
185
190
  spec = e.spec
186
191
  alert("In order to remove #{spec.name}, please execute:\n" \
187
- "\tgem uninstall #{spec.name} --install-dir=#{spec.installation_path}")
192
+ "\tgem uninstall #{spec.name} --install-dir=#{spec.base_dir}")
188
193
  rescue Gem::UninstallError => e
189
194
  spec = e.spec
190
195
  alert_error("Error: unable to successfully uninstall '#{spec.name}' which is " \
@@ -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)
@@ -197,18 +197,17 @@ command to remove old versions.
197
197
  yield
198
198
  else
199
199
  require "tmpdir"
200
- tmpdir = Dir.mktmpdir
201
- FileUtils.mv Gem.plugindir, tmpdir
200
+ Dir.mktmpdir("gem_update") do |tmpdir|
201
+ FileUtils.mv Gem.plugindir, tmpdir
202
202
 
203
- status = yield
203
+ status = yield
204
204
 
205
- if status
206
- FileUtils.rm_rf tmpdir
207
- else
208
- FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugindir
209
- end
205
+ unless status
206
+ FileUtils.mv File.join(tmpdir, "plugins"), Gem.plugindir
207
+ end
210
208
 
211
- status
209
+ status
210
+ end
212
211
  end
213
212
  end
214
213
 
@@ -318,16 +317,10 @@ command to remove old versions.
318
317
 
319
318
  #
320
319
  # Oldest version we support downgrading to. This is the version that
321
- # originally ships with the first patch version of each ruby, because we never
322
- # test each ruby against older rubygems, so we can't really guarantee it
323
- # works. Version list can be checked here: https://stdgems.org/rubygems
320
+ # originally ships with the oldest supported patch version of ruby.
324
321
  #
325
322
  def oldest_supported_version
326
323
  @oldest_supported_version ||=
327
- if Gem.ruby_version > Gem::Version.new("3.1.a")
328
- Gem::Version.new("3.3.3")
329
- else
330
- Gem::Version.new("3.2.3")
331
- end
324
+ Gem::Version.new("3.3.3")
332
325
  end
333
326
  end