rubygems-update 2.6.11 → 2.7.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (405) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -22
  3. data/CONTRIBUTING.rdoc +53 -54
  4. data/History.txt +405 -0
  5. data/Manifest.txt +46 -15
  6. data/POLICIES.rdoc +3 -3
  7. data/README.md +72 -0
  8. data/Rakefile +55 -12
  9. data/appveyor.yml +29 -1
  10. data/bin/gem +1 -1
  11. data/bin/update_rubygems +2 -2
  12. data/bundler/CHANGELOG.md +412 -9
  13. data/bundler/CODE_OF_CONDUCT.md +1 -1
  14. data/bundler/CONTRIBUTING.md +10 -29
  15. data/bundler/README.md +27 -11
  16. data/bundler/bundler.gemspec +58 -0
  17. data/bundler/exe/bundle +5 -7
  18. data/bundler/exe/bundle_ruby +4 -3
  19. data/bundler/lib/bundler.rb +103 -79
  20. data/bundler/lib/bundler/build_metadata.rb +53 -0
  21. data/bundler/lib/bundler/capistrano.rb +5 -0
  22. data/bundler/lib/bundler/cli.rb +231 -66
  23. data/bundler/lib/bundler/cli/add.rb +25 -0
  24. data/bundler/lib/bundler/cli/binstubs.rb +9 -7
  25. data/bundler/lib/bundler/cli/cache.rb +5 -4
  26. data/bundler/lib/bundler/cli/check.rb +3 -5
  27. data/bundler/lib/bundler/cli/clean.rb +5 -6
  28. data/bundler/lib/bundler/cli/common.rb +18 -2
  29. data/bundler/lib/bundler/cli/config.rb +26 -7
  30. data/bundler/lib/bundler/cli/console.rb +2 -1
  31. data/bundler/lib/bundler/cli/doctor.rb +1 -0
  32. data/bundler/lib/bundler/cli/exec.rb +6 -5
  33. data/bundler/lib/bundler/cli/gem.rb +42 -18
  34. data/bundler/lib/bundler/cli/info.rb +50 -0
  35. data/bundler/lib/bundler/cli/init.rb +21 -7
  36. data/bundler/lib/bundler/cli/inject.rb +13 -4
  37. data/bundler/lib/bundler/cli/install.rb +61 -77
  38. data/bundler/lib/bundler/cli/issue.rb +40 -0
  39. data/bundler/lib/bundler/cli/list.rb +22 -0
  40. data/bundler/lib/bundler/cli/lock.rb +4 -2
  41. data/bundler/lib/bundler/cli/open.rb +2 -2
  42. data/bundler/lib/bundler/cli/outdated.rb +30 -28
  43. data/bundler/lib/bundler/cli/package.rb +9 -6
  44. data/bundler/lib/bundler/cli/platform.rb +1 -0
  45. data/bundler/lib/bundler/cli/plugin.rb +1 -0
  46. data/bundler/lib/bundler/cli/pristine.rb +43 -0
  47. data/bundler/lib/bundler/cli/show.rb +1 -1
  48. data/bundler/lib/bundler/cli/update.rb +36 -13
  49. data/bundler/lib/bundler/cli/viz.rb +5 -1
  50. data/bundler/lib/bundler/compact_index_client.rb +1 -0
  51. data/bundler/lib/bundler/compact_index_client/cache.rb +1 -2
  52. data/bundler/lib/bundler/compact_index_client/updater.rb +36 -8
  53. data/bundler/lib/bundler/compatibility_guard.rb +14 -0
  54. data/bundler/lib/bundler/constants.rb +1 -0
  55. data/bundler/lib/bundler/current_ruby.rb +16 -8
  56. data/bundler/lib/bundler/definition.rb +252 -170
  57. data/bundler/lib/bundler/dep_proxy.rb +3 -1
  58. data/bundler/lib/bundler/dependency.rb +7 -7
  59. data/bundler/lib/bundler/deployment.rb +1 -1
  60. data/bundler/lib/bundler/deprecate.rb +15 -3
  61. data/bundler/lib/bundler/dsl.rb +103 -62
  62. data/bundler/lib/bundler/endpoint_specification.rb +13 -3
  63. data/bundler/lib/bundler/env.rb +101 -38
  64. data/bundler/lib/bundler/environment_preserver.rb +27 -6
  65. data/bundler/lib/bundler/errors.rb +3 -1
  66. data/bundler/lib/bundler/feature_flag.rb +39 -4
  67. data/bundler/lib/bundler/fetcher.rb +18 -11
  68. data/bundler/lib/bundler/fetcher/base.rb +1 -0
  69. data/bundler/lib/bundler/fetcher/compact_index.rb +2 -12
  70. data/bundler/lib/bundler/fetcher/dependency.rb +2 -1
  71. data/bundler/lib/bundler/fetcher/downloader.rb +14 -7
  72. data/bundler/lib/bundler/fetcher/index.rb +3 -2
  73. data/bundler/lib/bundler/friendly_errors.rb +7 -2
  74. data/bundler/lib/bundler/gem_helper.rb +24 -10
  75. data/bundler/lib/bundler/gem_helpers.rb +1 -0
  76. data/bundler/lib/bundler/gem_remote_fetcher.rb +1 -0
  77. data/bundler/lib/bundler/gem_tasks.rb +1 -0
  78. data/bundler/lib/bundler/gem_version_promoter.rb +13 -0
  79. data/bundler/lib/bundler/gemdeps.rb +1 -0
  80. data/bundler/lib/bundler/graph.rb +1 -0
  81. data/bundler/lib/bundler/index.rb +19 -11
  82. data/bundler/lib/bundler/injector.rb +54 -30
  83. data/bundler/lib/bundler/inline.rb +10 -10
  84. data/bundler/lib/bundler/installer.rb +114 -52
  85. data/bundler/lib/bundler/installer/gem_installer.rb +14 -4
  86. data/bundler/lib/bundler/installer/parallel_installer.rb +91 -42
  87. data/bundler/lib/bundler/installer/standalone.rb +1 -0
  88. data/bundler/lib/bundler/lazy_specification.rb +17 -4
  89. data/bundler/lib/bundler/lockfile_generator.rb +95 -0
  90. data/bundler/lib/bundler/lockfile_parser.rb +49 -35
  91. data/bundler/lib/bundler/match_platform.rb +1 -0
  92. data/bundler/lib/bundler/mirror.rb +10 -5
  93. data/bundler/lib/bundler/plugin.rb +8 -3
  94. data/bundler/lib/bundler/plugin/api/source.rb +16 -3
  95. data/bundler/lib/bundler/plugin/index.rb +9 -2
  96. data/bundler/lib/bundler/plugin/installer.rb +7 -6
  97. data/bundler/lib/bundler/plugin/source_list.rb +7 -8
  98. data/bundler/lib/bundler/process_lock.rb +24 -0
  99. data/bundler/lib/bundler/psyched_yaml.rb +10 -0
  100. data/bundler/lib/bundler/remote_specification.rb +25 -1
  101. data/bundler/lib/bundler/resolver.rb +176 -193
  102. data/bundler/lib/bundler/resolver/spec_group.rb +106 -0
  103. data/bundler/lib/bundler/retry.rb +1 -0
  104. data/bundler/lib/bundler/ruby_dsl.rb +1 -0
  105. data/bundler/lib/bundler/ruby_version.rb +7 -2
  106. data/bundler/lib/bundler/rubygems_ext.rb +18 -8
  107. data/bundler/lib/bundler/rubygems_gem_installer.rb +25 -2
  108. data/bundler/lib/bundler/rubygems_integration.rb +166 -69
  109. data/bundler/lib/bundler/runtime.rb +29 -19
  110. data/bundler/lib/bundler/settings.rb +202 -87
  111. data/bundler/lib/bundler/settings/validator.rb +79 -0
  112. data/bundler/lib/bundler/setup.rb +4 -7
  113. data/bundler/lib/bundler/shared_helpers.rb +143 -27
  114. data/bundler/lib/bundler/similarity_detector.rb +1 -0
  115. data/bundler/lib/bundler/source.rb +53 -1
  116. data/bundler/lib/bundler/source/gemspec.rb +1 -0
  117. data/bundler/lib/bundler/source/git.rb +51 -22
  118. data/bundler/lib/bundler/source/git/git_proxy.rb +23 -13
  119. data/bundler/lib/bundler/source/metadata.rb +63 -0
  120. data/bundler/lib/bundler/source/path.rb +38 -17
  121. data/bundler/lib/bundler/source/path/installer.rb +4 -2
  122. data/bundler/lib/bundler/source/rubygems.rb +161 -82
  123. data/bundler/lib/bundler/source/rubygems/remote.rb +12 -2
  124. data/bundler/lib/bundler/source_list.rb +75 -15
  125. data/bundler/lib/bundler/spec_set.rb +37 -21
  126. data/bundler/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
  127. data/bundler/lib/bundler/stub_specification.rb +86 -2
  128. data/bundler/lib/bundler/templates/.document +1 -0
  129. data/bundler/lib/bundler/templates/Executable +13 -1
  130. data/bundler/lib/bundler/templates/Executable.bundler +105 -0
  131. data/bundler/lib/bundler/templates/Executable.standalone +5 -5
  132. data/bundler/lib/bundler/templates/Gemfile +3 -0
  133. data/bundler/lib/bundler/templates/gems.rb +8 -0
  134. data/bundler/lib/bundler/templates/newgem/Gemfile.tt +4 -2
  135. data/bundler/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  136. data/bundler/lib/bundler/templates/newgem/README.md.tt +14 -8
  137. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +5 -5
  138. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  139. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  140. data/bundler/lib/bundler/templates/newgem/gitignore.tt +0 -1
  141. data/bundler/lib/bundler/templates/newgem/lib/newgem.rb.tt +6 -6
  142. data/bundler/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
  143. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -12
  144. data/bundler/lib/bundler/templates/newgem/rspec.tt +1 -0
  145. data/bundler/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +0 -2
  146. data/bundler/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +3 -0
  147. data/bundler/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
  148. data/bundler/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
  149. data/bundler/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  150. data/bundler/lib/bundler/ui.rb +1 -0
  151. data/bundler/lib/bundler/ui/rg_proxy.rb +1 -0
  152. data/bundler/lib/bundler/ui/shell.rb +26 -10
  153. data/bundler/lib/bundler/ui/silent.rb +12 -1
  154. data/bundler/lib/bundler/uri_credentials_filter.rb +1 -0
  155. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
  156. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
  157. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
  158. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
  159. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
  160. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +16 -5
  161. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +1 -0
  162. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +10 -2
  163. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -0
  164. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -0
  165. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -0
  166. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +1 -0
  167. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -0
  168. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -0
  169. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +16 -5
  170. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
  171. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
  172. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
  173. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
  174. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +501 -138
  175. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
  176. data/bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
  177. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +3 -1
  178. data/bundler/lib/bundler/vendor/thor/lib/thor.rb +46 -21
  179. data/bundler/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
  180. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
  181. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  182. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
  183. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
  184. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
  185. data/bundler/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
  186. data/bundler/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
  187. data/bundler/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
  188. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
  189. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
  190. data/bundler/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
  191. data/bundler/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
  192. data/bundler/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
  193. data/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
  194. data/bundler/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  195. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
  196. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
  197. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
  198. data/bundler/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
  199. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
  200. data/bundler/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  201. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
  202. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
  203. data/bundler/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
  204. data/bundler/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
  205. data/bundler/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  206. data/bundler/lib/bundler/vendored_fileutils.rb +9 -0
  207. data/bundler/lib/bundler/vendored_molinillo.rb +1 -0
  208. data/bundler/lib/bundler/vendored_persistent.rb +35 -0
  209. data/bundler/lib/bundler/vendored_thor.rb +6 -2
  210. data/bundler/lib/bundler/version.rb +19 -2
  211. data/bundler/lib/bundler/version_ranges.rb +76 -0
  212. data/bundler/lib/bundler/vlad.rb +5 -0
  213. data/bundler/lib/bundler/worker.rb +3 -1
  214. data/bundler/lib/bundler/yaml_serializer.rb +3 -3
  215. data/bundler/man/bundle-add.ronn +29 -0
  216. data/bundler/man/bundle-binstubs.ronn +15 -1
  217. data/bundler/man/bundle-check.ronn +26 -0
  218. data/bundler/man/bundle-clean.ronn +18 -0
  219. data/bundler/man/bundle-config.ronn +193 -69
  220. data/bundler/man/bundle-doctor.ronn +33 -0
  221. data/bundler/man/bundle-exec.ronn +10 -3
  222. data/bundler/man/bundle-gem.ronn +3 -2
  223. data/bundler/man/bundle-info.ronn +17 -0
  224. data/bundler/man/bundle-init.ronn +29 -0
  225. data/bundler/man/bundle-inject.ronn +22 -0
  226. data/bundler/man/bundle-install.ronn +44 -35
  227. data/bundler/man/bundle-list.ronn +15 -0
  228. data/bundler/man/bundle-lock.ronn +1 -1
  229. data/bundler/man/bundle-open.ronn +19 -0
  230. data/bundler/man/bundle-outdated.ronn +2 -2
  231. data/bundler/man/bundle-package.ronn +7 -2
  232. data/bundler/man/bundle-pristine.ronn +34 -0
  233. data/bundler/man/bundle-show.ronn +21 -0
  234. data/bundler/man/bundle-update.ronn +24 -17
  235. data/bundler/man/bundle-viz.ronn +30 -0
  236. data/bundler/man/bundle.ronn +36 -45
  237. data/bundler/man/gemfile.5.ronn +77 -71
  238. data/lib/rubygems.rb +102 -46
  239. data/lib/rubygems/basic_specification.rb +8 -4
  240. data/lib/rubygems/bundler_version_finder.rb +99 -0
  241. data/lib/rubygems/command.rb +10 -2
  242. data/lib/rubygems/command_manager.rb +8 -4
  243. data/lib/rubygems/commands/cert_command.rb +31 -6
  244. data/lib/rubygems/commands/cleanup_command.rb +10 -3
  245. data/lib/rubygems/commands/generate_index_command.rb +1 -1
  246. data/lib/rubygems/commands/help_command.rb +1 -1
  247. data/lib/rubygems/commands/install_command.rb +7 -0
  248. data/lib/rubygems/commands/open_command.rb +1 -1
  249. data/lib/rubygems/commands/owner_command.rb +7 -2
  250. data/lib/rubygems/commands/pristine_command.rb +11 -8
  251. data/lib/rubygems/commands/push_command.rb +39 -5
  252. data/lib/rubygems/commands/query_command.rb +17 -17
  253. data/lib/rubygems/commands/setup_command.rb +174 -69
  254. data/lib/rubygems/commands/signin_command.rb +33 -0
  255. data/lib/rubygems/commands/signout_command.rb +33 -0
  256. data/lib/rubygems/commands/sources_command.rb +1 -1
  257. data/lib/rubygems/commands/uninstall_command.rb +5 -4
  258. data/lib/rubygems/commands/unpack_command.rb +19 -7
  259. data/lib/rubygems/commands/update_command.rb +1 -1
  260. data/lib/rubygems/commands/which_command.rb +1 -1
  261. data/lib/rubygems/commands/yank_command.rb +4 -11
  262. data/lib/rubygems/config_file.rb +15 -26
  263. data/lib/rubygems/core_ext/kernel_require.rb +12 -16
  264. data/lib/rubygems/dependency.rb +3 -0
  265. data/lib/rubygems/dependency_installer.rb +8 -2
  266. data/lib/rubygems/dependency_list.rb +1 -1
  267. data/lib/rubygems/errors.rb +3 -0
  268. data/lib/rubygems/exceptions.rb +11 -1
  269. data/lib/rubygems/ext/builder.rb +2 -2
  270. data/lib/rubygems/ext/ext_conf_builder.rb +2 -4
  271. data/lib/rubygems/ext/rake_builder.rb +1 -1
  272. data/lib/rubygems/gem_runner.rb +5 -1
  273. data/lib/rubygems/gemcutter_utilities.rb +5 -2
  274. data/lib/rubygems/indexer.rb +6 -5
  275. data/lib/rubygems/install_update_options.rb +6 -29
  276. data/lib/rubygems/installer.rb +60 -13
  277. data/lib/rubygems/installer_test_case.rb +6 -3
  278. data/lib/rubygems/package.rb +55 -8
  279. data/lib/rubygems/package/file_source.rb +2 -2
  280. data/lib/rubygems/package/old.rb +3 -3
  281. data/lib/rubygems/package/tar_header.rb +17 -10
  282. data/lib/rubygems/package/tar_writer.rb +4 -3
  283. data/lib/rubygems/platform.rb +1 -1
  284. data/lib/rubygems/remote_fetcher.rb +2 -2
  285. data/lib/rubygems/request.rb +1 -1
  286. data/lib/rubygems/request_set.rb +47 -19
  287. data/lib/rubygems/request_set/gem_dependency_api.rb +3 -3
  288. data/lib/rubygems/request_set/lockfile.rb +1 -1
  289. data/lib/rubygems/requirement.rb +19 -4
  290. data/lib/rubygems/resolver.rb +24 -3
  291. data/lib/rubygems/resolver/api_specification.rb +5 -0
  292. data/lib/rubygems/resolver/installer_set.rb +4 -6
  293. data/lib/rubygems/safe_yaml.rb +51 -0
  294. data/lib/rubygems/security.rb +18 -6
  295. data/lib/rubygems/security/trust_dir.rb +1 -1
  296. data/lib/rubygems/security_option.rb +43 -0
  297. data/lib/rubygems/server.rb +21 -17
  298. data/lib/rubygems/source.rb +9 -6
  299. data/lib/rubygems/source/git.rb +2 -1
  300. data/lib/rubygems/source/local.rb +38 -35
  301. data/lib/rubygems/source/lock.rb +4 -1
  302. data/lib/rubygems/source_local.rb +3 -1
  303. data/lib/rubygems/source_specific_file.rb +3 -2
  304. data/lib/rubygems/spec_fetcher.rb +7 -3
  305. data/lib/rubygems/specification.rb +315 -249
  306. data/lib/rubygems/ssl_certs/{index.rubygems.org → rubygems.org}/GlobalSignRootCA.pem +0 -0
  307. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
  308. data/lib/rubygems/stub_specification.rb +4 -3
  309. data/lib/rubygems/test_case.rb +51 -11
  310. data/lib/rubygems/test_utilities.rb +2 -2
  311. data/lib/rubygems/text.rb +14 -1
  312. data/lib/rubygems/user_interaction.rb +24 -15
  313. data/lib/rubygems/util.rb +6 -16
  314. data/lib/rubygems/util/licenses.rb +72 -4
  315. data/lib/rubygems/validator.rb +3 -3
  316. data/lib/rubygems/version.rb +24 -4
  317. data/lib/rubygems/version_option.rb +6 -1
  318. data/lib/ubygems.rb +3 -0
  319. data/setup.rb +1 -1
  320. data/test/rubygems/private3072_key.pem +40 -0
  321. data/test/rubygems/public3072_cert.pem +25 -0
  322. data/test/rubygems/test_bundled_ca.rb +7 -4
  323. data/test/rubygems/test_config.rb +1 -1
  324. data/test/rubygems/test_gem.rb +158 -39
  325. data/test/rubygems/test_gem_bundler_version_finder.rb +126 -0
  326. data/test/rubygems/test_gem_command.rb +7 -1
  327. data/test/rubygems/test_gem_command_manager.rb +2 -2
  328. data/test/rubygems/test_gem_commands_build_command.rb +29 -1
  329. data/test/rubygems/test_gem_commands_cert_command.rb +64 -0
  330. data/test/rubygems/test_gem_commands_cleanup_command.rb +44 -1
  331. data/test/rubygems/test_gem_commands_install_command.rb +73 -2
  332. data/test/rubygems/test_gem_commands_open_command.rb +2 -1
  333. data/test/rubygems/test_gem_commands_owner_command.rb +25 -0
  334. data/test/rubygems/test_gem_commands_pristine_command.rb +1 -1
  335. data/test/rubygems/test_gem_commands_push_command.rb +25 -5
  336. data/test/rubygems/test_gem_commands_query_command.rb +154 -1
  337. data/test/rubygems/test_gem_commands_setup_command.rb +140 -10
  338. data/test/rubygems/test_gem_commands_signin_command.rb +98 -0
  339. data/test/rubygems/test_gem_commands_signout_command.rb +37 -0
  340. data/test/rubygems/test_gem_commands_sources_command.rb +52 -0
  341. data/test/rubygems/test_gem_commands_uninstall_command.rb +15 -3
  342. data/test/rubygems/test_gem_commands_update_command.rb +1 -7
  343. data/test/rubygems/test_gem_commands_which_command.rb +3 -3
  344. data/test/rubygems/test_gem_dependency.rb +28 -0
  345. data/test/rubygems/test_gem_dependency_installer.rb +1 -1
  346. data/test/rubygems/test_gem_doctor.rb +2 -2
  347. data/test/rubygems/test_gem_ext_builder.rb +8 -8
  348. data/test/rubygems/test_gem_ext_configure_builder.rb +1 -1
  349. data/test/rubygems/test_gem_ext_rake_builder.rb +2 -6
  350. data/test/rubygems/test_gem_gemcutter_utilities.rb +4 -4
  351. data/test/rubygems/test_gem_indexer.rb +1 -2
  352. data/test/rubygems/test_gem_install_update_options.rb +6 -1
  353. data/test/rubygems/test_gem_installer.rb +168 -31
  354. data/test/rubygems/test_gem_package.rb +183 -26
  355. data/test/rubygems/test_gem_package_old.rb +1 -1
  356. data/test/rubygems/test_gem_package_tar_header.rb +21 -0
  357. data/test/rubygems/test_gem_rdoc.rb +2 -0
  358. data/test/rubygems/test_gem_remote_fetcher.rb +24 -5
  359. data/test/rubygems/test_gem_request.rb +5 -2
  360. data/test/rubygems/test_gem_request_connection_pools.rb +6 -7
  361. data/test/rubygems/test_gem_request_set.rb +7 -7
  362. data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +3 -3
  363. data/test/rubygems/test_gem_request_set_lockfile.rb +4 -4
  364. data/test/rubygems/test_gem_request_set_lockfile_parser.rb +1 -1
  365. data/test/rubygems/test_gem_request_set_lockfile_tokenizer.rb +1 -1
  366. data/test/rubygems/test_gem_requirement.rb +12 -0
  367. data/test/rubygems/test_gem_resolver.rb +26 -0
  368. data/test/rubygems/test_gem_resolver_api_specification.rb +24 -0
  369. data/test/rubygems/test_gem_resolver_conflict.rb +1 -1
  370. data/test/rubygems/test_gem_resolver_git_specification.rb +1 -1
  371. data/test/rubygems/test_gem_resolver_installer_set.rb +1 -1
  372. data/test/rubygems/test_gem_security.rb +5 -0
  373. data/test/rubygems/test_gem_security_policy.rb +27 -27
  374. data/test/rubygems/test_gem_security_signer.rb +6 -6
  375. data/test/rubygems/test_gem_security_trust_dir.rb +2 -2
  376. data/test/rubygems/test_gem_server.rb +194 -12
  377. data/test/rubygems/test_gem_source.rb +12 -3
  378. data/test/rubygems/test_gem_source_git.rb +1 -1
  379. data/test/rubygems/test_gem_spec_fetcher.rb +20 -0
  380. data/test/rubygems/test_gem_specification.rb +180 -42
  381. data/test/rubygems/test_gem_stream_ui.rb +8 -8
  382. data/test/rubygems/test_gem_stub_specification.rb +26 -8
  383. data/test/rubygems/test_gem_text.rb +16 -0
  384. data/test/rubygems/test_gem_util.rb +26 -0
  385. data/test/rubygems/test_gem_version.rb +68 -9
  386. data/test/rubygems/test_gem_version_option.rb +15 -0
  387. data/test/rubygems/test_kernel.rb +30 -0
  388. data/test/rubygems/test_require.rb +70 -21
  389. data/util/ci +1 -0
  390. data/util/generate_spdx_license_list.rb +16 -6
  391. data/util/update_bundled_ca_certificates.rb +1 -3
  392. metadata +61 -57
  393. data/README.rdoc +0 -54
  394. data/bundler/DEVELOPMENT.md +0 -150
  395. data/bundler/ISSUES.md +0 -117
  396. data/bundler/lib/bundler/postit_trampoline.rb +0 -73
  397. data/bundler/lib/bundler/vendor/postit/lib/postit.rb +0 -15
  398. data/bundler/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
  399. data/bundler/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
  400. data/bundler/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
  401. data/bundler/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
  402. data/bundler/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
  403. data/bundler/man/index.txt +0 -8
  404. data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  405. data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: false
2
+
3
+ require "rubygems"
4
+ require "bundler/version"
5
+
6
+ if Bundler::VERSION.split(".").first.to_i >= 2
7
+ if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3")
8
+ abort "Bundler 2 requires Ruby 2.3 or later. Either install bundler 1 or update to a supported Ruby version."
9
+ end
10
+
11
+ if Gem::Version.new(Gem::VERSION.dup) < Gem::Version.new("2.5")
12
+ abort "Bundler 2 requires RubyGems 2.5 or later. Either install bundler 1 or update to a supported RubyGems version."
13
+ end
14
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
4
5
  FREEBSD = RbConfig::CONFIG["host_os"] =~ /bsd/
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  # Returns current version of Ruby
4
5
  #
@@ -8,7 +9,7 @@ module Bundler
8
9
  end
9
10
 
10
11
  class CurrentRuby
11
- KNOWN_MINOR_VERSIONS = %w(
12
+ KNOWN_MINOR_VERSIONS = %w[
12
13
  1.8
13
14
  1.9
14
15
  2.0
@@ -17,11 +18,12 @@ module Bundler
17
18
  2.3
18
19
  2.4
19
20
  2.5
20
- ).freeze
21
+ 2.6
22
+ ].freeze
21
23
 
22
24
  KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
23
25
 
24
- KNOWN_PLATFORMS = %w(
26
+ KNOWN_PLATFORMS = %w[
25
27
  jruby
26
28
  maglev
27
29
  mingw
@@ -30,11 +32,13 @@ module Bundler
30
32
  mswin64
31
33
  rbx
32
34
  ruby
35
+ truffleruby
33
36
  x64_mingw
34
- ).freeze
37
+ ].freeze
35
38
 
36
39
  def ruby?
37
- !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
40
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" ||
41
+ RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
38
42
  end
39
43
 
40
44
  def mri?
@@ -53,20 +57,24 @@ module Bundler
53
57
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
54
58
  end
55
59
 
60
+ def truffleruby?
61
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "truffleruby"
62
+ end
63
+
56
64
  def mswin?
57
65
  Bundler::WINDOWS
58
66
  end
59
67
 
60
68
  def mswin64?
61
- Bundler::WINDOWS && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
69
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
62
70
  end
63
71
 
64
72
  def mingw?
65
- Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
73
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
66
74
  end
67
75
 
68
76
  def x64_mingw?
69
- Bundler::WINDOWS && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
77
+ Bundler::WINDOWS && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
70
78
  end
71
79
 
72
80
  (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "bundler/lockfile_parser"
3
- require "digest/sha1"
4
4
  require "set"
5
5
 
6
6
  module Bundler
@@ -14,7 +14,9 @@ module Bundler
14
14
  :locked_gems,
15
15
  :platforms,
16
16
  :requires,
17
- :ruby_version
17
+ :ruby_version,
18
+ :lockfile,
19
+ :gemfiles
18
20
  )
19
21
 
20
22
  # Given a gemfile and lockfile creates a Bundler definition
@@ -51,8 +53,16 @@ module Bundler
51
53
  # to be updated or true if all gems should be updated
52
54
  # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
53
55
  # @param optional_groups [Array(String)] A list of optional groups
54
- def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [])
55
- @unlocking = unlock == true || !unlock.empty?
56
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
57
+ if [true, false].include?(unlock)
58
+ @unlocking_bundler = false
59
+ @unlocking = unlock
60
+ else
61
+ unlock = unlock.dup
62
+ @unlocking_bundler = unlock.delete(:bundler)
63
+ unlock.delete_if {|_k, v| Array(v).empty? }
64
+ @unlocking = !unlock.empty?
65
+ end
56
66
 
57
67
  @dependencies = dependencies
58
68
  @sources = sources
@@ -61,11 +71,13 @@ module Bundler
61
71
  @remote = false
62
72
  @specs = nil
63
73
  @ruby_version = ruby_version
74
+ @gemfiles = gemfiles
64
75
 
65
76
  @lockfile = lockfile
66
77
  @lockfile_contents = String.new
67
78
  @locked_bundler_version = nil
68
79
  @locked_ruby_version = nil
80
+ @locked_specs_incomplete_for_platform = false
69
81
 
70
82
  if lockfile && File.exist?(lockfile)
71
83
  @lockfile_contents = Bundler.read_file(lockfile)
@@ -81,7 +93,7 @@ module Bundler
81
93
  @locked_sources = @locked_gems.sources
82
94
  else
83
95
  @unlock = {}
84
- @locked_deps = []
96
+ @locked_deps = {}
85
97
  @locked_specs = SpecSet.new([])
86
98
  @locked_sources = []
87
99
  end
@@ -89,7 +101,7 @@ module Bundler
89
101
  @unlock = {}
90
102
  @platforms = []
91
103
  @locked_gems = nil
92
- @locked_deps = []
104
+ @locked_deps = {}
93
105
  @locked_specs = SpecSet.new([])
94
106
  @locked_sources = []
95
107
  @locked_platforms = []
@@ -102,44 +114,28 @@ module Bundler
102
114
  end
103
115
  @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
104
116
 
105
- add_current_platform unless Bundler.settings[:frozen]
117
+ add_current_platform unless Bundler.frozen_bundle?
106
118
 
119
+ converge_path_sources_to_gemspec_sources
107
120
  @path_changes = converge_paths
121
+ @source_changes = converge_sources
108
122
 
109
123
  unless @unlock[:lock_shared_dependencies]
110
- eager_unlock = expand_dependencies(@unlock[:gems])
111
- @unlock[:gems] = @locked_specs.for(eager_unlock).map(&:name)
124
+ eager_unlock = expand_dependencies(@unlock[:gems], true)
125
+ @unlock[:gems] = @locked_specs.for(eager_unlock, [], false, false, false).map(&:name)
112
126
  end
113
127
 
114
128
  @gem_version_promoter = create_gem_version_promoter
115
129
 
116
- @source_changes = converge_sources
117
130
  @dependency_changes = converge_dependencies
118
131
  @local_changes = converge_locals
119
132
 
120
133
  @requires = compute_requires
121
-
122
- fixup_dependency_types!
123
- end
124
-
125
- def fixup_dependency_types!
126
- # XXX This is a temporary workaround for a bug when using rubygems 1.8.15
127
- # where Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
128
- # doesn't carry a notion of the dependency type, if you use
129
- # add_development_dependency in a gemspec that's loaded with the gemspec
130
- # directive, the lockfile dependencies and resolved dependencies end up
131
- # with a mismatch on #type.
132
- # Test coverage to catch a regression on this is in gemspec_spec.rb
133
- @dependencies.each do |d|
134
- if ld = @locked_deps.find {|l| l.name == d.name }
135
- ld.instance_variable_set(:@type, d.type)
136
- end
137
- end
138
134
  end
139
135
 
140
136
  def create_gem_version_promoter
141
137
  locked_specs =
142
- if @unlocking && @locked_specs.empty? && !@lockfile_contents.empty?
138
+ if unlocking? && @locked_specs.empty? && !@lockfile_contents.empty?
143
139
  # Definition uses an empty set of locked_specs to indicate all gems
144
140
  # are unlocked, but GemVersionPromoter needs the locked_specs
145
141
  # for conservative comparison.
@@ -180,12 +176,11 @@ module Bundler
180
176
  raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
181
177
  "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
182
178
  "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
183
- "to a different version of #{locked_gem} that hasn't been removed in order to install."
179
+ "to a version other than #{locked_gem} that hasn't been removed in order to install."
184
180
  end
185
181
  unless specs["bundler"].any?
186
- local = Bundler.settings[:frozen] ? rubygems_index : index
187
- bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
188
- specs["bundler"] = bundler if bundler
182
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
183
+ specs["bundler"] = bundler
189
184
  end
190
185
 
191
186
  specs
@@ -210,10 +205,19 @@ module Bundler
210
205
  missing
211
206
  end
212
207
 
213
- def missing_dependencies
214
- missing = []
215
- resolve.materialize(current_dependencies, missing)
216
- missing
208
+ def missing_specs?
209
+ missing = missing_specs
210
+ return false if missing.empty?
211
+ Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
212
+ true
213
+ rescue BundlerError => e
214
+ @index = nil
215
+ @resolve = nil
216
+ @specs = nil
217
+ @gem_version_promoter = create_gem_version_promoter
218
+
219
+ Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
220
+ true
217
221
  end
218
222
 
219
223
  def requested_specs
@@ -242,14 +246,22 @@ module Bundler
242
246
  def resolve
243
247
  @resolve ||= begin
244
248
  last_resolve = converge_locked_specs
245
- if Bundler.settings[:frozen] || (!@unlocking && nothing_changed?)
246
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
247
- last_resolve
248
- else
249
- # Run a resolve against the locally available gems
250
- Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
251
- last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve)
252
- end
249
+ resolve =
250
+ if Bundler.frozen_bundle?
251
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
252
+ last_resolve
253
+ elsif !unlocking? && nothing_changed?
254
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
255
+ last_resolve
256
+ else
257
+ # Run a resolve against the locally available gems
258
+ Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
259
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
260
+ end
261
+
262
+ # filter out gems that _can_ be installed on multiple platforms, but don't need
263
+ # to be
264
+ resolve.for(expand_dependencies(dependencies, true), [], false, false, false)
253
265
  end
254
266
  end
255
267
 
@@ -258,25 +270,44 @@ module Bundler
258
270
  dependency_names = @dependencies.map(&:name)
259
271
 
260
272
  sources.all_sources.each do |source|
261
- source.dependency_names = dependency_names.dup
273
+ source.dependency_names = dependency_names - pinned_spec_names(source)
262
274
  idx.add_source source.specs
263
- dependency_names -= pinned_spec_names(source.specs)
264
275
  dependency_names.concat(source.unmet_deps).uniq!
265
276
  end
266
- idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
267
- idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
268
- end
269
- end
270
277
 
271
- # used when frozen is enabled so we can find the bundler
272
- # spec, even if (say) a git gem is not checked out.
273
- def rubygems_index
274
- @rubygems_index ||= Index.build do |idx|
275
- sources.rubygems_sources.each do |rubygems|
276
- idx.add_source rubygems.specs
278
+ double_check_for_index(idx, dependency_names)
279
+ end
280
+ end
281
+
282
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
283
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
284
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
285
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
286
+ # each spec we found, we add all possible versions from all sources to the index.
287
+ def double_check_for_index(idx, dependency_names)
288
+ pinned_names = pinned_spec_names
289
+ loop do
290
+ idxcount = idx.size
291
+
292
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
293
+ unmet_dependency_names = lambda do
294
+ return names unless names == :names
295
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
296
+ return names = nil if new_names.compact!
297
+ names = new_names.flatten(1).concat(dependency_names)
298
+ names.uniq!
299
+ names -= pinned_names
300
+ names
301
+ end
302
+
303
+ sources.all_sources.each do |source|
304
+ source.double_check_for(unmet_dependency_names)
277
305
  end
306
+
307
+ break if idxcount == idx.size
278
308
  end
279
309
  end
310
+ private :double_check_for_index
280
311
 
281
312
  def has_rubygems_remotes?
282
313
  sources.rubygems_sources.any? {|s| s.remotes.any? }
@@ -311,10 +342,11 @@ module Bundler
311
342
  end
312
343
  end
313
344
 
314
- preserve_unknown_sections ||= !updating_major && (Bundler.settings[:frozen] || !@unlocking)
315
- return if lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
345
+ preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
316
346
 
317
- if Bundler.settings[:frozen]
347
+ return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
348
+
349
+ if Bundler.frozen_bundle?
318
350
  Bundler.ui.error "Cannot write a changed lockfile while frozen."
319
351
  return
320
352
  end
@@ -354,51 +386,8 @@ module Bundler
354
386
  end
355
387
 
356
388
  def to_lock
357
- out = String.new
358
-
359
- sources.lock_sources.each do |source|
360
- # Add the source header
361
- out << source.to_lock
362
- # Find all specs for this source
363
- resolve.
364
- select {|s| source.can_lock?(s) }.
365
- # This needs to be sorted by full name so that
366
- # gems with the same name, but different platform
367
- # are ordered consistently
368
- sort_by(&:full_name).
369
- each do |spec|
370
- next if spec.name == "bundler"
371
- out << spec.to_lock
372
- end
373
- out << "\n"
374
- end
375
-
376
- out << "PLATFORMS\n"
377
-
378
- platforms.map(&:to_s).sort.each do |p|
379
- out << " #{p}\n"
380
- end
381
-
382
- out << "\n"
383
- out << "DEPENDENCIES\n"
384
-
385
- handled = []
386
- dependencies.sort_by(&:to_s).each do |dep|
387
- next if handled.include?(dep.name)
388
- out << dep.to_lock
389
- handled << dep.name
390
- end
391
-
392
- if locked_ruby_version
393
- out << "\nRUBY VERSION\n"
394
- out << " #{locked_ruby_version}\n"
395
- end
396
-
397
- # Record the version of Bundler that was used to create the lockfile
398
- out << "\nBUNDLED WITH\n"
399
- out << " #{locked_bundler_version}\n"
400
-
401
- out
389
+ require "bundler/lockfile_generator"
390
+ LockfileGenerator.generate(self)
402
391
  end
403
392
 
404
393
  def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
@@ -408,8 +397,15 @@ module Bundler
408
397
  "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
409
398
 
410
399
  unless explicit_flag
400
+ suggested_command = if Bundler.settings.locations("frozen")[:global]
401
+ "bundle config --delete frozen"
402
+ elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
403
+ "bundle config --delete deployment"
404
+ else
405
+ "bundle install --no-deployment"
406
+ end
411
407
  msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
412
- "freeze \nby running `bundle install --no-deployment`."
408
+ "freeze \nby running `#{suggested_command}`."
413
409
  end
414
410
 
415
411
  added = []
@@ -426,13 +422,13 @@ module Bundler
426
422
  new_sources = gemfile_sources - @locked_sources
427
423
  deleted_sources = @locked_sources - gemfile_sources
428
424
 
429
- new_deps = @dependencies - @locked_deps
430
- deleted_deps = @locked_deps - @dependencies
425
+ new_deps = @dependencies - @locked_deps.values
426
+ deleted_deps = @locked_deps.values - @dependencies
431
427
 
432
428
  # Check if it is possible that the source is only changed thing
433
429
  if (new_deps.empty? && deleted_deps.empty?) && (!new_sources.empty? && !deleted_sources.empty?)
434
- new_sources.reject! {|source| source.is_a_path? && source.path.exist? }
435
- deleted_sources.reject! {|source| source.is_a_path? && source.path.exist? }
430
+ new_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
431
+ deleted_sources.reject! {|source| (source.path? && source.path.exist?) || equivalent_rubygems_remotes?(source) }
436
432
  end
437
433
 
438
434
  if @locked_sources != gemfile_sources
@@ -452,7 +448,7 @@ module Bundler
452
448
 
453
449
  both_sources = Hash.new {|h, k| h[k] = [] }
454
450
  @dependencies.each {|d| both_sources[d.name][0] = d }
455
- @locked_deps.each {|d| both_sources[d.name][1] = d.source }
451
+ @locked_deps.each {|name, d| both_sources[name][1] = d.source }
456
452
 
457
453
  both_sources.each do |name, (dep, lock_source)|
458
454
  next unless (dep.nil? && !lock_source.nil?) || (!dep.nil? && !lock_source.nil? && !lock_source.can_lock?(dep))
@@ -461,12 +457,14 @@ module Bundler
461
457
  changed << "* #{name} from `#{gemfile_source_name}` to `#{lockfile_source_name}`"
462
458
  end
463
459
 
460
+ reason = change_reason
461
+ msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
464
462
  msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
465
463
  msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
466
464
  msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
467
465
  msg << "\n"
468
466
 
469
- raise ProductionError, msg if added.any? || deleted.any? || changed.any?
467
+ raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
470
468
  end
471
469
 
472
470
  def validate_runtime!
@@ -523,7 +521,7 @@ module Bundler
523
521
 
524
522
  def add_current_platform
525
523
  current_platform = Bundler.local_platform
526
- add_platform(current_platform) if Bundler.settings[:specific_platform]
524
+ add_platform(current_platform) if Bundler.feature_flag.specific_platform?
527
525
  add_platform(generic(current_platform))
528
526
  end
529
527
 
@@ -538,14 +536,18 @@ module Bundler
538
536
  attr_reader :sources
539
537
  private :sources
540
538
 
541
- private
542
-
543
539
  def nothing_changed?
544
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
540
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
541
+ end
542
+
543
+ def unlocking?
544
+ @unlocking
545
545
  end
546
546
 
547
+ private
548
+
547
549
  def change_reason
548
- if @unlocking
550
+ if unlocking?
549
551
  unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v|
550
552
  if v == true
551
553
  k.to_s
@@ -562,14 +564,12 @@ module Bundler
562
564
  [@new_platform, "you added a new platform to your gemfile"],
563
565
  [@path_changes, "the gemspecs for path gems changed"],
564
566
  [@local_changes, "the gemspecs for git local gems changed"],
567
+ [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"],
565
568
  ].select(&:first).map(&:last).join(", ")
566
569
  end
567
570
 
568
571
  def pretty_dep(dep, source = false)
569
- msg = String.new(dep.name)
570
- msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
571
- msg << " from the `#{dep.source}` source" if source && dep.source
572
- msg
572
+ SharedHelpers.pretty_dependency(dep, source)
573
573
  end
574
574
 
575
575
  # Check if the specs of the given source changed
@@ -582,7 +582,7 @@ module Bundler
582
582
 
583
583
  def dependencies_for_source_changed?(source, locked_source = source)
584
584
  deps_for_source = @dependencies.select {|s| s.source == source }
585
- locked_deps_for_source = @locked_deps.select {|s| s.source == locked_source }
585
+ locked_deps_for_source = @locked_deps.values.select {|dep| dep.source == locked_source }
586
586
 
587
587
  Set.new(deps_for_source) != Set.new(locked_deps_for_source)
588
588
  end
@@ -591,7 +591,11 @@ module Bundler
591
591
  locked_index = Index.new
592
592
  locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
593
593
 
594
- source.specs != locked_index
594
+ # order here matters, since Index#== is checking source.specs.include?(locked_index)
595
+ locked_index != source.specs
596
+ rescue PathError, GitError => e
597
+ Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
598
+ false
595
599
  end
596
600
 
597
601
  # Get all locals and override their matching sources.
@@ -627,29 +631,44 @@ module Bundler
627
631
  gemspec_source || source
628
632
  end
629
633
 
630
- def converge_sources
631
- changes = false
632
-
634
+ def converge_path_sources_to_gemspec_sources
633
635
  @locked_sources.map! do |source|
634
636
  converge_path_source_to_gemspec_source(source)
635
637
  end
636
638
  @locked_specs.each do |spec|
637
639
  spec.source &&= converge_path_source_to_gemspec_source(spec.source)
638
640
  end
641
+ @locked_deps.each do |_, dep|
642
+ dep.source &&= converge_path_source_to_gemspec_source(dep.source)
643
+ end
644
+ end
645
+
646
+ def converge_rubygems_sources
647
+ return false if Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
639
648
 
640
- # Get the Rubygems sources from the Gemfile.lock
649
+ changes = false
650
+
651
+ # Get the RubyGems sources from the Gemfile.lock
641
652
  locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
642
- # Get the Rubygems remotes from the Gemfile
653
+ # Get the RubyGems remotes from the Gemfile
643
654
  actual_remotes = sources.rubygems_remotes
644
655
 
645
- # If there is a Rubygems source in both
656
+ # If there is a RubyGems source in both
646
657
  if !locked_gem_sources.empty? && !actual_remotes.empty?
647
658
  locked_gem_sources.each do |locked_gem|
648
659
  # Merge the remotes from the Gemfile into the Gemfile.lock
649
- changes |= locked_gem.replace_remotes(actual_remotes)
660
+ changes |= locked_gem.replace_remotes(actual_remotes, Bundler.settings[:allow_deployment_source_credential_changes])
650
661
  end
651
662
  end
652
663
 
664
+ changes
665
+ end
666
+
667
+ def converge_sources
668
+ changes = false
669
+
670
+ changes |= converge_rubygems_sources
671
+
653
672
  # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
654
673
  # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
655
674
  # source in the Gemfile.lock, use the one from the Gemfile.
@@ -671,11 +690,12 @@ module Bundler
671
690
  end
672
691
 
673
692
  def converge_dependencies
674
- (@dependencies + @locked_deps).each do |dep|
675
- locked_source = @locked_deps.select {|d| d.name == dep.name }.last
693
+ frozen = Bundler.frozen_bundle?
694
+ (@dependencies + @locked_deps.values).each do |dep|
695
+ locked_source = @locked_deps[dep.name]
676
696
  # This is to make sure that if bundler is installing in deployment mode and
677
697
  # after locked_source and sources don't match, we still use locked_source.
678
- if Bundler.settings[:frozen] && !locked_source.nil? &&
698
+ if frozen && !locked_source.nil? &&
679
699
  locked_source.respond_to?(:source) && locked_source.source.instance_of?(Source::Path) && locked_source.source.path.exist?
680
700
  dep.source = locked_source.source
681
701
  elsif dep.source
@@ -685,7 +705,31 @@ module Bundler
685
705
  dep.platforms.concat(@platforms.map {|p| Dependency::REVERSE_PLATFORM_MAP[p] }.flatten(1)).uniq!
686
706
  end
687
707
  end
688
- Set.new(@dependencies) != Set.new(@locked_deps)
708
+
709
+ changes = false
710
+ # We want to know if all match, but don't want to check all entries
711
+ # This means we need to return false if any dependency doesn't match
712
+ # the lock or doesn't exist in the lock.
713
+ @dependencies.each do |dependency|
714
+ unless locked_dep = @locked_deps[dependency.name]
715
+ changes = true
716
+ next
717
+ end
718
+
719
+ # Gem::Dependency#== matches Gem::Dependency#type. As the lockfile
720
+ # doesn't carry a notion of the dependency type, if you use
721
+ # add_development_dependency in a gemspec that's loaded with the gemspec
722
+ # directive, the lockfile dependencies and resolved dependencies end up
723
+ # with a mismatch on #type. Work around that by setting the type on the
724
+ # dep from the lockfile.
725
+ locked_dep.instance_variable_set(:@type, dependency.type)
726
+
727
+ # We already know the name matches from the hash lookup
728
+ # so we only need to check the requirement now
729
+ changes ||= dependency.requirement != locked_dep.requirement
730
+ end
731
+
732
+ changes
689
733
  end
690
734
 
691
735
  # Remove elements from the locked specs that are expired. This will most
@@ -698,12 +742,11 @@ module Bundler
698
742
  # and Gemfile.lock. If the Gemfile modified a dependency, but
699
743
  # the gem in the Gemfile.lock still satisfies it, this is fine
700
744
  # too.
701
- locked_deps_hash = @locked_deps.inject({}) do |hsh, dep|
702
- hsh[dep] = dep
703
- hsh
704
- end
705
745
  @dependencies.each do |dep|
706
- locked_dep = locked_deps_hash[dep]
746
+ locked_dep = @locked_deps[dep.name]
747
+
748
+ # If the locked_dep doesn't match the dependency we're looking for then we ignore the locked_dep
749
+ locked_dep = nil unless locked_dep == dep
707
750
 
708
751
  if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
709
752
  deps << dep
@@ -717,6 +760,8 @@ module Bundler
717
760
  end
718
761
  end
719
762
 
763
+ unlock_source_unlocks_spec = Bundler.feature_flag.unlock_source_unlocks_spec?
764
+
720
765
  converged = []
721
766
  @locked_specs.each do |s|
722
767
  # Replace the locked dependency's source with the equivalent source from the Gemfile
@@ -724,42 +769,60 @@ module Bundler
724
769
  s.source = (dep && dep.source) || sources.get(s.source)
725
770
 
726
771
  # Don't add a spec to the list if its source is expired. For example,
727
- # if you change a Git gem to Rubygems.
728
- next if s.source.nil? || @unlock[:sources].include?(s.source.name)
772
+ # if you change a Git gem to RubyGems.
773
+ next if s.source.nil?
774
+ next if @unlock[:sources].include?(s.source.name)
729
775
 
730
776
  # XXX This is a backwards-compatibility fix to preserve the ability to
731
777
  # unlock a single gem by passing its name via `--source`. See issue #3759
732
- next if s.source.nil? || @unlock[:sources].include?(s.name)
778
+ # TODO: delete in Bundler 2
779
+ next if unlock_source_unlocks_spec && @unlock[:sources].include?(s.name)
733
780
 
734
781
  # If the spec is from a path source and it doesn't exist anymore
735
782
  # then we unlock it.
736
783
 
737
784
  # Path sources have special logic
738
785
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
739
- other = s.source.specs[s].first
786
+ other_sources_specs = begin
787
+ s.source.specs
788
+ rescue PathError, GitError
789
+ # if we won't need the source (according to the lockfile),
790
+ # don't error if the path/git source isn't available
791
+ next if @locked_specs.
792
+ for(requested_dependencies, [], false, true, false).
793
+ none? {|locked_spec| locked_spec.source == s.source }
794
+
795
+ raise
796
+ end
797
+
798
+ other = other_sources_specs[s].first
740
799
 
741
800
  # If the spec is no longer in the path source, unlock it. This
742
801
  # commonly happens if the version changed in the gemspec
743
802
  next unless other
744
803
 
745
804
  deps2 = other.dependencies.select {|d| d.type != :development }
805
+ runtime_dependencies = s.dependencies.select {|d| d.type != :development }
746
806
  # If the dependencies of the path source have changed, unlock it
747
- next unless s.dependencies.sort == deps2.sort
807
+ next unless runtime_dependencies.sort == deps2.sort
748
808
  end
749
809
 
750
810
  converged << s
751
811
  end
752
812
 
753
813
  resolve = SpecSet.new(converged)
754
- resolve = resolve.for(expand_dependencies(deps, true), @unlock[:gems])
755
- diff = @locked_specs.to_a - resolve.to_a
814
+ expanded_deps = expand_dependencies(deps, true)
815
+ @locked_specs_incomplete_for_platform = !resolve.for(expanded_deps, @unlock[:gems], true, true)
816
+ resolve = resolve.for(expanded_deps, @unlock[:gems], false, false, false)
817
+ diff = nil
756
818
 
757
819
  # Now, we unlock any sources that do not have anymore gems pinned to it
758
820
  sources.all_sources.each do |source|
759
821
  next unless source.respond_to?(:unlock!)
760
822
 
761
823
  unless resolve.any? {|s| s.source == source }
762
- source.unlock! if !diff.empty? && diff.any? {|s| s.source == source }
824
+ diff ||= @locked_specs.to_a - resolve.to_a
825
+ source.unlock! if diff.any? {|s| s.source == source }
763
826
  end
764
827
  end
765
828
 
@@ -774,24 +837,28 @@ module Bundler
774
837
  end
775
838
 
776
839
  def satisfies_locked_spec?(dep)
777
- @locked_specs.any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
840
+ @locked_specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
778
841
  end
779
842
 
780
843
  # This list of dependencies is only used in #resolve, so it's OK to add
781
844
  # the metadata dependencies here
782
845
  def expanded_dependencies
783
846
  @expanded_dependencies ||= begin
847
+ expand_dependencies(dependencies + metadata_dependencies, @remote)
848
+ end
849
+ end
850
+
851
+ def metadata_dependencies
852
+ @metadata_dependencies ||= begin
784
853
  ruby_versions = concat_ruby_version_requirements(@ruby_version)
785
854
  if ruby_versions.empty? || !@ruby_version.exact?
786
855
  concat_ruby_version_requirements(RubyVersion.system)
787
856
  concat_ruby_version_requirements(locked_ruby_version_object) unless @unlock[:ruby]
788
857
  end
789
-
790
- metadata_dependencies = [
858
+ [
791
859
  Dependency.new("ruby\0", ruby_versions),
792
860
  Dependency.new("rubygems\0", Gem::VERSION),
793
861
  ]
794
- expand_dependencies(dependencies + metadata_dependencies, @remote)
795
862
  end
796
863
  end
797
864
 
@@ -812,17 +879,20 @@ module Bundler
812
879
  end
813
880
 
814
881
  def expand_dependencies(dependencies, remote = false)
882
+ sorted_platforms = Resolver.sort_platforms(@platforms)
815
883
  deps = []
816
884
  dependencies.each do |dep|
817
885
  dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
818
886
  next if !remote && !dep.current_platform?
819
- platforms = dep.gem_platforms(@platforms)
887
+ platforms = dep.gem_platforms(sorted_platforms)
820
888
  if platforms.empty?
889
+ mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }
821
890
  Bundler.ui.warn \
822
891
  "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \
823
892
  "Bundler is installing for #{@platforms.join ", "} but the dependency " \
824
- "is only for #{dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }.join ", "}. " \
825
- "To add those platforms to the bundle, run `bundle lock --add-platform #{dep.platforms.join ", "}`."
893
+ "is only for #{mapped_platforms.join ", "}. " \
894
+ "To add those platforms to the bundle, " \
895
+ "run `bundle lock --add-platform #{mapped_platforms.join " "}`."
826
896
  end
827
897
  platforms.each do |p|
828
898
  deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
@@ -844,30 +914,33 @@ module Bundler
844
914
  # Record the specs available in each gem's source, so that those
845
915
  # specs will be available later when the resolver knows where to
846
916
  # look for that gemspec (or its dependencies)
847
- source_requirements = {}
917
+ default = sources.default_source
918
+ source_requirements = { :default => default }
919
+ default = nil unless Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
848
920
  dependencies.each do |dep|
849
- next unless dep.source
850
- source_requirements[dep.name] = dep.source.specs
921
+ next unless source = dep.source || default
922
+ source_requirements[dep.name] = source
923
+ end
924
+ metadata_dependencies.each do |dep|
925
+ source_requirements[dep.name] = sources.metadata_source
851
926
  end
927
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
852
928
  source_requirements
853
929
  end
854
930
 
855
- def pinned_spec_names(specs)
856
- names = []
857
- specs.each do |s|
858
- # TODO: when two sources without blocks is an error, we can change
859
- # this check to !s.source.is_a?(Source::LocalRubygems). For now,
860
- # we need to ask every Rubygems for every gem name.
861
- if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path)
862
- names << s.name
863
- end
931
+ def pinned_spec_names(skip = nil)
932
+ pinned_names = []
933
+ default = Bundler.feature_flag.lockfile_uses_separate_rubygems_sources? && sources.default_source
934
+ @dependencies.each do |dep|
935
+ next unless dep_source = dep.source || default
936
+ next if dep_source == skip
937
+ pinned_names << dep.name
864
938
  end
865
- names.uniq!
866
- names
939
+ pinned_names
867
940
  end
868
941
 
869
942
  def requested_groups
870
- groups - Bundler.settings.without - @optional_groups + Bundler.settings.with
943
+ groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
871
944
  end
872
945
 
873
946
  def lockfiles_equal?(current, proposed, preserve_unknown_sections)
@@ -902,11 +975,20 @@ module Bundler
902
975
 
903
976
  def additional_base_requirements_for_resolve
904
977
  return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
978
+ dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
905
979
  @locked_gems.specs.reduce({}) do |requirements, locked_spec|
906
- dep = Gem::Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
907
- requirements[locked_spec.name] = DepProxy.new(dep, locked_spec.platform)
980
+ name = locked_spec.name
981
+ next requirements if @locked_gems.dependencies[name] != dependencies_by_name[name]
982
+ dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
983
+ requirements[name] = DepProxy.new(dep, locked_spec.platform)
908
984
  requirements
909
985
  end.values
910
986
  end
987
+
988
+ def equivalent_rubygems_remotes?(source)
989
+ return false unless source.is_a?(Source::Rubygems)
990
+
991
+ Bundler.settings[:allow_deployment_source_credential_changes] && source.equivalent_remotes?(sources.rubygems_remotes)
992
+ end
911
993
  end
912
994
  end