bundler 2.2.27 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (353) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1328 -4
  3. data/README.md +4 -8
  4. data/bundler.gemspec +11 -11
  5. data/exe/bundle +5 -26
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +4 -4
  9. data/lib/bundler/capistrano.rb +1 -1
  10. data/lib/bundler/checksum.rb +254 -0
  11. data/lib/bundler/ci_detector.rb +75 -0
  12. data/lib/bundler/cli/add.rb +7 -5
  13. data/lib/bundler/cli/binstubs.rb +10 -6
  14. data/lib/bundler/cli/cache.rb +1 -1
  15. data/lib/bundler/cli/check.rb +4 -4
  16. data/lib/bundler/cli/common.rb +13 -3
  17. data/lib/bundler/cli/config.rb +18 -8
  18. data/lib/bundler/cli/console.rb +2 -5
  19. data/lib/bundler/cli/doctor.rb +16 -9
  20. data/lib/bundler/cli/exec.rb +2 -1
  21. data/lib/bundler/cli/fund.rb +1 -1
  22. data/lib/bundler/cli/gem.rb +153 -40
  23. data/lib/bundler/cli/info.rb +27 -17
  24. data/lib/bundler/cli/init.rb +6 -2
  25. data/lib/bundler/cli/inject.rb +1 -1
  26. data/lib/bundler/cli/install.rb +34 -42
  27. data/lib/bundler/cli/issue.rb +5 -4
  28. data/lib/bundler/cli/lock.rb +54 -28
  29. data/lib/bundler/cli/open.rb +9 -9
  30. data/lib/bundler/cli/outdated.rb +34 -29
  31. data/lib/bundler/cli/platform.rb +8 -6
  32. data/lib/bundler/cli/plugin.rb +9 -15
  33. data/lib/bundler/cli/pristine.rb +38 -30
  34. data/lib/bundler/cli/remove.rb +1 -2
  35. data/lib/bundler/cli/show.rb +5 -5
  36. data/lib/bundler/cli/update.rb +12 -7
  37. data/lib/bundler/cli/viz.rb +1 -1
  38. data/lib/bundler/cli.rb +265 -313
  39. data/lib/bundler/compact_index_client/cache.rb +53 -67
  40. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  41. data/lib/bundler/compact_index_client/gem_parser.rb +7 -3
  42. data/lib/bundler/compact_index_client/parser.rb +84 -0
  43. data/lib/bundler/compact_index_client/updater.rb +73 -77
  44. data/lib/bundler/compact_index_client.rb +59 -87
  45. data/lib/bundler/constants.rb +9 -2
  46. data/lib/bundler/current_ruby.rb +12 -16
  47. data/lib/bundler/definition.rb +604 -347
  48. data/lib/bundler/dependency.rb +33 -71
  49. data/lib/bundler/digest.rb +71 -0
  50. data/lib/bundler/dsl.rb +136 -102
  51. data/lib/bundler/endpoint_specification.rb +42 -16
  52. data/lib/bundler/env.rb +5 -7
  53. data/lib/bundler/environment_preserver.rb +8 -22
  54. data/lib/bundler/errors.rb +113 -13
  55. data/lib/bundler/feature_flag.rb +1 -2
  56. data/lib/bundler/fetcher/base.rb +11 -11
  57. data/lib/bundler/fetcher/compact_index.rb +32 -52
  58. data/lib/bundler/fetcher/dependency.rb +3 -7
  59. data/lib/bundler/fetcher/downloader.rb +17 -16
  60. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  61. data/lib/bundler/fetcher/index.rb +2 -29
  62. data/lib/bundler/fetcher.rb +98 -83
  63. data/lib/bundler/force_platform.rb +16 -0
  64. data/lib/bundler/friendly_errors.rb +29 -40
  65. data/lib/bundler/gem_helper.rb +12 -24
  66. data/lib/bundler/gem_helpers.rb +47 -7
  67. data/lib/bundler/gem_version_promoter.rb +68 -109
  68. data/lib/bundler/graph.rb +9 -9
  69. data/lib/bundler/index.rb +71 -79
  70. data/lib/bundler/injector.rb +25 -13
  71. data/lib/bundler/inline.rb +41 -28
  72. data/lib/bundler/installer/gem_installer.rb +22 -13
  73. data/lib/bundler/installer/parallel_installer.rb +19 -66
  74. data/lib/bundler/installer/standalone.rb +58 -17
  75. data/lib/bundler/installer.rb +31 -93
  76. data/lib/bundler/lazy_specification.rb +151 -72
  77. data/lib/bundler/lockfile_generator.rb +13 -4
  78. data/lib/bundler/lockfile_parser.rb +146 -71
  79. data/lib/bundler/man/bundle-add.1 +54 -44
  80. data/lib/bundler/man/bundle-add.1.ronn +62 -21
  81. data/lib/bundler/man/bundle-binstubs.1 +10 -19
  82. data/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  83. data/lib/bundler/man/bundle-cache.1 +38 -25
  84. data/lib/bundler/man/bundle-cache.1.ronn +40 -4
  85. data/lib/bundler/man/bundle-check.1 +7 -14
  86. data/lib/bundler/man/bundle-check.1.ronn +7 -2
  87. data/lib/bundler/man/bundle-clean.1 +4 -11
  88. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  89. data/lib/bundler/man/bundle-config.1 +48 -227
  90. data/lib/bundler/man/bundle-config.1.ronn +41 -34
  91. data/lib/bundler/man/bundle-console.1 +33 -0
  92. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  93. data/lib/bundler/man/bundle-doctor.1 +5 -19
  94. data/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  95. data/lib/bundler/man/bundle-env.1 +9 -0
  96. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  97. data/lib/bundler/man/bundle-exec.1 +20 -78
  98. data/lib/bundler/man/bundle-exec.1.ronn +12 -10
  99. data/lib/bundler/man/bundle-fund.1 +22 -0
  100. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  101. data/lib/bundler/man/bundle-gem.1 +57 -72
  102. data/lib/bundler/man/bundle-gem.1.ronn +57 -9
  103. data/lib/bundler/man/bundle-help.1 +9 -0
  104. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  105. data/lib/bundler/man/bundle-info.1 +8 -11
  106. data/lib/bundler/man/bundle-info.1.ronn +9 -5
  107. data/lib/bundler/man/bundle-init.1 +7 -12
  108. data/lib/bundler/man/bundle-init.1.ronn +4 -1
  109. data/lib/bundler/man/bundle-inject.1 +17 -19
  110. data/lib/bundler/man/bundle-inject.1.ronn +12 -2
  111. data/lib/bundler/man/bundle-install.1 +43 -163
  112. data/lib/bundler/man/bundle-install.1.ronn +33 -51
  113. data/lib/bundler/man/bundle-issue.1 +45 -0
  114. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  115. data/lib/bundler/man/bundle-licenses.1 +9 -0
  116. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  117. data/lib/bundler/man/bundle-list.1 +4 -19
  118. data/lib/bundler/man/bundle-list.1.ronn +4 -1
  119. data/lib/bundler/man/bundle-lock.1 +25 -34
  120. data/lib/bundler/man/bundle-lock.1.ronn +25 -4
  121. data/lib/bundler/man/bundle-open.1 +18 -18
  122. data/lib/bundler/man/bundle-open.1.ronn +10 -1
  123. data/lib/bundler/man/bundle-outdated.1 +23 -75
  124. data/lib/bundler/man/bundle-outdated.1.ronn +21 -22
  125. data/lib/bundler/man/bundle-platform.1 +16 -28
  126. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  127. data/lib/bundler/man/bundle-plugin.1 +58 -0
  128. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  129. data/lib/bundler/man/bundle-pristine.1 +5 -16
  130. data/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  131. data/lib/bundler/man/bundle-remove.1 +4 -14
  132. data/lib/bundler/man/bundle-remove.1.ronn +1 -1
  133. data/lib/bundler/man/bundle-show.1 +7 -11
  134. data/lib/bundler/man/bundle-show.1.ronn +4 -0
  135. data/lib/bundler/man/bundle-update.1 +31 -144
  136. data/lib/bundler/man/bundle-update.1.ronn +16 -7
  137. data/lib/bundler/man/bundle-version.1 +22 -0
  138. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  139. data/lib/bundler/man/bundle-viz.1 +9 -18
  140. data/lib/bundler/man/bundle-viz.1.ronn +9 -3
  141. data/lib/bundler/man/bundle.1 +17 -51
  142. data/lib/bundler/man/bundle.1.ronn +12 -7
  143. data/lib/bundler/man/gemfile.5 +132 -346
  144. data/lib/bundler/man/gemfile.5.ronn +127 -86
  145. data/lib/bundler/man/index.txt +8 -0
  146. data/lib/bundler/match_metadata.rb +17 -0
  147. data/lib/bundler/match_platform.rb +1 -2
  148. data/lib/bundler/match_remote_metadata.rb +29 -0
  149. data/lib/bundler/materialization.rb +59 -0
  150. data/lib/bundler/mirror.rb +8 -10
  151. data/lib/bundler/plugin/api/source.rb +11 -14
  152. data/lib/bundler/plugin/events.rb +24 -0
  153. data/lib/bundler/plugin/index.rb +13 -5
  154. data/lib/bundler/plugin/installer/git.rb +0 -4
  155. data/lib/bundler/plugin/installer/path.rb +18 -0
  156. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  157. data/lib/bundler/plugin/installer.rb +43 -20
  158. data/lib/bundler/plugin/source_list.rb +4 -4
  159. data/lib/bundler/plugin.rb +35 -7
  160. data/lib/bundler/process_lock.rb +10 -14
  161. data/lib/bundler/remote_specification.rb +17 -6
  162. data/lib/bundler/resolver/base.rb +117 -0
  163. data/lib/bundler/resolver/candidate.rb +82 -0
  164. data/lib/bundler/resolver/incompatibility.rb +15 -0
  165. data/lib/bundler/resolver/package.rb +90 -0
  166. data/lib/bundler/resolver/root.rb +25 -0
  167. data/lib/bundler/resolver/spec_group.rb +54 -66
  168. data/lib/bundler/resolver.rb +440 -306
  169. data/lib/bundler/retry.rb +2 -2
  170. data/lib/bundler/ruby_dsl.rb +42 -7
  171. data/lib/bundler/ruby_version.rb +22 -22
  172. data/lib/bundler/rubygems_ext.rb +323 -84
  173. data/lib/bundler/rubygems_gem_installer.rb +93 -65
  174. data/lib/bundler/rubygems_integration.rb +89 -237
  175. data/lib/bundler/runtime.rb +30 -20
  176. data/lib/bundler/safe_marshal.rb +31 -0
  177. data/lib/bundler/self_manager.rb +205 -0
  178. data/lib/bundler/settings.rb +145 -58
  179. data/lib/bundler/setup.rb +13 -1
  180. data/lib/bundler/shared_helpers.rb +94 -51
  181. data/lib/bundler/source/git/git_proxy.rb +283 -82
  182. data/lib/bundler/source/git.rb +187 -78
  183. data/lib/bundler/source/metadata.rb +16 -16
  184. data/lib/bundler/source/path/installer.rb +1 -22
  185. data/lib/bundler/source/path.rb +17 -27
  186. data/lib/bundler/source/rubygems/remote.rb +1 -1
  187. data/lib/bundler/source/rubygems.rb +165 -245
  188. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  189. data/lib/bundler/source.rb +7 -6
  190. data/lib/bundler/source_list.rb +41 -33
  191. data/lib/bundler/source_map.rb +15 -2
  192. data/lib/bundler/spec_set.rb +193 -58
  193. data/lib/bundler/stub_specification.rb +39 -7
  194. data/lib/bundler/templates/Executable +3 -5
  195. data/lib/bundler/templates/Executable.bundler +7 -12
  196. data/lib/bundler/templates/Executable.standalone +4 -4
  197. data/lib/bundler/templates/Gemfile +0 -2
  198. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  199. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  200. data/lib/bundler/templates/newgem/Gemfile.tt +5 -2
  201. data/lib/bundler/templates/newgem/README.md.tt +12 -12
  202. data/lib/bundler/templates/newgem/Rakefile.tt +28 -4
  203. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  204. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  205. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  206. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  207. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  208. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  209. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  210. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +20 -10
  211. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  212. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  213. data/lib/bundler/templates/newgem/newgem.gemspec.tt +26 -18
  214. data/lib/bundler/templates/newgem/rubocop.yml.tt +0 -5
  215. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  216. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  217. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  218. data/lib/bundler/ui/rg_proxy.rb +1 -1
  219. data/lib/bundler/ui/shell.rb +61 -16
  220. data/lib/bundler/ui/silent.rb +33 -6
  221. data/lib/bundler/uri_credentials_filter.rb +3 -3
  222. data/lib/bundler/uri_normalizer.rb +23 -0
  223. data/lib/bundler/vendor/.document +1 -0
  224. data/lib/bundler/vendor/connection_pool/.document +1 -0
  225. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  226. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  227. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  228. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  229. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +92 -78
  230. data/lib/bundler/vendor/fileutils/.document +1 -0
  231. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  232. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -418
  233. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  234. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  235. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +4 -3
  236. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +23 -11
  237. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +1 -1
  238. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +102 -64
  239. data/lib/bundler/vendor/pub_grub/.document +1 -0
  240. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  241. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  242. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  243. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  244. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  245. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  246. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  247. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  248. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  249. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  250. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  251. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  252. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  253. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  254. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  255. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  256. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  257. data/lib/bundler/vendor/securerandom/.document +1 -0
  258. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  259. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  260. data/lib/bundler/vendor/thor/.document +1 -0
  261. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  262. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  263. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +1 -1
  264. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  265. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +15 -19
  266. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +16 -6
  267. data/lib/bundler/vendor/thor/lib/thor/actions.rb +21 -17
  268. data/lib/bundler/vendor/thor/lib/thor/base.rb +140 -14
  269. data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -4
  270. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  271. data/lib/bundler/vendor/thor/lib/thor/error.rb +16 -20
  272. data/lib/bundler/vendor/thor/lib/thor/group.rb +12 -1
  273. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -1
  274. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +2 -2
  275. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
  276. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +33 -17
  277. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +28 -9
  278. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +65 -8
  279. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +2 -2
  280. data/lib/bundler/vendor/thor/lib/thor/runner.rb +40 -30
  281. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +56 -162
  282. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -46
  283. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  284. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -46
  285. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  286. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  287. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  288. data/lib/bundler/vendor/thor/lib/thor/shell.rb +2 -2
  289. data/lib/bundler/vendor/thor/lib/thor/util.rb +9 -8
  290. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  291. data/lib/bundler/vendor/thor/lib/thor.rb +166 -8
  292. data/lib/bundler/vendor/tsort/.document +1 -0
  293. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  294. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  295. data/lib/bundler/vendor/uri/.document +1 -0
  296. data/lib/bundler/vendor/uri/COPYING +56 -0
  297. data/lib/bundler/vendor/uri/lib/uri/common.rb +351 -219
  298. data/lib/bundler/vendor/uri/lib/uri/file.rb +10 -4
  299. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +3 -3
  300. data/lib/bundler/vendor/uri/lib/uri/generic.rb +49 -39
  301. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  302. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  303. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  304. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  305. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  306. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +26 -26
  307. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +131 -50
  308. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  309. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  310. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  311. data/lib/bundler/vendor/uri/lib/uri.rb +12 -12
  312. data/lib/bundler/vendored_net_http.rb +23 -0
  313. data/lib/bundler/vendored_persistent.rb +0 -36
  314. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  315. data/lib/bundler/vendored_securerandom.rb +12 -0
  316. data/lib/bundler/vendored_timeout.rb +12 -0
  317. data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
  318. data/lib/bundler/vendored_uri.rb +18 -1
  319. data/lib/bundler/version.rb +5 -1
  320. data/lib/bundler/vlad.rb +1 -1
  321. data/lib/bundler/worker.rb +7 -9
  322. data/lib/bundler/yaml_serializer.rb +22 -13
  323. data/lib/bundler.rb +176 -151
  324. metadata +98 -41
  325. data/lib/bundler/dep_proxy.rb +0 -55
  326. data/lib/bundler/gemdeps.rb +0 -29
  327. data/lib/bundler/psyched_yaml.rb +0 -22
  328. data/lib/bundler/templates/gems.rb +0 -8
  329. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  330. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  331. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  332. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  333. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  334. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  335. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  336. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  337. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  338. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  339. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  340. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  341. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  342. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  343. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  344. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  345. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  346. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  347. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  348. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  349. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  350. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  351. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  352. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  353. data/lib/bundler/version_ranges.rb +0 -122
@@ -1,183 +1,315 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bundler
4
+ #
5
+ # This class implements the interface needed by PubGrub for resolution. It is
6
+ # equivalent to the `PubGrub::BasicPackageSource` class provided by PubGrub by
7
+ # default and used by the most simple PubGrub consumers.
8
+ #
4
9
  class Resolver
5
- require_relative "vendored_molinillo"
6
- require_relative "resolver/spec_group"
10
+ require_relative "vendored_pub_grub"
11
+ require_relative "resolver/base"
12
+ require_relative "resolver/candidate"
13
+ require_relative "resolver/incompatibility"
14
+ require_relative "resolver/root"
7
15
 
8
16
  include GemHelpers
9
17
 
10
- # Figures out the best possible configuration of gems that satisfies
11
- # the list of passed dependencies and any child dependencies without
12
- # causing any gem activation errors.
13
- #
14
- # ==== Parameters
15
- # *dependencies<Gem::Dependency>:: The list of dependencies to resolve
16
- #
17
- # ==== Returns
18
- # <GemBundle>,nil:: If the list of dependencies can be resolved, a
19
- # collection of gemspecs is returned. Otherwise, nil is returned.
20
- def self.resolve(requirements, source_requirements = {}, base = [], gem_version_promoter = GemVersionPromoter.new, additional_base_requirements = [], platforms = nil)
21
- base = SpecSet.new(base) unless base.is_a?(SpecSet)
22
- resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
23
- result = resolver.start(requirements)
24
- SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") }))
25
- end
26
-
27
- def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
28
- @source_requirements = source_requirements
18
+ def initialize(base, gem_version_promoter, most_specific_locked_platform = nil)
19
+ @source_requirements = base.source_requirements
29
20
  @base = base
30
- @resolver = Molinillo::Resolver.new(self, self)
31
- @search_for = {}
32
- @base_dg = Molinillo::DependencyGraph.new
33
- aggregate_global_source = @source_requirements[:default].is_a?(Source::RubygemsAggregate)
34
- @base.each do |ls|
35
- dep = Dependency.new(ls.name, ls.version)
36
- ls.source = source_for(ls.name) unless aggregate_global_source
37
- @base_dg.add_vertex(ls.name, DepProxy.get_proxy(dep, ls.platform), true)
38
- end
39
- additional_base_requirements.each {|d| @base_dg.add_vertex(d.name, d) }
40
- @platforms = platforms.reject {|p| p != Gem::Platform::RUBY && (platforms - [p]).any? {|pl| generic(pl) == p } }
41
- @resolving_only_for_ruby = platforms == [Gem::Platform::RUBY]
42
21
  @gem_version_promoter = gem_version_promoter
43
- @use_gvp = Bundler.feature_flag.use_gem_version_promoter_for_major_updates? || !@gem_version_promoter.major?
44
- end
45
-
46
- def start(requirements)
47
- @gem_version_promoter.prerelease_specified = @prerelease_specified = {}
48
- requirements.each {|dep| @prerelease_specified[dep.name] ||= dep.prerelease? }
49
-
50
- verify_gemfile_dependencies_are_found!(requirements)
51
- dg = @resolver.resolve(requirements, @base_dg)
52
- dg.
53
- map(&:payload).
54
- reject {|sg| sg.name.end_with?("\0") }.
55
- map(&:to_specs).
56
- flatten
57
- rescue Molinillo::VersionConflict => e
58
- message = version_conflict_message(e)
59
- raise VersionConflict.new(e.conflicts.keys.uniq, message)
60
- rescue Molinillo::CircularDependencyError => e
61
- names = e.dependencies.sort_by(&:name).map {|d| "gem '#{d.name}'" }
62
- raise CyclicDependencyError, "Your bundle requires gems that depend" \
63
- " on each other, creating an infinite loop. Please remove" \
64
- " #{names.count > 1 ? "either " : ""}#{names.join(" or ")}" \
65
- " and try again."
66
- end
67
-
68
- include Molinillo::UI
69
-
70
- # Conveys debug information to the user.
71
- #
72
- # @param [Integer] depth the current depth of the resolution process.
73
- # @return [void]
74
- def debug(depth = 0)
75
- return unless debug?
76
- debug_info = yield
77
- debug_info = debug_info.inspect unless debug_info.is_a?(String)
78
- puts debug_info.split("\n").map {|s| depth == 0 ? "BUNDLER: #{s}" : "BUNDLER(#{depth}): #{s}" }
22
+ @most_specific_locked_platform = most_specific_locked_platform
79
23
  end
80
24
 
81
- def debug?
82
- return @debug_mode if defined?(@debug_mode)
83
- @debug_mode =
84
- ENV["BUNDLER_DEBUG_RESOLVER"] ||
85
- ENV["BUNDLER_DEBUG_RESOLVER_TREE"] ||
86
- ENV["DEBUG_RESOLVER"] ||
87
- ENV["DEBUG_RESOLVER_TREE"] ||
88
- false
89
- end
25
+ def start
26
+ @requirements = @base.requirements
27
+ @packages = @base.packages
90
28
 
91
- def before_resolution
92
- Bundler.ui.info "Resolving dependencies...", debug?
93
- end
29
+ root, logger = setup_solver
94
30
 
95
- def after_resolution
96
- Bundler.ui.info ""
97
- end
31
+ Bundler.ui.info "Resolving dependencies...", true
98
32
 
99
- def indicate_progress
100
- Bundler.ui.info ".", false unless debug?
33
+ solve_versions(root: root, logger: logger)
101
34
  end
102
35
 
103
- include Molinillo::SpecificationProvider
36
+ def setup_solver
37
+ root = Resolver::Root.new(name_for_explicit_dependency_source)
38
+ root_version = Resolver::Candidate.new(0)
39
+
40
+ @all_specs = Hash.new do |specs, name|
41
+ source = source_for(name)
42
+ matches = source.specs.search(name)
43
+
44
+ # Don't bother to check for circular deps when no dependency API are
45
+ # available, since it's too slow to be usable. That edge case won't work
46
+ # but resolution other than that should work fine and reasonably fast.
47
+ if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
48
+ matches = filter_invalid_self_dependencies(matches, name)
49
+ end
50
+
51
+ specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
52
+ end
53
+
54
+ @all_versions = Hash.new do |candidates, package|
55
+ candidates[package] = all_versions_for(package)
56
+ end
57
+
58
+ @sorted_versions = Hash.new do |candidates, package|
59
+ candidates[package] = filtered_versions_for(package).sort
60
+ end
61
+
62
+ @sorted_versions[root] = [root_version]
104
63
 
105
- def dependencies_for(specification)
106
- specification.dependencies_for_activated_platforms
64
+ root_dependencies = prepare_dependencies(@requirements, @packages)
65
+
66
+ @cached_dependencies = Hash.new do |dependencies, package|
67
+ dependencies[package] = Hash.new do |versions, version|
68
+ versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
69
+ end
70
+ end
71
+
72
+ @cached_dependencies[root] = { root_version => root_dependencies }
73
+
74
+ logger = Bundler::UI::Shell.new
75
+ logger.level = debug? ? "debug" : "warn"
76
+
77
+ [root, logger]
107
78
  end
108
79
 
109
- def search_for(dependency_proxy)
110
- platform = dependency_proxy.__platform
111
- dependency = dependency_proxy.dep
112
- name = dependency.name
113
- @search_for[dependency_proxy] ||= begin
114
- results = results_for(dependency, @base[name])
80
+ def solve_versions(root:, logger:)
81
+ solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
82
+ result = solver.solve
83
+ result.flat_map {|package, version| version.to_specs(package, @most_specific_locked_platform) }
84
+ rescue PubGrub::SolveFailure => e
85
+ incompatibility = e.incompatibility
86
+
87
+ names_to_unlock, names_to_allow_prereleases_for, names_to_allow_remote_specs_for, extended_explanation = find_names_to_relax(incompatibility)
88
+
89
+ names_to_relax = names_to_unlock + names_to_allow_prereleases_for + names_to_allow_remote_specs_for
115
90
 
116
- if vertex = @base_dg.vertex_named(name)
117
- locked_requirement = vertex.payload.requirement
91
+ if names_to_relax.any?
92
+ if names_to_unlock.any?
93
+ Bundler.ui.debug "Found conflicts with locked dependencies. Will retry with #{names_to_unlock.join(", ")} unlocked...", true
94
+
95
+ @base.unlock_names(names_to_unlock)
118
96
  end
119
97
 
120
- if !@prerelease_specified[name] && (!@use_gvp || locked_requirement.nil?)
121
- # Move prereleases to the beginning of the list, so they're considered
122
- # last during resolution.
123
- pre, results = results.partition {|spec| spec.version.prerelease? }
124
- results = pre + results
98
+ if names_to_allow_prereleases_for.any?
99
+ Bundler.ui.debug "Found conflicts with dependencies with prereleases. Will retry considering prereleases for #{names_to_allow_prereleases_for.join(", ")}...", true
100
+
101
+ @base.include_prereleases(names_to_allow_prereleases_for)
125
102
  end
126
103
 
127
- spec_groups = if results.any?
128
- nested = []
129
- results.each do |spec|
130
- version, specs = nested.last
131
- if version == spec.version
132
- specs << spec
133
- else
134
- nested << [spec.version, [spec]]
135
- end
104
+ if names_to_allow_remote_specs_for.any?
105
+ Bundler.ui.debug "Found conflicts with local versions of #{names_to_allow_remote_specs_for.join(", ")}. Will retry considering remote versions...", true
106
+
107
+ @base.include_remote_specs(names_to_allow_remote_specs_for)
108
+ end
109
+
110
+ root, logger = setup_solver
111
+
112
+ Bundler.ui.debug "Retrying resolution...", true
113
+ retry
114
+ end
115
+
116
+ explanation = e.message
117
+
118
+ if extended_explanation
119
+ explanation << "\n\n"
120
+ explanation << extended_explanation
121
+ end
122
+
123
+ raise SolveFailure.new(explanation)
124
+ end
125
+
126
+ def find_names_to_relax(incompatibility)
127
+ names_to_unlock = []
128
+ names_to_allow_prereleases_for = []
129
+ names_to_allow_remote_specs_for = []
130
+ extended_explanation = nil
131
+
132
+ while incompatibility.conflict?
133
+ cause = incompatibility.cause
134
+ incompatibility = cause.incompatibility
135
+
136
+ incompatibility.terms.each do |term|
137
+ package = term.package
138
+ name = package.name
139
+
140
+ if base_requirements[name]
141
+ names_to_unlock << name
142
+ elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
143
+ names_to_allow_prereleases_for << name
144
+ elsif package.prefer_local? && @all_specs[name].any? {|s| !s.is_a?(StubSpecification) }
145
+ names_to_allow_remote_specs_for << name
136
146
  end
137
- nested.reduce([]) do |groups, (version, specs)|
138
- next groups if locked_requirement && !locked_requirement.satisfied_by?(version)
139
147
 
140
- specs_by_platform = Hash.new do |current_specs, current_platform|
141
- current_specs[current_platform] = select_best_platform_match(specs, current_platform)
142
- end
148
+ no_versions_incompat = [cause.incompatibility, cause.satisfier].find {|incompat| incompat.cause.is_a?(PubGrub::Incompatibility::NoVersions) }
149
+ next unless no_versions_incompat
150
+
151
+ extended_explanation = no_versions_incompat.extended_explanation
152
+ end
153
+ end
154
+
155
+ [names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, names_to_allow_remote_specs_for.uniq, extended_explanation]
156
+ end
143
157
 
144
- spec_group_ruby = SpecGroup.create_for(specs_by_platform, [Gem::Platform::RUBY], Gem::Platform::RUBY)
145
- groups << spec_group_ruby if spec_group_ruby
158
+ def parse_dependency(package, dependency)
159
+ range = if repository_for(package).is_a?(Source::Gemspec)
160
+ PubGrub::VersionRange.any
161
+ else
162
+ requirement_to_range(dependency)
163
+ end
146
164
 
147
- next groups if @resolving_only_for_ruby
165
+ PubGrub::VersionConstraint.new(package, range: range)
166
+ end
148
167
 
149
- spec_group = SpecGroup.create_for(specs_by_platform, @platforms, platform)
150
- groups << spec_group if spec_group
168
+ def versions_for(package, range=VersionRange.any)
169
+ versions = select_sorted_versions(package, range)
151
170
 
152
- groups
171
+ # Conditional avoids (among other things) calling
172
+ # sort_versions_by_preferred with the root package
173
+ if versions.size > 1
174
+ sort_versions_by_preferred(package, versions)
175
+ else
176
+ versions
177
+ end
178
+ end
179
+
180
+ def no_versions_incompatibility_for(package, unsatisfied_term)
181
+ cause = PubGrub::Incompatibility::NoVersions.new(unsatisfied_term)
182
+ name = package.name
183
+ constraint = unsatisfied_term.constraint
184
+ constraint_string = constraint.constraint_string
185
+ requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) }
186
+
187
+ if name == "bundler" && bundler_pinned_to_current_version?
188
+ custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}"
189
+ extended_explanation = bundler_not_found_message(requirements)
190
+ else
191
+ specs_matching_other_platforms = filter_matching_specs(@all_specs[name], requirements)
192
+
193
+ platforms_explanation = specs_matching_other_platforms.any? ? " for any resolution platforms (#{package.platforms.join(", ")})" : ""
194
+ custom_explanation = "#{constraint} could not be found in #{repository_for(package)}#{platforms_explanation}"
195
+
196
+ label = "#{name} (#{constraint_string})"
197
+ extended_explanation = other_specs_matching_message(specs_matching_other_platforms, label) if specs_matching_other_platforms.any?
198
+ end
199
+
200
+ Incompatibility.new([unsatisfied_term], cause: cause, custom_explanation: custom_explanation, extended_explanation: extended_explanation)
201
+ end
202
+
203
+ def debug?
204
+ ENV["BUNDLER_DEBUG_RESOLVER"] ||
205
+ ENV["BUNDLER_DEBUG_RESOLVER_TREE"] ||
206
+ ENV["DEBUG_RESOLVER"] ||
207
+ ENV["DEBUG_RESOLVER_TREE"] ||
208
+ false
209
+ end
210
+
211
+ def incompatibilities_for(package, version)
212
+ package_deps = @cached_dependencies[package]
213
+ sorted_versions = @sorted_versions[package]
214
+ package_deps[version].map do |dep_package, dep_constraint|
215
+ low = high = sorted_versions.index(version)
216
+
217
+ # find version low such that all >= low share the same dep
218
+ while low > 0 && package_deps[sorted_versions[low - 1]][dep_package] == dep_constraint
219
+ low -= 1
220
+ end
221
+ low =
222
+ if low == 0
223
+ nil
224
+ else
225
+ sorted_versions[low]
153
226
  end
154
- else
155
- []
227
+
228
+ # find version high such that all < high share the same dep
229
+ while high < sorted_versions.length && package_deps[sorted_versions[high]][dep_package] == dep_constraint
230
+ high += 1
156
231
  end
157
- # GVP handles major itself, but it's still a bit risky to trust it with it
158
- # until we get it settled with new behavior. For 2.x it can take over all cases.
159
- if !@use_gvp
160
- spec_groups
161
- else
162
- @gem_version_promoter.sort_versions(dependency, spec_groups)
232
+ high =
233
+ if high == sorted_versions.length
234
+ nil
235
+ else
236
+ sorted_versions[high]
237
+ end
238
+
239
+ range = PubGrub::VersionRange.new(min: low, max: high, include_min: true)
240
+
241
+ self_constraint = PubGrub::VersionConstraint.new(package, range: range)
242
+
243
+ dep_term = PubGrub::Term.new(dep_constraint, false)
244
+ self_term = PubGrub::Term.new(self_constraint, true)
245
+
246
+ custom_explanation = if dep_package.meta? && package.root?
247
+ "current #{dep_package} version is #{dep_constraint.constraint_string}"
163
248
  end
249
+
250
+ PubGrub::Incompatibility.new([self_term, dep_term], cause: :dependency, custom_explanation: custom_explanation)
164
251
  end
165
252
  end
166
253
 
167
- def index_for(dependency)
168
- source_for(dependency.name).specs
254
+ def all_versions_for(package)
255
+ name = package.name
256
+ results = (@base[name] + filter_specs(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
257
+
258
+ if name == "bundler" && !bundler_pinned_to_current_version?
259
+ bundler_spec = Gem.loaded_specs["bundler"]
260
+ results << bundler_spec if bundler_spec
261
+ end
262
+
263
+ locked_requirement = base_requirements[name]
264
+ results = filter_matching_specs(results, locked_requirement) if locked_requirement
265
+
266
+ results.group_by(&:version).reduce([]) do |groups, (version, specs)|
267
+ platform_specs = package.platform_specs(specs)
268
+
269
+ # If package is a top-level dependency,
270
+ # candidate is only valid if there are matching versions for all resolution platforms.
271
+ #
272
+ # If package is not a top-level deependency,
273
+ # then it's not necessary that it has matching versions for all platforms, since it may have been introduced only as
274
+ # a dependency for a platform specific variant, so it will only need to have a valid version for that platform.
275
+ #
276
+ if package.top_level?
277
+ next groups if platform_specs.any?(&:empty?)
278
+ else
279
+ next groups if platform_specs.all?(&:empty?)
280
+ end
281
+
282
+ ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
283
+ ruby_group = Resolver::SpecGroup.new(ruby_specs)
284
+
285
+ unless ruby_group.empty?
286
+ platform_specs.each do |specs|
287
+ ruby_group.merge(Resolver::SpecGroup.new(specs))
288
+ end
289
+
290
+ groups << Resolver::Candidate.new(version, group: ruby_group, priority: -1)
291
+ next groups if package.force_ruby_platform?
292
+ end
293
+
294
+ platform_group = Resolver::SpecGroup.new(platform_specs.flatten.uniq)
295
+ next groups if platform_group == ruby_group
296
+
297
+ groups << Resolver::Candidate.new(version, group: platform_group, priority: 1)
298
+
299
+ groups
300
+ end
169
301
  end
170
302
 
171
303
  def source_for(name)
172
304
  @source_requirements[name] || @source_requirements[:default]
173
305
  end
174
306
 
175
- def results_for(dependency, base)
176
- index_for(dependency).search(dependency, base)
307
+ def default_bundler_source
308
+ @source_requirements[:default_bundler]
177
309
  end
178
310
 
179
- def name_for(dependency)
180
- dependency.name
311
+ def bundler_pinned_to_current_version?
312
+ !default_bundler_source.nil?
181
313
  end
182
314
 
183
315
  def name_for_explicit_dependency_source
@@ -186,204 +318,206 @@ module Bundler
186
318
  "Gemfile"
187
319
  end
188
320
 
189
- def name_for_locking_dependency_source
190
- Bundler.default_lockfile.basename.to_s
191
- rescue StandardError
192
- "Gemfile.lock"
321
+ def raise_not_found!(package)
322
+ name = package.name
323
+ source = source_for(name)
324
+ specs = @all_specs[name]
325
+ matching_part = name
326
+ requirement_label = SharedHelpers.pretty_dependency(package.dependency)
327
+ cache_message = begin
328
+ " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
329
+ rescue GemfileNotFound
330
+ nil
331
+ end
332
+ specs_matching_requirement = filter_matching_specs(specs, package.dependency.requirement)
333
+
334
+ not_found_message = if specs_matching_requirement.any?
335
+ specs = specs_matching_requirement
336
+ matching_part = requirement_label
337
+ platforms = package.platforms
338
+
339
+ if platforms.size == 1
340
+ "Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
341
+ else
342
+ "Could not find gems matching '#{requirement_label}' valid for all resolution platforms (#{platforms.join(", ")})"
343
+ end
344
+ else
345
+ "Could not find gem '#{requirement_label}'"
346
+ end
347
+
348
+ message = String.new("#{not_found_message} in #{source}#{cache_message}.\n")
349
+
350
+ if specs.any?
351
+ message << "\n#{other_specs_matching_message(specs, matching_part)}"
352
+ end
353
+
354
+ raise GemNotFound, message
193
355
  end
194
356
 
195
- def requirement_satisfied_by?(requirement, activated, spec)
196
- requirement.matches_spec?(spec) || spec.source.is_a?(Source::Gemspec)
357
+ private
358
+
359
+ def filtered_versions_for(package)
360
+ @gem_version_promoter.filter_versions(package, @all_versions[package])
197
361
  end
198
362
 
199
- def dependencies_equal?(dependencies, other_dependencies)
200
- dependencies.map(&:dep) == other_dependencies.map(&:dep)
363
+ def raise_all_versions_filtered_out!(package)
364
+ level = @gem_version_promoter.level
365
+ name = package.name
366
+ locked_version = package.locked_version
367
+ requirement = package.dependency
368
+
369
+ raise GemNotFound,
370
+ "#{name} is locked to #{locked_version}, while Gemfile is requesting #{requirement}. " \
371
+ "--strict --#{level} was specified, but there are no #{level} level upgrades from #{locked_version} satisfying #{requirement}, so version solving has failed"
201
372
  end
202
373
 
203
- def sort_dependencies(dependencies, activated, conflicts)
204
- dependencies.sort_by do |dependency|
205
- name = name_for(dependency)
206
- vertex = activated.vertex_named(name)
207
- [
208
- @base_dg.vertex_named(name) ? 0 : 1,
209
- vertex.payload ? 0 : 1,
210
- vertex.root? ? 0 : 1,
211
- amount_constrained(dependency),
212
- conflicts[name] ? 0 : 1,
213
- vertex.payload ? 0 : search_for(dependency).count,
214
- self.class.platform_sort_key(dependency.__platform),
215
- ]
374
+ def filter_matching_specs(specs, requirements)
375
+ Array(requirements).flat_map do |requirement|
376
+ specs.select {| spec| requirement_satisfied_by?(requirement, spec) }
216
377
  end
217
378
  end
218
379
 
219
- def self.platform_sort_key(platform)
220
- # Prefer specific platform to not specific platform
221
- return ["99-LAST", "", "", ""] if Gem::Platform::RUBY == platform
222
- ["00", *platform.to_a.map {|part| part || "" }]
380
+ def filter_specs(specs, package)
381
+ filter_remote_specs(filter_prereleases(specs, package), package)
223
382
  end
224
383
 
225
- private
384
+ def filter_prereleases(specs, package)
385
+ return specs unless package.ignores_prereleases? && specs.size > 1
226
386
 
227
- # returns an integer \in (-\infty, 0]
228
- # a number closer to 0 means the dependency is less constraining
229
- #
230
- # dependencies w/ 0 or 1 possibilities (ignoring version requirements)
231
- # are given very negative values, so they _always_ sort first,
232
- # before dependencies that are unconstrained
233
- def amount_constrained(dependency)
234
- @amount_constrained ||= {}
235
- @amount_constrained[dependency.name] ||= begin
236
- if (base = @base[dependency.name]) && !base.empty?
237
- dependency.requirement.satisfied_by?(base.first.version) ? 0 : 1
238
- else
239
- all = index_for(dependency).search(dependency.name).size
387
+ specs.reject {|s| s.version.prerelease? }
388
+ end
240
389
 
241
- if all <= 1
242
- all - 1_000_000
243
- else
244
- search = search_for(dependency)
245
- search = @prerelease_specified[dependency.name] ? search.count : search.count {|s| !s.version.prerelease? }
246
- search - all
390
+ def filter_remote_specs(specs, package)
391
+ return specs unless package.prefer_local?
392
+
393
+ specs.select {|s| s.is_a?(StubSpecification) }
394
+ end
395
+
396
+ # Ignore versions that depend on themselves incorrectly
397
+ def filter_invalid_self_dependencies(specs, name)
398
+ specs.reject do |s|
399
+ s.dependencies.any? {|d| d.name == name && !d.requirement.satisfied_by?(s.version) }
400
+ end
401
+ end
402
+
403
+ def requirement_satisfied_by?(requirement, spec)
404
+ requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
405
+ end
406
+
407
+ def sort_versions_by_preferred(package, versions)
408
+ @gem_version_promoter.sort_versions(package, versions)
409
+ end
410
+
411
+ def repository_for(package)
412
+ source_for(package.name)
413
+ end
414
+
415
+ def base_requirements
416
+ @base.base_requirements
417
+ end
418
+
419
+ def prepare_dependencies(requirements, packages)
420
+ to_dependency_hash(requirements, packages).filter_map do |dep_package, dep_constraint|
421
+ name = dep_package.name
422
+
423
+ next [dep_package, dep_constraint] if name == "bundler"
424
+
425
+ dep_range = dep_constraint.range
426
+ versions = select_sorted_versions(dep_package, dep_range)
427
+ if versions.empty?
428
+ if dep_package.ignores_prereleases? || dep_package.prefer_local?
429
+ @all_versions.delete(dep_package)
430
+ @sorted_versions.delete(dep_package)
247
431
  end
432
+ dep_package.consider_prereleases! if dep_package.ignores_prereleases?
433
+ dep_package.consider_remote_versions! if dep_package.prefer_local?
434
+ versions = select_sorted_versions(dep_package, dep_range)
248
435
  end
249
- end
436
+
437
+ if versions.empty? && select_all_versions(dep_package, dep_range).any?
438
+ raise_all_versions_filtered_out!(dep_package)
439
+ end
440
+
441
+ next [dep_package, dep_constraint] unless versions.empty?
442
+
443
+ next unless dep_package.current_platform?
444
+
445
+ raise_not_found!(dep_package)
446
+ end.to_h
250
447
  end
251
448
 
252
- def verify_gemfile_dependencies_are_found!(requirements)
253
- requirements.each do |requirement|
254
- name = requirement.name
255
- next if name == "bundler"
256
- next unless search_for(requirement).empty?
257
-
258
- if (base = @base[name]) && !base.empty?
259
- version = base.first.version
260
- message = "You have requested:\n" \
261
- " #{name} #{requirement.requirement}\n\n" \
262
- "The bundle currently has #{name} locked at #{version}.\n" \
263
- "Try running `bundle update #{name}`\n\n" \
264
- "If you are updating multiple gems in your Gemfile at once,\n" \
265
- "try passing them all to `bundle update`"
449
+ def select_sorted_versions(package, range)
450
+ range.select_versions(@sorted_versions[package])
451
+ end
452
+
453
+ def select_all_versions(package, range)
454
+ range.select_versions(@all_versions[package])
455
+ end
456
+
457
+ def other_specs_matching_message(specs, requirement)
458
+ message = String.new("The source contains the following gems matching '#{requirement}':\n")
459
+ message << specs.map {|s| " * #{s.full_name}" }.join("\n")
460
+ message
461
+ end
462
+
463
+ def requirement_to_range(requirement)
464
+ ranges = requirement.requirements.map do |(op, version)|
465
+ ver = Resolver::Candidate.new(version, priority: -1)
466
+ platform_ver = Resolver::Candidate.new(version, priority: 1)
467
+
468
+ case op
469
+ when "~>"
470
+ name = "~> #{ver}"
471
+ bump = Resolver::Candidate.new(version.bump.to_s + ".A")
472
+ PubGrub::VersionRange.new(name: name, min: ver, max: bump, include_min: true)
473
+ when ">"
474
+ PubGrub::VersionRange.new(min: platform_ver)
475
+ when ">="
476
+ PubGrub::VersionRange.new(min: ver, include_min: true)
477
+ when "<"
478
+ PubGrub::VersionRange.new(max: ver)
479
+ when "<="
480
+ PubGrub::VersionRange.new(max: platform_ver, include_max: true)
481
+ when "="
482
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true)
483
+ when "!="
484
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true).invert
266
485
  else
267
- source = source_for(name)
268
- specs = source.specs.search(name)
269
- versions_with_platforms = specs.map {|s| [s.version, s.platform] }
270
- cache_message = begin
271
- " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
272
- rescue GemfileNotFound
273
- nil
274
- end
275
- message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source.to_err}#{cache_message}.\n")
276
- message << "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}" if versions_with_platforms.any?
486
+ raise "bad version specifier: #{op}"
277
487
  end
278
- raise GemNotFound, message
279
488
  end
489
+
490
+ ranges.inject(&:intersect)
280
491
  end
281
492
 
282
- def formatted_versions_with_platforms(versions_with_platforms)
283
- version_platform_strs = versions_with_platforms.map do |vwp|
284
- version = vwp.first
285
- platform = vwp.last
286
- version_platform_str = String.new(version.to_s)
287
- version_platform_str << " #{platform}" unless platform.nil? || platform == Gem::Platform::RUBY
288
- version_platform_str
493
+ def to_dependency_hash(dependencies, packages)
494
+ dependencies.inject({}) do |deps, dep|
495
+ package = packages[dep.name]
496
+
497
+ current_req = deps[package]
498
+ new_req = parse_dependency(package, dep.requirement)
499
+
500
+ deps[package] = if current_req
501
+ current_req.intersect(new_req)
502
+ else
503
+ new_req
504
+ end
505
+
506
+ deps
289
507
  end
290
- version_platform_strs.join(", ")
291
508
  end
292
509
 
293
- def version_conflict_message(e)
294
- # only show essential conflicts, if possible
295
- conflicts = e.conflicts.dup
510
+ def bundler_not_found_message(conflict_dependencies)
511
+ candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies)
296
512
 
297
- if conflicts["bundler"]
298
- conflicts.replace("bundler" => conflicts["bundler"])
513
+ if candidate_specs.any?
514
+ target_version = candidate_specs.last.version
515
+ new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
516
+ "Your bundle requires a different version of Bundler than the one you're running.\n" \
517
+ "Install the necessary version with `gem install bundler:#{target_version}` and rerun bundler using `#{new_command}`\n"
299
518
  else
300
- conflicts.delete_if do |_name, conflict|
301
- deps = conflict.requirement_trees.map(&:last).flatten(1)
302
- !Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
303
- end
519
+ "Your bundle requires a different version of Bundler than the one you're running, and that version could not be found.\n"
304
520
  end
305
-
306
- e = Molinillo::VersionConflict.new(conflicts, e.specification_provider) unless conflicts.empty?
307
-
308
- solver_name = "Bundler"
309
- possibility_type = "gem"
310
- e.message_with_trees(
311
- :solver_name => solver_name,
312
- :possibility_type => possibility_type,
313
- :reduce_trees => lambda do |trees|
314
- # called first, because we want to reduce the amount of work required to find maximal empty sets
315
- trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } }
316
-
317
- # bail out if tree size is too big for Array#combination to make any sense
318
- return trees if trees.size > 15
319
- maximal = 1.upto(trees.size).map do |size|
320
- trees.map(&:last).flatten(1).combination(size).to_a
321
- end.flatten(1).select do |deps|
322
- Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement)))
323
- end.min_by(&:size)
324
-
325
- trees.reject! {|t| !maximal.include?(t.last) } if maximal
326
-
327
- trees.sort_by {|t| t.reverse.map(&:name) }
328
- end,
329
- :printable_requirement => lambda {|req| SharedHelpers.pretty_dependency(req) },
330
- :additional_message_for_conflict => lambda do |o, name, conflict|
331
- if name == "bundler"
332
- o << %(\n Current Bundler version:\n bundler (#{Bundler::VERSION}))
333
-
334
- conflict_dependency = conflict.requirement
335
- conflict_requirement = conflict_dependency.requirement
336
- other_bundler_required = !conflict_requirement.satisfied_by?(Gem::Version.new(Bundler::VERSION))
337
-
338
- if other_bundler_required
339
- o << "\n\n"
340
-
341
- candidate_specs = source_for(:default_bundler).specs.search(conflict_dependency)
342
- if candidate_specs.any?
343
- target_version = candidate_specs.last.version
344
- new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ")
345
- o << "Your bundle requires a different version of Bundler than the one you're running.\n"
346
- o << "Install the necessary version with `gem install bundler:#{target_version}` and rerun bundler using `#{new_command}`\n"
347
- else
348
- o << "Your bundle requires a different version of Bundler than the one you're running, and that version could not be found.\n"
349
- end
350
- end
351
- elsif conflict.locked_requirement
352
- o << "\n"
353
- o << %(Running `bundle update` will rebuild your snapshot from scratch, using only\n)
354
- o << %(the gems in your Gemfile, which may resolve the conflict.\n)
355
- elsif !conflict.existing
356
- o << "\n"
357
-
358
- relevant_source = conflict.requirement.source || source_for(name)
359
-
360
- metadata_requirement = name.end_with?("\0")
361
-
362
- o << "Could not find gem '" unless metadata_requirement
363
- o << SharedHelpers.pretty_dependency(conflict.requirement)
364
- o << "'" unless metadata_requirement
365
- if conflict.requirement_trees.first.size > 1
366
- o << ", which is required by "
367
- o << "gem '#{SharedHelpers.pretty_dependency(conflict.requirement_trees.first[-2])}',"
368
- end
369
- o << " "
370
-
371
- o << if metadata_requirement
372
- "is not available in #{relevant_source}"
373
- else
374
- "in #{relevant_source.to_err}.\n"
375
- end
376
- end
377
- end,
378
- :version_for_spec => lambda {|spec| spec.version },
379
- :incompatible_version_message_for_conflict => lambda do |name, _conflict|
380
- if name.end_with?("\0")
381
- %(#{solver_name} found conflicting requirements for the #{name} version:)
382
- else
383
- %(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
384
- end
385
- end
386
- )
387
521
  end
388
522
  end
389
523
  end