bundler 1.15.2 → 2.4.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (424) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +2861 -1117
  3. data/LICENSE.md +18 -19
  4. data/README.md +22 -17
  5. data/bundler.gemspec +23 -27
  6. data/exe/bundle +27 -12
  7. data/exe/bundler +1 -1
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +45 -0
  10. data/lib/bundler/capistrano.rb +7 -2
  11. data/lib/bundler/cli/add.rb +33 -12
  12. data/lib/bundler/cli/binstubs.rb +25 -9
  13. data/lib/bundler/cli/cache.rb +25 -17
  14. data/lib/bundler/cli/check.rb +8 -8
  15. data/lib/bundler/cli/clean.rb +6 -7
  16. data/lib/bundler/cli/common.rb +52 -15
  17. data/lib/bundler/cli/config.rb +171 -86
  18. data/lib/bundler/cli/console.rb +5 -4
  19. data/lib/bundler/cli/doctor.rb +72 -8
  20. data/lib/bundler/cli/exec.rb +13 -29
  21. data/lib/bundler/cli/fund.rb +36 -0
  22. data/lib/bundler/cli/gem.rb +266 -48
  23. data/lib/bundler/cli/info.rb +52 -9
  24. data/lib/bundler/cli/init.rb +22 -6
  25. data/lib/bundler/cli/inject.rb +2 -1
  26. data/lib/bundler/cli/install.rb +74 -99
  27. data/lib/bundler/cli/issue.rb +9 -8
  28. data/lib/bundler/cli/list.rb +66 -0
  29. data/lib/bundler/cli/lock.rb +11 -5
  30. data/lib/bundler/cli/open.rb +14 -9
  31. data/lib/bundler/cli/outdated.rb +165 -123
  32. data/lib/bundler/cli/platform.rb +3 -2
  33. data/lib/bundler/cli/plugin.rb +20 -2
  34. data/lib/bundler/cli/pristine.rb +25 -6
  35. data/lib/bundler/cli/remove.rb +17 -0
  36. data/lib/bundler/cli/show.rb +3 -4
  37. data/lib/bundler/cli/update.rb +71 -12
  38. data/lib/bundler/cli/viz.rb +2 -1
  39. data/lib/bundler/cli.rb +394 -152
  40. data/lib/bundler/compact_index_client/cache.rb +8 -26
  41. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  42. data/lib/bundler/compact_index_client/updater.rb +62 -51
  43. data/lib/bundler/compact_index_client.rb +29 -18
  44. data/lib/bundler/constants.rb +2 -1
  45. data/lib/bundler/current_ruby.rb +36 -13
  46. data/lib/bundler/definition.rb +417 -434
  47. data/lib/bundler/dependency.rb +34 -76
  48. data/lib/bundler/deployment.rb +2 -2
  49. data/lib/bundler/deprecate.rb +15 -3
  50. data/lib/bundler/digest.rb +71 -0
  51. data/lib/bundler/dsl.rb +135 -116
  52. data/lib/bundler/endpoint_specification.rb +26 -15
  53. data/lib/bundler/env.rb +95 -39
  54. data/lib/bundler/environment_preserver.rb +56 -8
  55. data/lib/bundler/errors.rb +32 -14
  56. data/lib/bundler/feature_flag.rb +29 -7
  57. data/lib/bundler/fetcher/base.rb +8 -9
  58. data/lib/bundler/fetcher/compact_index.rb +47 -49
  59. data/lib/bundler/fetcher/dependency.rb +5 -8
  60. data/lib/bundler/fetcher/downloader.rb +26 -17
  61. data/lib/bundler/fetcher/index.rb +5 -30
  62. data/lib/bundler/fetcher.rb +51 -46
  63. data/lib/bundler/force_platform.rb +18 -0
  64. data/lib/bundler/friendly_errors.rb +53 -53
  65. data/lib/bundler/gem_helper.rb +95 -50
  66. data/lib/bundler/gem_helpers.rb +45 -28
  67. data/lib/bundler/gem_tasks.rb +2 -1
  68. data/lib/bundler/gem_version_promoter.rb +60 -90
  69. data/lib/bundler/graph.rb +6 -5
  70. data/lib/bundler/index.rb +23 -61
  71. data/lib/bundler/injector.rb +228 -32
  72. data/lib/bundler/inline.rb +29 -32
  73. data/lib/bundler/installer/gem_installer.rb +24 -16
  74. data/lib/bundler/installer/parallel_installer.rb +94 -71
  75. data/lib/bundler/installer/standalone.rb +63 -12
  76. data/lib/bundler/installer.rb +128 -94
  77. data/lib/bundler/lazy_specification.rb +89 -52
  78. data/lib/bundler/lockfile_generator.rb +95 -0
  79. data/lib/bundler/lockfile_parser.rb +40 -66
  80. data/lib/bundler/man/bundle-add.1 +82 -0
  81. data/lib/bundler/man/bundle-add.1.ronn +58 -0
  82. data/lib/bundler/man/bundle-binstubs.1 +42 -0
  83. data/lib/bundler/man/bundle-binstubs.1.ronn +41 -0
  84. data/lib/bundler/man/bundle-cache.1 +61 -0
  85. data/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +26 -14
  86. data/{man → lib/bundler/man}/bundle-check.1 +4 -4
  87. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +3 -3
  88. data/{man → lib/bundler/man}/bundle-clean.1 +2 -2
  89. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  90. data/{man → lib/bundler/man}/bundle-config.1 +175 -57
  91. data/lib/bundler/man/bundle-config.1.ronn +408 -0
  92. data/lib/bundler/man/bundle-console.1 +53 -0
  93. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  94. data/lib/bundler/man/bundle-doctor.1 +44 -0
  95. data/lib/bundler/man/bundle-doctor.1.ronn +33 -0
  96. data/{man → lib/bundler/man}/bundle-exec.1 +11 -8
  97. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +16 -9
  98. data/lib/bundler/man/bundle-gem.1 +105 -0
  99. data/lib/bundler/man/bundle-gem.1.ronn +117 -0
  100. data/lib/bundler/man/bundle-help.1 +13 -0
  101. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  102. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  103. data/lib/bundler/man/bundle-init.1 +29 -0
  104. data/lib/bundler/man/bundle-init.1.ronn +31 -0
  105. data/{man → lib/bundler/man}/bundle-inject.1 +7 -4
  106. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +5 -3
  107. data/{man → lib/bundler/man}/bundle-install.1 +63 -55
  108. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +81 -68
  109. data/lib/bundler/man/bundle-list.1 +50 -0
  110. data/lib/bundler/man/bundle-list.1.ronn +33 -0
  111. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  112. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +1 -1
  113. data/{man → lib/bundler/man}/bundle-open.1 +22 -2
  114. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +9 -1
  115. data/{man → lib/bundler/man}/bundle-outdated.1 +8 -11
  116. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +7 -12
  117. data/{man → lib/bundler/man}/bundle-platform.1 +16 -6
  118. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  119. data/lib/bundler/man/bundle-plugin.1 +81 -0
  120. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  121. data/lib/bundler/man/bundle-pristine.1 +34 -0
  122. data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
  123. data/lib/bundler/man/bundle-remove.1 +31 -0
  124. data/lib/bundler/man/bundle-remove.1.ronn +23 -0
  125. data/{man → lib/bundler/man}/bundle-show.1 +3 -3
  126. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +3 -2
  127. data/{man → lib/bundler/man}/bundle-update.1 +17 -13
  128. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +27 -22
  129. data/lib/bundler/man/bundle-version.1 +35 -0
  130. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  131. data/{man → lib/bundler/man}/bundle-viz.1 +10 -7
  132. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +8 -6
  133. data/{man → lib/bundler/man}/bundle.1 +44 -31
  134. data/lib/bundler/man/bundle.1.ronn +116 -0
  135. data/{man → lib/bundler/man}/gemfile.5 +153 -83
  136. data/{man → lib/bundler/man}/gemfile.5.ronn +156 -93
  137. data/lib/bundler/man/index.txt +29 -0
  138. data/lib/bundler/match_metadata.rb +13 -0
  139. data/lib/bundler/match_platform.rb +2 -2
  140. data/lib/bundler/match_remote_metadata.rb +29 -0
  141. data/lib/bundler/mirror.rb +16 -15
  142. data/lib/bundler/plugin/api/source.rb +35 -14
  143. data/lib/bundler/plugin/api.rb +1 -1
  144. data/lib/bundler/plugin/dsl.rb +1 -1
  145. data/lib/bundler/plugin/events.rb +61 -0
  146. data/lib/bundler/plugin/index.rb +38 -10
  147. data/lib/bundler/plugin/installer/git.rb +0 -4
  148. data/lib/bundler/plugin/installer/rubygems.rb +1 -9
  149. data/lib/bundler/plugin/installer.rb +35 -18
  150. data/lib/bundler/plugin/source_list.rb +11 -8
  151. data/lib/bundler/plugin.rb +115 -47
  152. data/lib/bundler/process_lock.rb +24 -0
  153. data/lib/bundler/remote_specification.rb +12 -8
  154. data/lib/bundler/resolver/base.rb +107 -0
  155. data/lib/bundler/resolver/candidate.rb +94 -0
  156. data/lib/bundler/resolver/incompatibility.rb +15 -0
  157. data/lib/bundler/resolver/package.rb +72 -0
  158. data/lib/bundler/resolver/root.rb +25 -0
  159. data/lib/bundler/resolver/spec_group.rb +82 -0
  160. data/lib/bundler/resolver.rb +327 -324
  161. data/lib/bundler/retry.rb +5 -4
  162. data/lib/bundler/ruby_dsl.rb +2 -1
  163. data/lib/bundler/ruby_version.rb +11 -38
  164. data/lib/bundler/rubygems_ext.rb +236 -90
  165. data/lib/bundler/rubygems_gem_installer.rb +104 -8
  166. data/lib/bundler/rubygems_integration.rb +204 -501
  167. data/lib/bundler/runtime.rb +35 -48
  168. data/lib/bundler/self_manager.rb +168 -0
  169. data/lib/bundler/settings/validator.rb +102 -0
  170. data/lib/bundler/settings.rb +309 -142
  171. data/lib/bundler/setup.rb +15 -12
  172. data/lib/bundler/shared_helpers.rb +147 -83
  173. data/lib/bundler/similarity_detector.rb +4 -3
  174. data/lib/bundler/source/gemspec.rb +1 -0
  175. data/lib/bundler/source/git/git_proxy.rb +281 -125
  176. data/lib/bundler/source/git.rb +102 -73
  177. data/lib/bundler/source/metadata.rb +62 -0
  178. data/lib/bundler/source/path/installer.rb +13 -32
  179. data/lib/bundler/source/path.rb +36 -25
  180. data/lib/bundler/source/rubygems/remote.rb +9 -4
  181. data/lib/bundler/source/rubygems.rb +273 -226
  182. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  183. data/lib/bundler/source.rb +65 -9
  184. data/lib/bundler/source_list.rb +138 -33
  185. data/lib/bundler/source_map.rb +71 -0
  186. data/lib/bundler/spec_set.rb +101 -72
  187. data/lib/bundler/stub_specification.rb +45 -36
  188. data/lib/bundler/templates/.document +1 -0
  189. data/lib/bundler/templates/Executable +13 -3
  190. data/lib/bundler/templates/Executable.bundler +109 -0
  191. data/lib/bundler/templates/Executable.standalone +4 -4
  192. data/lib/bundler/templates/Gemfile +1 -2
  193. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  194. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  195. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  196. data/lib/bundler/templates/newgem/Gemfile.tt +22 -2
  197. data/lib/bundler/templates/newgem/README.md.tt +14 -16
  198. data/lib/bundler/templates/newgem/Rakefile.tt +43 -5
  199. data/lib/bundler/templates/newgem/bin/console.tt +1 -4
  200. data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  201. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  202. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  203. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  204. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  205. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  206. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  207. data/lib/bundler/templates/newgem/gitignore.tt +3 -1
  208. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  209. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  210. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +5 -2
  211. data/lib/bundler/templates/newgem/newgem.gemspec.tt +39 -35
  212. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  213. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  214. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  215. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -1
  216. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  217. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  218. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  219. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  220. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  221. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  222. data/lib/bundler/ui/rg_proxy.rb +2 -1
  223. data/lib/bundler/ui/shell.rb +49 -17
  224. data/lib/bundler/ui/silent.rb +22 -5
  225. data/lib/bundler/ui.rb +4 -3
  226. data/lib/bundler/uri_credentials_filter.rb +11 -4
  227. data/lib/bundler/uri_normalizer.rb +23 -0
  228. data/lib/bundler/vendor/.document +1 -0
  229. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  230. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  231. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  232. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  233. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +128 -0
  234. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  235. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +2706 -0
  236. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  237. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  238. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  239. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  240. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +302 -462
  241. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  242. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  243. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  244. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  245. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  246. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  247. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  248. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  249. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  250. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  251. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  252. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  253. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  254. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  255. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +243 -0
  256. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  257. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  258. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  259. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
  260. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +4 -2
  261. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  262. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +9 -1
  263. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +64 -16
  264. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +27 -11
  265. data/lib/bundler/vendor/thor/lib/thor/actions.rb +38 -16
  266. data/lib/bundler/vendor/thor/lib/thor/base.rb +84 -41
  267. data/lib/bundler/vendor/thor/lib/thor/command.rb +30 -21
  268. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +18 -0
  269. data/lib/bundler/vendor/thor/lib/thor/error.rb +83 -0
  270. data/lib/bundler/vendor/thor/lib/thor/group.rb +4 -4
  271. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  272. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  273. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  274. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  275. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  276. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +7 -3
  277. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +22 -9
  278. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +45 -10
  279. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  280. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  281. data/lib/bundler/vendor/thor/lib/thor/runner.rb +17 -14
  282. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +97 -21
  283. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +10 -2
  284. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  285. data/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
  286. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  287. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  288. data/lib/bundler/vendor/thor/lib/thor.rb +39 -15
  289. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  290. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  291. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  292. data/lib/bundler/vendor/uri/lib/uri/common.rb +729 -0
  293. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  294. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  295. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1587 -0
  296. data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  297. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  298. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  299. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  300. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  301. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +539 -0
  302. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +119 -0
  303. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  304. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  305. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  306. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  307. data/lib/bundler/vendored_fileutils.rb +4 -0
  308. data/lib/bundler/vendored_persistent.rb +6 -8
  309. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +2 -1
  310. data/lib/bundler/vendored_thor.rb +3 -2
  311. data/lib/bundler/vendored_tsort.rb +4 -0
  312. data/lib/bundler/vendored_uri.rb +4 -0
  313. data/lib/bundler/version.rb +8 -19
  314. data/lib/bundler/vlad.rb +6 -1
  315. data/lib/bundler/worker.rb +26 -14
  316. data/lib/bundler/yaml_serializer.rb +6 -7
  317. data/lib/bundler.rb +336 -199
  318. metadata +174 -236
  319. data/.codeclimate.yml +0 -25
  320. data/.gitignore +0 -18
  321. data/.rspec +0 -3
  322. data/.rubocop.yml +0 -131
  323. data/.rubocop_todo.yml +0 -418
  324. data/.travis.yml +0 -122
  325. data/CODE_OF_CONDUCT.md +0 -42
  326. data/CONTRIBUTING.md +0 -17
  327. data/Rakefile +0 -338
  328. data/bin/rake +0 -19
  329. data/bin/rspec +0 -15
  330. data/bin/rubocop +0 -17
  331. data/bin/with_rubygems +0 -39
  332. data/doc/README.md +0 -30
  333. data/doc/TROUBLESHOOTING.md +0 -64
  334. data/doc/contributing/BUG_TRIAGE.md +0 -36
  335. data/doc/contributing/COMMUNITY.md +0 -13
  336. data/doc/contributing/GETTING_HELP.md +0 -11
  337. data/doc/contributing/HOW_YOU_CAN_HELP.md +0 -27
  338. data/doc/contributing/ISSUES.md +0 -51
  339. data/doc/contributing/README.md +0 -38
  340. data/doc/development/NEW_FEATURES.md +0 -10
  341. data/doc/development/PULL_REQUESTS.md +0 -40
  342. data/doc/development/README.md +0 -19
  343. data/doc/development/RELEASING.md +0 -9
  344. data/doc/development/SETUP.md +0 -27
  345. data/doc/documentation/README.md +0 -29
  346. data/doc/documentation/VISION.md +0 -26
  347. data/doc/documentation/WRITING.md +0 -54
  348. data/exe/bundle_ruby +0 -59
  349. data/lib/bundler/cli/package.rb +0 -46
  350. data/lib/bundler/dep_proxy.rb +0 -46
  351. data/lib/bundler/gem_remote_fetcher.rb +0 -42
  352. data/lib/bundler/gemdeps.rb +0 -28
  353. data/lib/bundler/psyched_yaml.rb +0 -27
  354. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -65
  355. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  356. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  357. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  358. data/lib/bundler/templates/newgem/.travis.yml.tt +0 -5
  359. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  360. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  361. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -50
  362. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -80
  363. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -35
  364. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -65
  365. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -61
  366. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -62
  367. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -60
  368. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -125
  369. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -45
  370. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -35
  371. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -125
  372. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -222
  373. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -75
  374. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -5
  375. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -100
  376. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -65
  377. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -494
  378. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -45
  379. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -54
  380. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -10
  381. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  382. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  383. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  384. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  385. data/lib/bundler/version_ranges.rb +0 -75
  386. data/man/bundle-add.1 +0 -43
  387. data/man/bundle-add.1.txt +0 -40
  388. data/man/bundle-add.ronn +0 -29
  389. data/man/bundle-binstubs.1 +0 -30
  390. data/man/bundle-binstubs.1.txt +0 -33
  391. data/man/bundle-binstubs.ronn +0 -29
  392. data/man/bundle-check.1.txt +0 -32
  393. data/man/bundle-clean.1.txt +0 -26
  394. data/man/bundle-config.1.txt +0 -418
  395. data/man/bundle-config.ronn +0 -318
  396. data/man/bundle-exec.1.txt +0 -171
  397. data/man/bundle-gem.1 +0 -80
  398. data/man/bundle-gem.1.txt +0 -90
  399. data/man/bundle-gem.ronn +0 -77
  400. data/man/bundle-info.1.txt +0 -21
  401. data/man/bundle-init.1 +0 -20
  402. data/man/bundle-init.1.txt +0 -24
  403. data/man/bundle-init.ronn +0 -18
  404. data/man/bundle-inject.1.txt +0 -32
  405. data/man/bundle-install.1.txt +0 -385
  406. data/man/bundle-lock.1.txt +0 -93
  407. data/man/bundle-open.1.txt +0 -29
  408. data/man/bundle-outdated.1.txt +0 -127
  409. data/man/bundle-package.1 +0 -52
  410. data/man/bundle-package.1.txt +0 -74
  411. data/man/bundle-platform.1.txt +0 -57
  412. data/man/bundle-pristine.1 +0 -16
  413. data/man/bundle-pristine.1.txt +0 -21
  414. data/man/bundle-pristine.ronn +0 -13
  415. data/man/bundle-show.1.txt +0 -25
  416. data/man/bundle-update.1.txt +0 -388
  417. data/man/bundle-viz.1.txt +0 -37
  418. data/man/bundle.1.txt +0 -110
  419. data/man/bundle.ronn +0 -105
  420. data/man/gemfile.5.txt +0 -600
  421. data/man/index.txt +0 -15
  422. data/task/release.rake +0 -116
  423. /data/lib/bundler/{ssl_certs → man}/.document +0 -0
  424. /data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
- require "bundler/worker"
3
- require "bundler/installer/gem_installer"
2
+
3
+ require_relative "../worker"
4
+ require_relative "gem_installer"
4
5
 
5
6
  module Bundler
6
7
  class ParallelInstaller
7
8
  class SpecInstallation
8
- attr_accessor :spec, :name, :post_install_message, :state, :error
9
+ attr_accessor :spec, :name, :full_name, :post_install_message, :state, :error
9
10
  def initialize(spec)
10
11
  @spec = spec
11
12
  @name = spec.name
13
+ @full_name = spec.full_name
12
14
  @state = :none
13
15
  @post_install_message = ""
14
16
  @error = nil
@@ -26,13 +28,8 @@ module Bundler
26
28
  state == :failed
27
29
  end
28
30
 
29
- def installation_attempted?
30
- installed? || failed?
31
- end
32
-
33
- # Only true when spec in neither installed nor already enqueued
34
31
  def ready_to_enqueue?
35
- !enqueued? && !installation_attempted?
32
+ state == :none
36
33
  end
37
34
 
38
35
  def has_post_install_message?
@@ -53,14 +50,7 @@ module Bundler
53
50
  # Represents only the non-development dependencies, the ones that are
54
51
  # itself and are in the total list.
55
52
  def dependencies
56
- @dependencies ||= begin
57
- all_dependencies.reject {|dep| ignorable_dependency? dep }
58
- end
59
- end
60
-
61
- def missing_lockfile_dependencies(all_spec_names)
62
- deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
63
- deps.reject {|dep| all_spec_names.include? dep.name }
53
+ @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }
64
54
  end
65
55
 
66
56
  # Represents all dependencies
@@ -69,7 +59,7 @@ module Bundler
69
59
  end
70
60
 
71
61
  def to_s
72
- "#<#{self.class} #{@spec.full_name} (#{state})>"
62
+ "#<#{self.class} #{full_name} (#{state})>"
73
63
  end
74
64
  end
75
65
 
@@ -77,11 +67,6 @@ module Bundler
77
67
  new(*args).call
78
68
  end
79
69
 
80
- # Returns max number of threads machine can handle with a min of 1
81
- def self.max_threads
82
- [Bundler.settings[:jobs].to_i - 1, 1].max
83
- end
84
-
85
70
  attr_reader :size
86
71
 
87
72
  def initialize(installer, all_specs, size, standalone, force)
@@ -91,80 +76,118 @@ module Bundler
91
76
  @force = force
92
77
  @specs = all_specs.map {|s| SpecInstallation.new(s) }
93
78
  @spec_set = all_specs
79
+ @rake = @specs.find {|s| s.name == "rake" }
94
80
  end
95
81
 
96
82
  def call
97
- # Since `autoload` has the potential for threading issues on 1.8.7
98
- # TODO: remove in bundler 2.0
99
- require "bundler/gem_remote_fetcher" if RUBY_VERSION < "1.9"
83
+ if @rake
84
+ do_install(@rake, 0)
85
+ Gem::Specification.reset
86
+ end
100
87
 
101
- check_for_corrupt_lockfile
102
- enqueue_specs
103
- process_specs until @specs.all?(&:installed?) || @specs.any?(&:failed?)
104
- handle_error if @specs.any?(&:failed?)
88
+ if @size > 1
89
+ install_with_worker
90
+ else
91
+ install_serially
92
+ end
93
+
94
+ check_for_unmet_dependencies
95
+
96
+ handle_error if failed_specs.any?
105
97
  @specs
106
98
  ensure
107
99
  worker_pool && worker_pool.stop
108
100
  end
109
101
 
110
- def worker_pool
111
- @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda { |spec_install, worker_num|
112
- gem_installer = Bundler::GemInstaller.new(
113
- spec_install.spec, @installer, @standalone, worker_num, @force
114
- )
115
- success, message = gem_installer.install_from_spec
116
- if success && !message.nil?
117
- spec_install.post_install_message = message
118
- elsif !success
119
- spec_install.state = :failed
120
- spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
102
+ def check_for_unmet_dependencies
103
+ unmet_dependencies = @specs.map do |s|
104
+ [
105
+ s,
106
+ s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
107
+ ]
108
+ end.reject {|a| a.last.empty? }
109
+ return if unmet_dependencies.empty?
110
+
111
+ warning = []
112
+ warning << "Your lockfile doesn't include a valid resolution."
113
+ warning << "You can fix this by regenerating your lockfile or manually editing the bad locked gems to a version that satisfies all dependencies."
114
+ warning << "The unmet dependencies are:"
115
+
116
+ unmet_dependencies.each do |spec, unmet_spec_dependencies|
117
+ unmet_spec_dependencies.each do |unmet_spec_dependency|
118
+ found = @specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }
119
+ warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}"
121
120
  end
122
- spec_install
121
+ end
122
+
123
+ Bundler.ui.warn(warning.join("\n"))
124
+ end
125
+
126
+ private
127
+
128
+ def failed_specs
129
+ @specs.select(&:failed?)
130
+ end
131
+
132
+ def install_with_worker
133
+ enqueue_specs
134
+ process_specs until finished_installing?
135
+ end
136
+
137
+ def install_serially
138
+ until finished_installing?
139
+ raise "failed to find a spec to enqueue while installing serially" unless spec_install = @specs.find(&:ready_to_enqueue?)
140
+ spec_install.state = :enqueued
141
+ do_install(spec_install, 0)
142
+ end
143
+ end
144
+
145
+ def worker_pool
146
+ @worker_pool ||= Bundler::Worker.new @size, "Parallel Installer", lambda {|spec_install, worker_num|
147
+ do_install(spec_install, worker_num)
123
148
  }
124
149
  end
125
150
 
151
+ def do_install(spec_install, worker_num)
152
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
153
+ gem_installer = Bundler::GemInstaller.new(
154
+ spec_install.spec, @installer, @standalone, worker_num, @force
155
+ )
156
+ success, message = gem_installer.install_from_spec
157
+ if success
158
+ spec_install.state = :installed
159
+ spec_install.post_install_message = message unless message.nil?
160
+ else
161
+ spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
162
+ spec_install.state = :failed
163
+ end
164
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
165
+ spec_install
166
+ end
167
+
126
168
  # Dequeue a spec and save its post-install message and then enqueue the
127
169
  # remaining specs.
128
170
  # Some specs might've had to wait til this spec was installed to be
129
171
  # processed so the call to `enqueue_specs` is important after every
130
172
  # dequeue.
131
173
  def process_specs
132
- spec = worker_pool.deq
133
- spec.state = :installed unless spec.failed?
174
+ worker_pool.deq
134
175
  enqueue_specs
135
176
  end
136
177
 
137
- def handle_error
138
- errors = @specs.select(&:failed?).map(&:error)
139
- if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
140
- raise exception
178
+ def finished_installing?
179
+ @specs.all? do |spec|
180
+ return true if spec.failed?
181
+ spec.installed?
141
182
  end
142
- raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
143
183
  end
144
184
 
145
- def check_for_corrupt_lockfile
146
- missing_dependencies = @specs.map do |s|
147
- [
148
- s,
149
- s.missing_lockfile_dependencies(@specs.map(&:name)),
150
- ]
151
- end.reject { |a| a.last.empty? }
152
- return if missing_dependencies.empty?
153
-
154
- warning = []
155
- warning << "Your lockfile was created by an old Bundler that left some things out."
156
- if @size != 1
157
- warning << "Because of the missing DEPENDENCIES, we can only install gems one at a time, instead of installing #{@size} at a time."
158
- @size = 1
159
- end
160
- warning << "You can fix this by adding the missing gems to your Gemfile, running bundle install, and then removing the gems from your Gemfile."
161
- warning << "The missing gems are:"
162
-
163
- missing_dependencies.each do |spec, missing|
164
- warning << "* #{missing.map(&:name).join(", ")} depended upon by #{spec.name}"
185
+ def handle_error
186
+ errors = failed_specs.map(&:error)
187
+ if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
188
+ raise exception
165
189
  end
166
-
167
- Bundler.ui.warn(warning.join("\n"))
190
+ raise Bundler::InstallError, errors.join("\n\n")
168
191
  end
169
192
 
170
193
  def require_tree_for_spec(spec)
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Bundler
3
4
  class Standalone
4
5
  def initialize(groups, definition)
5
- @specs = groups.empty? ? definition.requested_specs : definition.specs_for(groups.map(&:to_sym))
6
+ @specs = definition.specs_for(groups)
6
7
  end
7
8
 
8
9
  def generate
@@ -11,42 +12,92 @@ module Bundler
11
12
  end
12
13
  File.open File.join(bundler_path, "setup.rb"), "w" do |file|
13
14
  file.puts "require 'rbconfig'"
14
- file.puts "# ruby 1.8.7 doesn't define RUBY_ENGINE"
15
- file.puts "ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'"
16
- file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
17
- file.puts "path = File.expand_path('..', __FILE__)"
15
+ file.puts define_path_helpers
16
+ file.puts reverse_rubygems_kernel_mixin
18
17
  paths.each do |path|
19
- file.puts %($:.unshift "\#{path}/#{path}")
18
+ if Pathname.new(path).absolute?
19
+ file.puts %($:.unshift "#{path}")
20
+ else
21
+ file.puts %($:.unshift File.expand_path("\#{__dir__}/#{path}"))
22
+ end
20
23
  end
21
24
  end
22
25
  end
23
26
 
24
- private
27
+ private
25
28
 
26
29
  def paths
27
30
  @specs.map do |spec|
28
31
  next if spec.name == "bundler"
29
32
  Array(spec.require_paths).map do |path|
30
- gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
33
+ gem_path(path, spec).
34
+ sub(version_dir, '#{RUBY_ENGINE}/#{Gem.ruby_api_version}').
35
+ sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
31
36
  # This is a static string intentionally. It's interpolated at a later time.
32
37
  end
33
- end.flatten
38
+ end.flatten.compact
34
39
  end
35
40
 
36
41
  def version_dir
37
- "#{Bundler::RubyVersion.system.engine}/#{RbConfig::CONFIG["ruby_version"]}"
42
+ "#{RUBY_ENGINE}/#{Gem.ruby_api_version}"
43
+ end
44
+
45
+ def extensions_dir
46
+ %r{extensions/(?<platform>[^/]+)/#{Regexp.escape(Gem.extension_api_version)}}
38
47
  end
39
48
 
40
49
  def bundler_path
41
- Bundler.root.join(Bundler.settings[:path], "bundler")
50
+ Bundler.root.join(Bundler.settings[:path].to_s, "bundler")
42
51
  end
43
52
 
44
53
  def gem_path(path, spec)
45
54
  full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
46
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
55
+ if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
56
+ full_path
57
+ else
58
+ Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
59
+ end
47
60
  rescue TypeError
48
61
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
49
62
  raise Gem::InvalidSpecificationException.new(error_message)
50
63
  end
64
+
65
+ def define_path_helpers
66
+ <<~'END'
67
+ unless defined?(Gem)
68
+ module Gem
69
+ def self.ruby_api_version
70
+ RbConfig::CONFIG["ruby_version"]
71
+ end
72
+
73
+ def self.extension_api_version
74
+ if 'no' == RbConfig::CONFIG['ENABLE_SHARED']
75
+ "#{ruby_api_version}-static"
76
+ else
77
+ ruby_api_version
78
+ end
79
+ end
80
+ end
81
+ end
82
+ END
83
+ end
84
+
85
+ def reverse_rubygems_kernel_mixin
86
+ <<~END
87
+ if Gem.respond_to?(:discover_gems_on_require=)
88
+ Gem.discover_gems_on_require = false
89
+ else
90
+ kernel = (class << ::Kernel; self; end)
91
+ [kernel, ::Kernel].each do |k|
92
+ if k.private_method_defined?(:gem_original_require)
93
+ private_require = k.private_method_defined?(:require)
94
+ k.send(:remove_method, :require)
95
+ k.send(:define_method, :require, k.instance_method(:gem_original_require))
96
+ k.send(:private, :require) if private_require
97
+ end
98
+ end
99
+ end
100
+ END
101
+ end
51
102
  end
52
103
  end
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
- require "erb"
3
- require "rubygems/dependency_installer"
4
- require "bundler/worker"
5
- require "bundler/installer/parallel_installer"
6
- require "bundler/installer/standalone"
7
- require "bundler/installer/gem_installer"
2
+
3
+ require_relative "worker"
4
+ require_relative "installer/parallel_installer"
5
+ require_relative "installer/standalone"
6
+ require_relative "installer/gem_installer"
8
7
 
9
8
  module Bundler
10
9
  class Installer
@@ -14,14 +13,15 @@ module Bundler
14
13
  Installer.ambiguous_gems = []
15
14
  end
16
15
 
17
- attr_reader :post_install_messages
16
+ attr_reader :post_install_messages, :definition
18
17
 
19
18
  # Begins the installation process for Bundler.
20
19
  # For more information see the #run method on this class.
21
20
  def self.install(root, definition, options = {})
22
21
  installer = new(root, definition)
23
- Plugin.hook("before-install-all", definition.dependencies)
22
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
24
23
  installer.run(options)
24
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
25
25
  installer
26
26
  end
27
27
 
@@ -33,25 +33,26 @@ module Bundler
33
33
 
34
34
  # Runs the install procedures for a specific Gemfile.
35
35
  #
36
- # Firstly, this method will check to see if Bundler.bundle_path exists
37
- # and if not then will create it. This is usually the location of gems
38
- # on the system, be it RVM or at a system path.
36
+ # Firstly, this method will check to see if `Bundler.bundle_path` exists
37
+ # and if not then Bundler will create the directory. This is usually the same
38
+ # location as RubyGems which typically is the `~/.gem` directory
39
+ # unless other specified.
39
40
  #
40
- # Secondly, it checks if Bundler has been configured to be "frozen"
41
+ # Secondly, it checks if Bundler has been configured to be "frozen".
41
42
  # Frozen ensures that the Gemfile and the Gemfile.lock file are matching.
42
43
  # This stops a situation where a developer may update the Gemfile but may not run
43
44
  # `bundle install`, which leads to the Gemfile.lock file not being correctly updated.
44
45
  # If this file is not correctly updated then any other developer running
45
46
  # `bundle install` will potentially not install the correct gems.
46
47
  #
47
- # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile using
48
- # Bundler::Environment#dependencies. If there are no dependencies specified then
49
- # Bundler returns a warning message stating so and this method returns.
48
+ # Thirdly, Bundler checks if there are any dependencies specified in the Gemfile.
49
+ # If there are no dependencies specified then Bundler returns a warning message stating
50
+ # so and this method returns.
50
51
  #
51
- # Fourthly, Bundler checks if the default lockfile (Gemfile.lock) exists, and if so
52
- # then proceeds to set up a definition based on the default gemfile (Gemfile) and the
53
- # default lock file (Gemfile.lock). However, this is not the case if the platform is different
54
- # to that which is specified in Gemfile.lock, or if there are any missing specs for the gems.
52
+ # Fourthly, Bundler checks if the Gemfile.lock exists, and if so
53
+ # then proceeds to set up a definition based on the Gemfile and the Gemfile.lock.
54
+ # During this step Bundler will also download information about any new gems
55
+ # that are not in the Gemfile.lock and resolve any dependencies if needed.
55
56
  #
56
57
  # Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote.
57
58
  # This then leads into the gems being installed, along with stubs for their executables,
@@ -61,26 +62,37 @@ module Bundler
61
62
  # Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time
62
63
  # that a user runs `bundle install` they will receive any updates from this process.
63
64
  #
64
- # Finally: TODO add documentation for how the standalone process works.
65
+ # Finally, if the user has specified the standalone flag, Bundler will generate the needed
66
+ # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
67
+ # information.
65
68
  def run(options)
66
- create_bundle_path
69
+ Bundler.create_bundle_path
67
70
 
68
- if Bundler.settings[:frozen]
69
- @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
70
- end
71
+ ProcessLock.lock do
72
+ if Bundler.frozen_bundle?
73
+ @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
74
+ end
71
75
 
72
- if @definition.dependencies.empty?
73
- Bundler.ui.warn "The Gemfile specifies no dependencies"
74
- lock
75
- return
76
- end
76
+ if @definition.dependencies.empty?
77
+ Bundler.ui.warn "The Gemfile specifies no dependencies"
78
+ lock
79
+ return
80
+ end
81
+
82
+ if resolve_if_needed(options)
83
+ ensure_specs_are_compatible!
84
+ load_plugins
85
+ options.delete(:jobs)
86
+ else
87
+ options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
88
+ end
89
+ install(options)
77
90
 
78
- resolve_if_need(options)
79
- ensure_specs_are_compatible!
80
- install(options)
91
+ Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
81
92
 
82
- lock unless Bundler.settings[:frozen]
83
- Standalone.new(options[:standalone], @definition).generate if options[:standalone]
93
+ lock unless Bundler.frozen_bundle?
94
+ Standalone.new(options[:standalone], @definition).generate if options[:standalone]
95
+ end
84
96
  end
85
97
 
86
98
  def generate_bundler_executable_stubs(spec, options = {})
@@ -101,23 +113,35 @@ module Bundler
101
113
  end
102
114
 
103
115
  # double-assignment to avoid warnings about variables that will be used by ERB
104
- bin_path = bin_path = Bundler.bin_path
105
- template = template = File.read(File.expand_path("../templates/Executable", __FILE__))
106
- relative_gemfile_path = relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
107
- ruby_command = ruby_command = Thor::Util.ruby_command
116
+ bin_path = Bundler.bin_path
117
+ bin_path = bin_path
118
+ relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
119
+ relative_gemfile_path = relative_gemfile_path
120
+ ruby_command = Thor::Util.ruby_command
121
+ ruby_command = ruby_command
122
+ template_path = File.expand_path("templates/Executable", __dir__)
123
+ if spec.name == "bundler"
124
+ template_path += ".bundler"
125
+ spec.executables = %(bundle)
126
+ end
127
+ template = File.read(template_path)
108
128
 
109
129
  exists = []
110
130
  spec.executables.each do |executable|
111
- next if executable == "bundle"
112
-
113
131
  binstub_path = "#{bin_path}/#{executable}"
114
132
  if File.exist?(binstub_path) && !options[:force]
115
133
  exists << executable
116
134
  next
117
135
  end
118
136
 
119
- File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
120
- f.puts ERB.new(template, nil, "-").result(binding)
137
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
138
+ require "erb"
139
+ content = ERB.new(template, :trim_mode => "-").result(binding)
140
+
141
+ File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
142
+ if Gem.win_platform? || options[:all_platforms]
143
+ prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
144
+ File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
121
145
  end
122
146
  end
123
147
 
@@ -136,65 +160,86 @@ module Bundler
136
160
  end
137
161
  end
138
162
 
139
- def generate_standalone_bundler_executable_stubs(spec)
163
+ def generate_standalone_bundler_executable_stubs(spec, options = {})
140
164
  # double-assignment to avoid warnings about variables that will be used by ERB
141
165
  bin_path = Bundler.bin_path
142
- standalone_path = standalone_path = Bundler.root.join(Bundler.settings[:path]).relative_path_from(bin_path)
143
- template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
144
- ruby_command = ruby_command = Thor::Util.ruby_command
166
+ unless path = Bundler.settings[:path]
167
+ raise "Can't standalone without an explicit path set"
168
+ end
169
+ standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
170
+ standalone_path = standalone_path
171
+ template = File.read(File.expand_path("templates/Executable.standalone", __dir__))
172
+ ruby_command = Thor::Util.ruby_command
173
+ ruby_command = ruby_command
145
174
 
146
175
  spec.executables.each do |executable|
147
176
  next if executable == "bundle"
148
- executable_path = executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
149
- File.open "#{bin_path}/#{executable}", "w", 0o755 do |f|
150
- f.puts ERB.new(template, nil, "-").result(binding)
177
+ executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
178
+ executable_path = executable_path
179
+
180
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
181
+ require "erb"
182
+ content = ERB.new(template, :trim_mode => "-").result(binding)
183
+
184
+ File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
185
+ if Gem.win_platform? || options[:all_platforms]
186
+ prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
187
+ File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
151
188
  end
152
189
  end
153
190
  end
154
191
 
155
- private
192
+ private
156
193
 
157
194
  # the order that the resolver provides is significant, since
158
195
  # dependencies might affect the installation of a gem.
159
196
  # that said, it's a rare situation (other than rake), and parallel
160
197
  # installation is SO MUCH FASTER. so we let people opt in.
161
198
  def install(options)
162
- Bundler.rubygems.load_plugins
163
199
  force = options["force"]
164
- jobs = 1
165
- jobs = [Bundler.settings[:jobs].to_i - 1, 1].max if can_install_in_parallel?
200
+ jobs = installation_parallelization(options)
166
201
  install_in_parallel jobs, options[:standalone], force
167
202
  end
168
203
 
204
+ def installation_parallelization(options)
205
+ if jobs = options.delete(:jobs)
206
+ return jobs
207
+ end
208
+
209
+ if jobs = Bundler.settings[:jobs]
210
+ return jobs
211
+ end
212
+
213
+ Bundler.settings.processor_count
214
+ end
215
+
216
+ def load_plugins
217
+ Bundler.rubygems.load_plugins
218
+
219
+ requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
220
+ path_plugin_files = requested_path_gems.map do |spec|
221
+ Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
222
+ rescue TypeError
223
+ error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
224
+ raise Gem::InvalidSpecificationException, error_message
225
+ end.flatten
226
+ Bundler.rubygems.load_plugin_files(path_plugin_files)
227
+ Bundler.rubygems.load_env_plugins
228
+ end
229
+
169
230
  def ensure_specs_are_compatible!
170
- system_ruby = Bundler::RubyVersion.system
171
- rubygems_version = Gem::Version.create(Gem::VERSION)
172
231
  @definition.specs.each do |spec|
173
- if required_ruby_version = spec.required_ruby_version
174
- unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
175
- raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
176
- "which is incompatible with the current version, #{system_ruby}"
177
- end
232
+ unless spec.matches_current_ruby?
233
+ raise InstallError, "#{spec.full_name} requires ruby version #{spec.required_ruby_version}, " \
234
+ "which is incompatible with the current version, #{Gem.ruby_version}"
178
235
  end
179
- next unless required_rubygems_version = spec.required_rubygems_version
180
- unless required_rubygems_version.satisfied_by?(rubygems_version)
181
- raise InstallError, "#{spec.full_name} requires rubygems version #{required_rubygems_version}, " \
182
- "which is incompatible with the current version, #{rubygems_version}"
236
+ unless spec.matches_current_rubygems?
237
+ raise InstallError, "#{spec.full_name} requires rubygems version #{spec.required_rubygems_version}, " \
238
+ "which is incompatible with the current version, #{Gem.rubygems_version}"
183
239
  end
184
240
  end
185
241
  end
186
242
 
187
- def can_install_in_parallel?
188
- if Bundler.rubygems.provides?(">= 2.1.0")
189
- true
190
- else
191
- Bundler.ui.warn "Rubygems #{Gem::VERSION} is not threadsafe, so your "\
192
- "gems will be installed one at a time. Upgrade to Rubygems 2.1.0 " \
193
- "or higher to enable parallel gem installation."
194
- false
195
- end
196
- end
197
-
198
243
  def install_in_parallel(size, standalone, force = false)
199
244
  spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
200
245
  spec_installations.each do |installation|
@@ -202,28 +247,17 @@ module Bundler
202
247
  end
203
248
  end
204
249
 
205
- def create_bundle_path
206
- SharedHelpers.filesystem_access(Bundler.bundle_path.to_s) do |p|
207
- Bundler.mkdir_p(p)
208
- end unless Bundler.bundle_path.exist?
209
- rescue Errno::EEXIST
210
- raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " \
211
- "because a file already exists at that path. Either remove or rename the file so the directory can be created."
212
- end
250
+ # returns whether or not a re-resolve was needed
251
+ def resolve_if_needed(options)
252
+ @definition.resolution_mode = options
213
253
 
214
- def resolve_if_need(options)
215
- if !options["update"] && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
216
- local = Bundler.ui.silence do
217
- begin
218
- tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
219
- true unless tmpdef.new_platform? || tmpdef.missing_dependencies.any?
220
- rescue BundlerError
221
- end
222
- end
254
+ if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
255
+ return false if @definition.nothing_changed? && !@definition.missing_specs?
223
256
  end
224
257
 
225
- return if local
226
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
258
+ @definition.setup_sources_for_resolve
259
+
260
+ true
227
261
  end
228
262
 
229
263
  def lock(opts = {})