bundler 1.17.3 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (426) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3354 -1258
  3. data/LICENSE.md +18 -19
  4. data/README.md +10 -15
  5. data/bundler.gemspec +15 -33
  6. data/exe/bundle +8 -10
  7. data/exe/bundler +1 -1
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +5 -13
  10. data/lib/bundler/capistrano.rb +5 -5
  11. data/lib/bundler/checksum.rb +254 -0
  12. data/lib/bundler/ci_detector.rb +75 -0
  13. data/lib/bundler/cli/add.rb +29 -15
  14. data/lib/bundler/cli/binstubs.rb +13 -5
  15. data/lib/bundler/cli/cache.rb +24 -17
  16. data/lib/bundler/cli/check.rb +7 -5
  17. data/lib/bundler/cli/clean.rb +1 -1
  18. data/lib/bundler/cli/common.rb +50 -14
  19. data/lib/bundler/cli/config.rb +171 -86
  20. data/lib/bundler/cli/console.rb +3 -6
  21. data/lib/bundler/cli/doctor.rb +29 -12
  22. data/lib/bundler/cli/exec.rb +9 -25
  23. data/lib/bundler/cli/fund.rb +36 -0
  24. data/lib/bundler/cli/gem.rb +268 -53
  25. data/lib/bundler/cli/info.rb +51 -18
  26. data/lib/bundler/cli/init.rb +7 -3
  27. data/lib/bundler/cli/inject.rb +2 -2
  28. data/lib/bundler/cli/install.rb +55 -73
  29. data/lib/bundler/cli/issue.rb +9 -8
  30. data/lib/bundler/cli/list.rb +19 -11
  31. data/lib/bundler/cli/lock.rb +56 -26
  32. data/lib/bundler/cli/open.rb +10 -7
  33. data/lib/bundler/cli/outdated.rb +159 -128
  34. data/lib/bundler/cli/platform.rb +8 -6
  35. data/lib/bundler/cli/plugin.rb +23 -12
  36. data/lib/bundler/cli/pristine.rb +39 -26
  37. data/lib/bundler/cli/remove.rb +1 -2
  38. data/lib/bundler/cli/show.rb +7 -7
  39. data/lib/bundler/cli/update.rb +51 -19
  40. data/lib/bundler/cli/viz.rb +1 -1
  41. data/lib/bundler/cli.rb +399 -390
  42. data/lib/bundler/compact_index_client/cache.rb +55 -77
  43. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  44. data/lib/bundler/compact_index_client/gem_parser.rb +32 -0
  45. data/lib/bundler/compact_index_client/parser.rb +84 -0
  46. data/lib/bundler/compact_index_client/updater.rb +72 -84
  47. data/lib/bundler/compact_index_client.rb +61 -73
  48. data/lib/bundler/constants.rb +9 -2
  49. data/lib/bundler/current_ruby.rb +20 -21
  50. data/lib/bundler/definition.rb +663 -505
  51. data/lib/bundler/dependency.rb +38 -71
  52. data/lib/bundler/deployment.rb +1 -1
  53. data/lib/bundler/digest.rb +71 -0
  54. data/lib/bundler/dsl.rb +171 -152
  55. data/lib/bundler/endpoint_specification.rb +43 -17
  56. data/lib/bundler/env.rb +11 -18
  57. data/lib/bundler/environment_preserver.rb +17 -8
  58. data/lib/bundler/errors.rb +115 -14
  59. data/lib/bundler/feature_flag.rb +15 -39
  60. data/lib/bundler/fetcher/base.rb +12 -12
  61. data/lib/bundler/fetcher/compact_index.rb +41 -47
  62. data/lib/bundler/fetcher/dependency.rb +4 -8
  63. data/lib/bundler/fetcher/downloader.rb +27 -20
  64. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  65. data/lib/bundler/fetcher/index.rb +6 -33
  66. data/lib/bundler/fetcher.rb +109 -90
  67. data/lib/bundler/force_platform.rb +16 -0
  68. data/lib/bundler/friendly_errors.rb +50 -55
  69. data/lib/bundler/gem_helper.rb +81 -46
  70. data/lib/bundler/gem_helpers.rb +78 -29
  71. data/lib/bundler/gem_tasks.rb +1 -1
  72. data/lib/bundler/gem_version_promoter.rb +68 -109
  73. data/lib/bundler/graph.rb +11 -11
  74. data/lib/bundler/index.rb +74 -82
  75. data/lib/bundler/injector.rb +58 -26
  76. data/lib/bundler/inline.rb +59 -35
  77. data/lib/bundler/installer/gem_installer.rb +29 -29
  78. data/lib/bundler/installer/parallel_installer.rb +38 -68
  79. data/lib/bundler/installer/standalone.rb +76 -16
  80. data/lib/bundler/installer.rb +60 -135
  81. data/lib/bundler/lazy_specification.rb +161 -63
  82. data/lib/bundler/lockfile_generator.rb +14 -5
  83. data/lib/bundler/lockfile_parser.rb +150 -109
  84. data/lib/bundler/man/bundle-add.1 +76 -0
  85. data/lib/bundler/man/bundle-add.1.ronn +87 -0
  86. data/{man → lib/bundler/man}/bundle-binstubs.1 +15 -22
  87. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +8 -7
  88. data/lib/bundler/man/bundle-cache.1 +68 -0
  89. data/lib/bundler/man/bundle-cache.1.ronn +108 -0
  90. data/{man → lib/bundler/man}/bundle-check.1 +7 -14
  91. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +7 -2
  92. data/{man → lib/bundler/man}/bundle-clean.1 +4 -11
  93. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  94. data/{man → lib/bundler/man}/bundle-config.1 +80 -260
  95. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +104 -98
  96. data/lib/bundler/man/bundle-console.1 +33 -0
  97. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  98. data/{man → lib/bundler/man}/bundle-doctor.1 +5 -19
  99. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +1 -1
  100. data/lib/bundler/man/bundle-env.1 +9 -0
  101. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  102. data/{man → lib/bundler/man}/bundle-exec.1 +20 -78
  103. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +12 -10
  104. data/lib/bundler/man/bundle-fund.1 +22 -0
  105. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  106. data/lib/bundler/man/bundle-gem.1 +87 -0
  107. data/lib/bundler/man/bundle-gem.1.ronn +149 -0
  108. data/lib/bundler/man/bundle-help.1 +9 -0
  109. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/lib/bundler/man/bundle-info.1 +17 -0
  111. data/lib/bundler/man/bundle-info.1.ronn +21 -0
  112. data/{man → lib/bundler/man}/bundle-init.1 +8 -13
  113. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +5 -2
  114. data/lib/bundler/man/bundle-inject.1 +31 -0
  115. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +12 -2
  116. data/{man → lib/bundler/man}/bundle-install.1 +65 -155
  117. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +66 -57
  118. data/lib/bundler/man/bundle-issue.1 +45 -0
  119. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  120. data/lib/bundler/man/bundle-licenses.1 +9 -0
  121. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  122. data/{man → lib/bundler/man}/bundle-list.1 +9 -24
  123. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +10 -7
  124. data/{man → lib/bundler/man}/bundle-lock.1 +25 -34
  125. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +25 -4
  126. data/lib/bundler/man/bundle-open.1 +32 -0
  127. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +10 -1
  128. data/{man → lib/bundler/man}/bundle-outdated.1 +23 -75
  129. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +21 -22
  130. data/lib/bundler/man/bundle-platform.1 +49 -0
  131. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  132. data/lib/bundler/man/bundle-plugin.1 +58 -0
  133. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  134. data/{man → lib/bundler/man}/bundle-pristine.1 +5 -16
  135. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +1 -1
  136. data/{man → lib/bundler/man}/bundle-remove.1 +4 -14
  137. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +1 -1
  138. data/{man → lib/bundler/man}/bundle-show.1 +7 -11
  139. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +4 -0
  140. data/{man → lib/bundler/man}/bundle-update.1 +35 -148
  141. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +21 -12
  142. data/lib/bundler/man/bundle-version.1 +22 -0
  143. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  144. data/{man → lib/bundler/man}/bundle-viz.1 +9 -18
  145. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +9 -3
  146. data/{man → lib/bundler/man}/bundle.1 +19 -53
  147. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  148. data/{man → lib/bundler/man}/gemfile.5 +139 -356
  149. data/{man → lib/bundler/man}/gemfile.5.ronn +134 -97
  150. data/{man → lib/bundler/man}/index.txt +9 -1
  151. data/lib/bundler/match_metadata.rb +17 -0
  152. data/lib/bundler/match_platform.rb +2 -3
  153. data/lib/bundler/match_remote_metadata.rb +29 -0
  154. data/lib/bundler/materialization.rb +59 -0
  155. data/lib/bundler/mirror.rb +10 -12
  156. data/lib/bundler/plugin/api/source.rb +34 -18
  157. data/lib/bundler/plugin/api.rb +1 -1
  158. data/lib/bundler/plugin/dsl.rb +1 -1
  159. data/lib/bundler/plugin/events.rb +24 -0
  160. data/lib/bundler/plugin/index.rb +44 -9
  161. data/lib/bundler/plugin/installer/git.rb +0 -4
  162. data/lib/bundler/plugin/installer/path.rb +18 -0
  163. data/lib/bundler/plugin/installer/rubygems.rb +1 -9
  164. data/lib/bundler/plugin/installer.rb +63 -27
  165. data/lib/bundler/plugin/source_list.rb +5 -1
  166. data/lib/bundler/plugin.rb +131 -45
  167. data/lib/bundler/process_lock.rb +10 -14
  168. data/lib/bundler/remote_specification.rb +22 -10
  169. data/lib/bundler/resolver/base.rb +118 -0
  170. data/lib/bundler/resolver/candidate.rb +82 -0
  171. data/lib/bundler/resolver/incompatibility.rb +15 -0
  172. data/lib/bundler/resolver/package.rb +90 -0
  173. data/lib/bundler/resolver/root.rb +25 -0
  174. data/lib/bundler/resolver/spec_group.rb +60 -68
  175. data/lib/bundler/resolver.rb +454 -303
  176. data/lib/bundler/retry.rb +6 -6
  177. data/lib/bundler/ruby_dsl.rb +51 -7
  178. data/lib/bundler/ruby_version.rb +23 -38
  179. data/lib/bundler/rubygems_ext.rb +357 -98
  180. data/lib/bundler/rubygems_gem_installer.rb +131 -65
  181. data/lib/bundler/rubygems_integration.rb +149 -591
  182. data/lib/bundler/runtime.rb +51 -51
  183. data/lib/bundler/safe_marshal.rb +31 -0
  184. data/lib/bundler/self_manager.rb +206 -0
  185. data/lib/bundler/settings.rb +271 -135
  186. data/lib/bundler/setup.rb +23 -12
  187. data/lib/bundler/shared_helpers.rb +127 -117
  188. data/lib/bundler/similarity_detector.rb +3 -3
  189. data/lib/bundler/source/git/git_proxy.rb +326 -127
  190. data/lib/bundler/source/git.rb +207 -88
  191. data/lib/bundler/source/metadata.rb +19 -18
  192. data/lib/bundler/source/path/installer.rb +11 -32
  193. data/lib/bundler/source/path.rb +39 -38
  194. data/lib/bundler/source/rubygems/remote.rb +3 -4
  195. data/lib/bundler/source/rubygems.rb +223 -255
  196. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  197. data/lib/bundler/source.rb +33 -11
  198. data/lib/bundler/source_list.rb +131 -66
  199. data/lib/bundler/source_map.rb +71 -0
  200. data/lib/bundler/spec_set.rb +239 -94
  201. data/lib/bundler/stub_specification.rb +77 -39
  202. data/lib/bundler/templates/Executable +3 -5
  203. data/lib/bundler/templates/Executable.bundler +23 -19
  204. data/lib/bundler/templates/Executable.standalone +4 -4
  205. data/lib/bundler/templates/Gemfile +0 -2
  206. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  207. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +104 -46
  208. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  209. data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
  210. data/lib/bundler/templates/newgem/README.md.tt +18 -16
  211. data/lib/bundler/templates/newgem/Rakefile.tt +44 -6
  212. data/lib/bundler/templates/newgem/bin/console.tt +1 -4
  213. data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  214. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  215. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  216. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  217. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  218. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  219. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  220. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  221. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  222. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  223. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  224. data/lib/bundler/templates/newgem/newgem.gemspec.tt +37 -40
  225. data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  226. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  227. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  228. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  229. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  230. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  231. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  232. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  233. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  234. data/lib/bundler/ui/rg_proxy.rb +2 -2
  235. data/lib/bundler/ui/shell.rb +64 -23
  236. data/lib/bundler/ui/silent.rb +33 -6
  237. data/lib/bundler/ui.rb +3 -3
  238. data/lib/bundler/uri_credentials_filter.rb +11 -5
  239. data/lib/bundler/uri_normalizer.rb +23 -0
  240. data/lib/bundler/vendor/.document +1 -0
  241. data/lib/bundler/vendor/connection_pool/.document +1 -0
  242. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  243. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  244. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  245. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  246. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +175 -0
  247. data/lib/bundler/vendor/fileutils/.document +1 -0
  248. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  249. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1490 -432
  250. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  251. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  252. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  253. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  254. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  255. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +362 -484
  256. data/lib/bundler/vendor/pub_grub/.document +1 -0
  257. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  258. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  259. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  260. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  261. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  262. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  263. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  264. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  265. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  266. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  267. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  268. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  269. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  270. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  271. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  272. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  273. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  274. data/lib/bundler/vendor/securerandom/.document +1 -0
  275. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  276. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  277. data/lib/bundler/vendor/thor/.document +1 -0
  278. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  279. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +4 -3
  280. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  281. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +8 -18
  282. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  283. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +27 -20
  284. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +34 -13
  285. data/lib/bundler/vendor/thor/lib/thor/actions.rb +47 -28
  286. data/lib/bundler/vendor/thor/lib/thor/base.rb +200 -54
  287. data/lib/bundler/vendor/thor/lib/thor/command.rb +34 -18
  288. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  289. data/lib/bundler/vendor/thor/lib/thor/error.rb +74 -0
  290. data/lib/bundler/vendor/thor/lib/thor/group.rb +15 -4
  291. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +2 -1
  292. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  293. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  294. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  295. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  296. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
  297. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +35 -15
  298. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +45 -13
  299. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +86 -13
  300. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  301. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +3 -2
  302. data/lib/bundler/vendor/thor/lib/thor/runner.rb +51 -40
  303. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +99 -148
  304. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -43
  305. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  306. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -49
  307. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  308. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  309. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  310. data/lib/bundler/vendor/thor/lib/thor/shell.rb +6 -6
  311. data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
  312. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  313. data/lib/bundler/vendor/thor/lib/thor.rb +182 -17
  314. data/lib/bundler/vendor/tsort/.document +1 -0
  315. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  316. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  317. data/lib/bundler/vendor/uri/.document +1 -0
  318. data/lib/bundler/vendor/uri/COPYING +56 -0
  319. data/lib/bundler/vendor/uri/lib/uri/common.rb +876 -0
  320. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  321. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  322. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1578 -0
  323. data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  324. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  325. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  326. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  327. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  328. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  329. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  330. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  331. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  332. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  333. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  334. data/lib/bundler/vendored_fileutils.rb +1 -6
  335. data/lib/bundler/vendored_net_http.rb +23 -0
  336. data/lib/bundler/vendored_persistent.rb +1 -42
  337. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  338. data/lib/bundler/vendored_securerandom.rb +12 -0
  339. data/lib/bundler/vendored_thor.rb +2 -2
  340. data/lib/bundler/vendored_timeout.rb +12 -0
  341. data/lib/bundler/vendored_tsort.rb +4 -0
  342. data/lib/bundler/vendored_uri.rb +21 -0
  343. data/lib/bundler/version.rb +5 -20
  344. data/lib/bundler/vlad.rb +3 -3
  345. data/lib/bundler/worker.rb +26 -15
  346. data/lib/bundler/yaml_serializer.rb +21 -13
  347. data/lib/bundler.rb +364 -230
  348. metadata +186 -218
  349. data/exe/bundle_ruby +0 -60
  350. data/lib/bundler/cli/package.rb +0 -49
  351. data/lib/bundler/compatibility_guard.rb +0 -14
  352. data/lib/bundler/dep_proxy.rb +0 -48
  353. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  354. data/lib/bundler/gemdeps.rb +0 -29
  355. data/lib/bundler/psyched_yaml.rb +0 -37
  356. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  357. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  358. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  359. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  360. data/lib/bundler/templates/gems.rb +0 -8
  361. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  362. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  363. data/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  364. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  365. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  366. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  367. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  368. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  369. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  370. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  371. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  372. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  373. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  374. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  375. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  376. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  377. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  378. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  379. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  380. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  381. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  382. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  383. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  384. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  385. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  386. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  387. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  388. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  389. data/lib/bundler/version_ranges.rb +0 -76
  390. data/man/bundle-add.1 +0 -58
  391. data/man/bundle-add.1.txt +0 -52
  392. data/man/bundle-add.ronn +0 -40
  393. data/man/bundle-binstubs.1.txt +0 -48
  394. data/man/bundle-check.1.txt +0 -33
  395. data/man/bundle-clean.1.txt +0 -26
  396. data/man/bundle-config.1.txt +0 -529
  397. data/man/bundle-doctor.1.txt +0 -44
  398. data/man/bundle-exec.1.txt +0 -178
  399. data/man/bundle-gem.1 +0 -80
  400. data/man/bundle-gem.1.txt +0 -91
  401. data/man/bundle-gem.ronn +0 -78
  402. data/man/bundle-info.1 +0 -20
  403. data/man/bundle-info.1.txt +0 -21
  404. data/man/bundle-info.ronn +0 -17
  405. data/man/bundle-init.1.txt +0 -34
  406. data/man/bundle-inject.1 +0 -33
  407. data/man/bundle-inject.1.txt +0 -32
  408. data/man/bundle-install.1.txt +0 -396
  409. data/man/bundle-list.1.txt +0 -43
  410. data/man/bundle-lock.1.txt +0 -93
  411. data/man/bundle-open.1 +0 -32
  412. data/man/bundle-open.1.txt +0 -29
  413. data/man/bundle-outdated.1.txt +0 -131
  414. data/man/bundle-package.1 +0 -55
  415. data/man/bundle-package.1.txt +0 -79
  416. data/man/bundle-package.ronn +0 -72
  417. data/man/bundle-platform.1 +0 -61
  418. data/man/bundle-platform.1.txt +0 -57
  419. data/man/bundle-pristine.1.txt +0 -44
  420. data/man/bundle-remove.1.txt +0 -34
  421. data/man/bundle-show.1.txt +0 -27
  422. data/man/bundle-update.1.txt +0 -391
  423. data/man/bundle-viz.1.txt +0 -39
  424. data/man/bundle.1.txt +0 -116
  425. data/man/gemfile.5.txt +0 -653
  426. /data/lib/bundler/{ssl_certs → man}/.document +0 -0
@@ -14,67 +14,74 @@ module Bundler
14
14
  def fetch(uri, headers = {}, counter = 0)
15
15
  raise HTTPError, "Too many redirects" if counter >= redirect_limit
16
16
 
17
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
18
+
17
19
  response = request(uri, headers)
18
- Bundler.ui.debug("HTTP #{response.code} #{response.message} #{uri}")
20
+ Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}")
19
21
 
20
22
  case response
21
- when Net::HTTPSuccess, Net::HTTPNotModified
23
+ when Gem::Net::HTTPSuccess, Gem::Net::HTTPNotModified
22
24
  response
23
- when Net::HTTPRedirection
24
- new_uri = URI.parse(response["location"])
25
+ when Gem::Net::HTTPRedirection
26
+ new_uri = Gem::URI.parse(response["location"])
25
27
  if new_uri.host == uri.host
26
28
  new_uri.user = uri.user
27
29
  new_uri.password = uri.password
28
30
  end
29
31
  fetch(new_uri, headers, counter + 1)
30
- when Net::HTTPRequestedRangeNotSatisfiable
32
+ when Gem::Net::HTTPRequestedRangeNotSatisfiable
31
33
  new_headers = headers.dup
32
34
  new_headers.delete("Range")
33
35
  new_headers["Accept-Encoding"] = "gzip"
34
36
  fetch(uri, new_headers)
35
- when Net::HTTPRequestEntityTooLarge
37
+ when Gem::Net::HTTPRequestEntityTooLarge
36
38
  raise FallbackError, response.body
37
- when Net::HTTPUnauthorized
39
+ when Gem::Net::HTTPTooManyRequests
40
+ raise TooManyRequestsError, response.body
41
+ when Gem::Net::HTTPUnauthorized
42
+ raise BadAuthenticationError, uri.host if uri.userinfo
38
43
  raise AuthenticationRequiredError, uri.host
39
- when Net::HTTPNotFound
40
- raise FallbackError, "Net::HTTPNotFound"
44
+ when Gem::Net::HTTPForbidden
45
+ raise AuthenticationForbiddenError, uri.host
46
+ when Gem::Net::HTTPNotFound
47
+ raise FallbackError, "Gem::Net::HTTPNotFound: #{filtered_uri}"
41
48
  else
42
- raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
49
+ message = "Gem::#{response.class.name.gsub(/\AGem::/, "")}"
50
+ message += ": #{response.body}" unless response.body.empty?
51
+ raise HTTPError, message
43
52
  end
44
53
  end
45
54
 
46
55
  def request(uri, headers)
47
56
  validate_uri_scheme!(uri)
48
57
 
49
- Bundler.ui.debug "HTTP GET #{uri}"
50
- req = Net::HTTP::Get.new uri.request_uri, headers
58
+ filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
59
+
60
+ Bundler.ui.debug "HTTP GET #{filtered_uri}"
61
+ req = Gem::Net::HTTP::Get.new uri.request_uri, headers
51
62
  if uri.user
52
63
  user = CGI.unescape(uri.user)
53
64
  password = uri.password ? CGI.unescape(uri.password) : nil
54
65
  req.basic_auth(user, password)
55
66
  end
56
67
  connection.request(uri, req)
57
- rescue NoMethodError => e
58
- raise unless ["undefined method", "use_ssl="].all? {|snippet| e.message.include? snippet }
59
- raise LoadError.new("cannot load such file -- openssl")
60
68
  rescue OpenSSL::SSL::SSLError
61
69
  raise CertificateFailureError.new(uri)
62
70
  rescue *HTTP_ERRORS => e
63
71
  Bundler.ui.trace e
64
- case e.message
65
- when /host down:/, /getaddrinfo: nodename nor servname provided/
72
+ if e.is_a?(SocketError) || e.message.to_s.include?("host down:")
66
73
  raise NetworkDownError, "Could not reach host #{uri.host}. Check your network " \
67
74
  "connection and try again."
68
75
  else
69
- raise HTTPError, "Network error while fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" \
76
+ raise HTTPError, "Network error while fetching #{filtered_uri}" \
70
77
  " (#{e})"
71
78
  end
72
79
  end
73
80
 
74
- private
81
+ private
75
82
 
76
83
  def validate_uri_scheme!(uri)
77
- return if uri.scheme =~ /\Ahttps?\z/
84
+ return if /\Ahttps?\z/.match?(uri.scheme)
78
85
  raise InvalidOption,
79
86
  "The request uri `#{uri}` has an invalid scheme (`#{uri.scheme}`). " \
80
87
  "Did you mean `http` or `https`?"
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems/remote_fetcher"
4
+
5
+ module Bundler
6
+ class Fetcher
7
+ class GemRemoteFetcher < Gem::RemoteFetcher
8
+ def request(*args)
9
+ super do |req|
10
+ req.delete("User-Agent") if headers["User-Agent"]
11
+ yield req if block_given?
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,51 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/fetcher/base"
4
- require "rubygems/remote_fetcher"
3
+ require_relative "base"
5
4
 
6
5
  module Bundler
7
6
  class Fetcher
8
7
  class Index < Base
9
8
  def specs(_gem_names)
10
- Bundler.rubygems.fetch_all_remote_specs(remote)
11
- rescue Gem::RemoteFetcher::FetchError, OpenSSL::SSL::SSLError, Net::HTTPFatalError => e
9
+ Bundler.rubygems.fetch_all_remote_specs(remote, gem_remote_fetcher)
10
+ rescue Gem::RemoteFetcher::FetchError => e
12
11
  case e.message
13
12
  when /certificate verify failed/
14
13
  raise CertificateFailureError.new(display_uri)
15
14
  when /401/
16
- raise AuthenticationRequiredError, remote_uri
17
- when /403/
18
15
  raise BadAuthenticationError, remote_uri if remote_uri.userinfo
19
16
  raise AuthenticationRequiredError, remote_uri
17
+ when /403/
18
+ raise AuthenticationForbiddenError, remote_uri
20
19
  else
21
- Bundler.ui.trace e
22
- raise HTTPError, "Could not fetch specs from #{display_uri}"
23
- end
24
- end
25
-
26
- def fetch_spec(spec)
27
- spec -= [nil, "ruby", ""]
28
- spec_file_name = "#{spec.join "-"}.gemspec"
29
-
30
- uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
31
- if uri.scheme == "file"
32
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
33
- elsif cached_spec_path = gemspec_cached_path(spec_file_name)
34
- Bundler.load_gemspec(cached_spec_path)
35
- else
36
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
20
+ raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
37
21
  end
38
- rescue MarshalError
39
- raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
40
- "Your network or your gem server is probably having issues right now."
41
- end
42
-
43
- private
44
-
45
- # cached gem specification path, if one exists
46
- def gemspec_cached_path(spec_file_name)
47
- paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
48
- paths.find {|path| File.file? path }
49
22
  end
50
23
  end
51
24
  end
@@ -1,22 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/vendored_persistent"
3
+ require_relative "vendored_persistent"
4
+ require_relative "vendored_timeout"
4
5
  require "cgi"
5
- require "securerandom"
6
+ require_relative "vendored_securerandom"
6
7
  require "zlib"
7
8
 
8
9
  module Bundler
9
10
  # Handles all the fetching with the rubygems server
10
11
  class Fetcher
11
- autoload :CompactIndex, "bundler/fetcher/compact_index"
12
- autoload :Downloader, "bundler/fetcher/downloader"
13
- autoload :Dependency, "bundler/fetcher/dependency"
14
- autoload :Index, "bundler/fetcher/index"
12
+ autoload :Base, File.expand_path("fetcher/base", __dir__)
13
+ autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
14
+ autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
15
+ autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
16
+ autoload :Index, File.expand_path("fetcher/index", __dir__)
15
17
 
16
18
  # This error is raised when it looks like the network is down
17
19
  class NetworkDownError < HTTPError; end
20
+ # This error is raised if we should rate limit our requests to the API
21
+ class TooManyRequestsError < HTTPError; end
18
22
  # This error is raised if the API returns a 413 (only printed in verbose)
19
23
  class FallbackError < HTTPError; end
24
+
20
25
  # This is the error raised if OpenSSL fails the cert verification
21
26
  class CertificateFailureError < HTTPError
22
27
  def initialize(remote_uri)
@@ -25,28 +30,30 @@ module Bundler
25
30
  " is a chance you are experiencing a man-in-the-middle attack, but" \
26
31
  " most likely your system doesn't have the CA certificates needed" \
27
32
  " for verification. For information about OpenSSL certificates, see" \
28
- " http://bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile" \
29
- " sources and change 'https' to 'http'."
33
+ " https://railsapps.github.io/openssl-certificate-verify-failed.html."
30
34
  end
31
35
  end
36
+
32
37
  # This is the error raised when a source is HTTPS and OpenSSL didn't load
33
38
  class SSLError < HTTPError
34
39
  def initialize(msg = nil)
35
- super msg || "Could not load OpenSSL.\n" \
36
- "You must recompile Ruby with OpenSSL support or change the sources in your " \
37
- "Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL " \
38
- "using RVM are available at rvm.io/packages/openssl."
40
+ super "Could not load OpenSSL.\n" \
41
+ "You must recompile Ruby with OpenSSL support.\n" \
42
+ "original error: #{msg}\n"
39
43
  end
40
44
  end
45
+
41
46
  # This error is raised if HTTP authentication is required, but not provided.
42
47
  class AuthenticationRequiredError < HTTPError
43
48
  def initialize(remote_uri)
44
49
  remote_uri = filter_uri(remote_uri)
45
50
  super "Authentication is required for #{remote_uri}.\n" \
46
51
  "Please supply credentials for this source. You can do this by running:\n" \
47
- " bundle config #{remote_uri} username:password"
52
+ "`bundle config set --global #{remote_uri} username:password`\n" \
53
+ "or by storing the credentials in the `#{Settings.key_for(remote_uri)}` environment variable"
48
54
  end
49
55
  end
56
+
50
57
  # This error is raised if HTTP authentication is provided, but incorrect.
51
58
  class BadAuthenticationError < HTTPError
52
59
  def initialize(remote_uri)
@@ -56,6 +63,16 @@ module Bundler
56
63
  end
57
64
  end
58
65
 
66
+ # This error is raised if HTTP authentication is correct, but lacks
67
+ # necessary permissions.
68
+ class AuthenticationForbiddenError < HTTPError
69
+ def initialize(remote_uri)
70
+ remote_uri = filter_uri(remote_uri)
71
+ super "Access token could not be authenticated for #{remote_uri}.\n" \
72
+ "Make sure it's valid and has the necessary scopes configured."
73
+ end
74
+ end
75
+
59
76
  # Exceptions classes that should bypass retry attempts. If your password didn't work the
60
77
  # first time, it's not going to the third time.
61
78
  NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
@@ -65,9 +82,9 @@ module Bundler
65
82
  :HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
66
83
  :HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
67
84
  FAIL_ERRORS = begin
68
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
69
- fail_errors << Gem::Requirement::BadRequirementError if defined?(Gem::Requirement::BadRequirementError)
70
- fail_errors.concat(NET_ERRORS.map {|e| SharedHelpers.const_get_safely(e, Net) }.compact)
85
+ fail_errors = [AuthenticationRequiredError, BadAuthenticationError, AuthenticationForbiddenError, FallbackError, SecurityError]
86
+ fail_errors << Gem::Requirement::BadRequirementError
87
+ fail_errors.concat(NET_ERRORS.map {|e| Gem::Net.const_get(e) })
71
88
  end.freeze
72
89
 
73
90
  class << self
@@ -79,6 +96,7 @@ module Bundler
79
96
  self.max_retries = Bundler.settings[:retry] # How many retries for the API call
80
97
 
81
98
  def initialize(remote)
99
+ @cis = nil
82
100
  @remote = remote
83
101
 
84
102
  Socket.do_not_reverse_lookup = true
@@ -94,14 +112,17 @@ module Bundler
94
112
  spec -= [nil, "ruby", ""]
95
113
  spec_file_name = "#{spec.join "-"}.gemspec"
96
114
 
97
- uri = URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
98
- if uri.scheme == "file"
99
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(uri.path))
115
+ uri = Gem::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
116
+ spec = if uri.scheme == "file"
117
+ path = Gem::Util.correct_for_windows_path(uri.path)
118
+ Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
100
119
  elsif cached_spec_path = gemspec_cached_path(spec_file_name)
101
120
  Bundler.load_gemspec(cached_spec_path)
102
121
  else
103
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
122
+ Bundler.safe_load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
104
123
  end
124
+ raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
125
+ spec
105
126
  rescue MarshalError
106
127
  raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
107
128
  "Your network or your gem server is probably having issues right now."
@@ -116,26 +137,13 @@ module Bundler
116
137
 
117
138
  # return the specs in the bundler format as an index
118
139
  def specs(gem_names, source)
119
- old = Bundler.rubygems.sources
120
140
  index = Bundler::Index.new
121
141
 
122
- if Bundler::Fetcher.disable_endpoint
123
- @use_api = false
124
- specs = fetchers.last.specs(gem_names)
125
- else
126
- specs = []
127
- fetchers.shift until fetchers.first.available? || fetchers.empty?
128
- fetchers.dup.each do |f|
129
- break unless f.api_fetcher? && !gem_names || !specs = f.specs(gem_names)
130
- fetchers.delete(f)
131
- end
132
- @use_api = false if fetchers.none?(&:api_fetcher?)
133
- end
134
-
135
- specs.each do |name, version, platform, dependencies, metadata|
136
- next if name == "bundler"
142
+ fetch_specs(gem_names).each do |name, version, platform, dependencies, metadata|
137
143
  spec = if dependencies
138
- EndpointSpecification.new(name, version, platform, dependencies, metadata)
144
+ EndpointSpecification.new(name, version, platform, self, dependencies, metadata).tap do |es|
145
+ source.checksum_store.replace(es, es.checksum)
146
+ end
139
147
  else
140
148
  RemoteSpecification.new(name, version, platform, self)
141
149
  end
@@ -146,22 +154,8 @@ module Bundler
146
154
 
147
155
  index
148
156
  rescue CertificateFailureError
149
- Bundler.ui.info "" if gem_names && use_api # newline after dots
157
+ Bundler.ui.info "" if gem_names && api_fetcher? # newline after dots
150
158
  raise
151
- ensure
152
- Bundler.rubygems.sources = old
153
- end
154
-
155
- def use_api
156
- return @use_api if defined?(@use_api)
157
-
158
- fetchers.shift until fetchers.first.available?
159
-
160
- @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
161
- false
162
- else
163
- fetchers.first.api_fetcher?
164
- end
165
159
  end
166
160
 
167
161
  def user_agent
@@ -189,7 +183,7 @@ module Bundler
189
183
  agent << " ci/#{cis.join(",")}" if cis.any?
190
184
 
191
185
  # add a random ID so we can consolidate runs server-side
192
- agent << " " << SecureRandom.hex(8)
186
+ agent << " " << Gem::SecureRandom.hex(8)
193
187
 
194
188
  # add any user agent strings set in the config
195
189
  extra_ua = Bundler.settings[:user_agent]
@@ -199,10 +193,6 @@ module Bundler
199
193
  end
200
194
  end
201
195
 
202
- def fetchers
203
- @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
204
- end
205
-
206
196
  def http_proxy
207
197
  return unless uri = connection.proxy_uri
208
198
  uri.to_s
@@ -212,35 +202,67 @@ module Bundler
212
202
  "#<#{self.class}:0x#{object_id} uri=#{uri}>"
213
203
  end
214
204
 
215
- private
205
+ def api_fetcher?
206
+ fetchers.first.api_fetcher?
207
+ end
208
+
209
+ def gem_remote_fetcher
210
+ @gem_remote_fetcher ||= begin
211
+ require_relative "fetcher/gem_remote_fetcher"
212
+ fetcher = GemRemoteFetcher.new Gem.configuration[:http_proxy]
213
+ fetcher.headers["User-Agent"] = user_agent
214
+ fetcher.headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
215
+ fetcher
216
+ end
217
+ end
218
+
219
+ private
220
+
221
+ def available_fetchers
222
+ if Bundler::Fetcher.disable_endpoint
223
+ [Index]
224
+ elsif remote_uri.scheme == "file"
225
+ Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
226
+ [Index]
227
+ else
228
+ [CompactIndex, Dependency, Index]
229
+ end
230
+ end
231
+
232
+ def fetchers
233
+ @fetchers ||= available_fetchers.map {|f| f.new(downloader, @remote, uri, gem_remote_fetcher) }.drop_while {|f| !f.available? }
234
+ end
216
235
 
217
- FETCHERS = [CompactIndex, Dependency, Index].freeze
236
+ def fetch_specs(gem_names)
237
+ fetchers.reject!(&:api_fetcher?) unless gem_names
238
+ fetchers.reject! do |f|
239
+ specs = f.specs(gem_names)
240
+ return specs if specs
241
+ true
242
+ end
243
+ []
244
+ end
218
245
 
219
246
  def cis
220
- env_cis = {
221
- "TRAVIS" => "travis",
222
- "CIRCLECI" => "circle",
223
- "SEMAPHORE" => "semaphore",
224
- "JENKINS_URL" => "jenkins",
225
- "BUILDBOX" => "buildbox",
226
- "GO_SERVER_URL" => "go",
227
- "SNAP_CI" => "snap",
228
- "CI_NAME" => ENV["CI_NAME"],
229
- "CI" => "ci"
230
- }
231
- env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
247
+ @cis ||= Bundler::CIDetector.ci_strings
232
248
  end
233
249
 
234
250
  def connection
235
251
  @connection ||= begin
236
252
  needs_ssl = remote_uri.scheme == "https" ||
237
- Bundler.settings[:ssl_verify_mode] ||
238
- Bundler.settings[:ssl_client_cert]
239
- raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
253
+ Bundler.settings[:ssl_verify_mode] ||
254
+ Bundler.settings[:ssl_client_cert]
255
+ if needs_ssl
256
+ begin
257
+ require "openssl"
258
+ rescue StandardError, LoadError => e
259
+ raise SSLError.new(e.message)
260
+ end
261
+ end
240
262
 
241
- con = PersistentHTTP.new "bundler", :ENV
242
- if gem_proxy = Bundler.rubygems.configuration[:http_proxy]
243
- con.proxy = URI.parse(gem_proxy) if gem_proxy != :no_proxy
263
+ con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
264
+ if gem_proxy = Gem.configuration[:http_proxy]
265
+ con.proxy = Gem::URI.parse(gem_proxy) if gem_proxy != :no_proxy
244
266
  end
245
267
 
246
268
  if remote_uri.scheme == "https"
@@ -250,8 +272,8 @@ module Bundler
250
272
  end
251
273
 
252
274
  ssl_client_cert = Bundler.settings[:ssl_client_cert] ||
253
- (Bundler.rubygems.configuration.ssl_client_cert if
254
- Bundler.rubygems.configuration.respond_to?(:ssl_client_cert))
275
+ (Gem.configuration.ssl_client_cert if
276
+ Gem.configuration.respond_to?(:ssl_client_cert))
255
277
  if ssl_client_cert
256
278
  pem = File.read(ssl_client_cert)
257
279
  con.cert = OpenSSL::X509::Certificate.new(pem)
@@ -269,22 +291,21 @@ module Bundler
269
291
  # cached gem specification path, if one exists
270
292
  def gemspec_cached_path(spec_file_name)
271
293
  paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) }
272
- paths = paths.select {|path| File.file? path }
273
- paths.first
294
+ paths.find {|path| File.file? path }
274
295
  end
275
296
 
276
297
  HTTP_ERRORS = [
277
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
298
+ Gem::Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
278
299
  Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
279
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
280
- PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
300
+ Gem::Net::HTTPBadResponse, Gem::Net::HTTPHeaderSyntaxError, Gem::Net::ProtocolError,
301
+ Gem::Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
281
302
  ].freeze
282
303
 
283
304
  def bundler_cert_store
284
305
  store = OpenSSL::X509::Store.new
285
306
  ssl_ca_cert = Bundler.settings[:ssl_ca_cert] ||
286
- (Bundler.rubygems.configuration.ssl_ca_cert if
287
- Bundler.rubygems.configuration.respond_to?(:ssl_ca_cert))
307
+ (Gem.configuration.ssl_ca_cert if
308
+ Gem.configuration.respond_to?(:ssl_ca_cert))
288
309
  if ssl_ca_cert
289
310
  if File.directory? ssl_ca_cert
290
311
  store.add_path ssl_ca_cert
@@ -293,14 +314,12 @@ module Bundler
293
314
  end
294
315
  else
295
316
  store.set_default_paths
296
- certs = File.expand_path("../ssl_certs/*/*.pem", __FILE__)
297
- Dir.glob(certs).each {|c| store.add_file c }
317
+ require "rubygems/request"
318
+ Gem::Request.get_cert_files.each {|c| store.add_file c }
298
319
  end
299
320
  store
300
321
  end
301
322
 
302
- private
303
-
304
323
  def remote_uri
305
324
  @remote.uri
306
325
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module ForcePlatform
5
+ # The `:force_ruby_platform` value used by dependencies for resolution, and
6
+ # by locked specifications for materialization is `false` by default, except
7
+ # for TruffleRuby. TruffleRuby generally needs to force the RUBY platform
8
+ # variant unless the name is explicitly allowlisted.
9
+
10
+ def default_force_ruby_platform
11
+ return false unless RUBY_ENGINE == "truffleruby"
12
+
13
+ !Gem::Platform::REUSE_AS_BINARY_ON_TRUFFLERUBY.include?(name)
14
+ end
15
+ end
16
+ end