bundler 1.17.3 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (426) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3354 -1258
  3. data/LICENSE.md +18 -19
  4. data/README.md +10 -15
  5. data/bundler.gemspec +15 -33
  6. data/exe/bundle +8 -10
  7. data/exe/bundler +1 -1
  8. data/lib/bundler/.document +1 -0
  9. data/lib/bundler/build_metadata.rb +5 -13
  10. data/lib/bundler/capistrano.rb +5 -5
  11. data/lib/bundler/checksum.rb +254 -0
  12. data/lib/bundler/ci_detector.rb +75 -0
  13. data/lib/bundler/cli/add.rb +29 -15
  14. data/lib/bundler/cli/binstubs.rb +13 -5
  15. data/lib/bundler/cli/cache.rb +24 -17
  16. data/lib/bundler/cli/check.rb +7 -5
  17. data/lib/bundler/cli/clean.rb +1 -1
  18. data/lib/bundler/cli/common.rb +50 -14
  19. data/lib/bundler/cli/config.rb +171 -86
  20. data/lib/bundler/cli/console.rb +3 -6
  21. data/lib/bundler/cli/doctor.rb +29 -12
  22. data/lib/bundler/cli/exec.rb +9 -25
  23. data/lib/bundler/cli/fund.rb +36 -0
  24. data/lib/bundler/cli/gem.rb +268 -53
  25. data/lib/bundler/cli/info.rb +51 -18
  26. data/lib/bundler/cli/init.rb +7 -3
  27. data/lib/bundler/cli/inject.rb +2 -2
  28. data/lib/bundler/cli/install.rb +55 -73
  29. data/lib/bundler/cli/issue.rb +9 -8
  30. data/lib/bundler/cli/list.rb +19 -11
  31. data/lib/bundler/cli/lock.rb +56 -26
  32. data/lib/bundler/cli/open.rb +10 -7
  33. data/lib/bundler/cli/outdated.rb +159 -128
  34. data/lib/bundler/cli/platform.rb +8 -6
  35. data/lib/bundler/cli/plugin.rb +23 -12
  36. data/lib/bundler/cli/pristine.rb +39 -26
  37. data/lib/bundler/cli/remove.rb +1 -2
  38. data/lib/bundler/cli/show.rb +7 -7
  39. data/lib/bundler/cli/update.rb +51 -19
  40. data/lib/bundler/cli/viz.rb +1 -1
  41. data/lib/bundler/cli.rb +399 -390
  42. data/lib/bundler/compact_index_client/cache.rb +55 -77
  43. data/lib/bundler/compact_index_client/cache_file.rb +148 -0
  44. data/lib/bundler/compact_index_client/gem_parser.rb +32 -0
  45. data/lib/bundler/compact_index_client/parser.rb +84 -0
  46. data/lib/bundler/compact_index_client/updater.rb +72 -84
  47. data/lib/bundler/compact_index_client.rb +61 -73
  48. data/lib/bundler/constants.rb +9 -2
  49. data/lib/bundler/current_ruby.rb +20 -21
  50. data/lib/bundler/definition.rb +663 -505
  51. data/lib/bundler/dependency.rb +38 -71
  52. data/lib/bundler/deployment.rb +1 -1
  53. data/lib/bundler/digest.rb +71 -0
  54. data/lib/bundler/dsl.rb +171 -152
  55. data/lib/bundler/endpoint_specification.rb +43 -17
  56. data/lib/bundler/env.rb +11 -18
  57. data/lib/bundler/environment_preserver.rb +17 -8
  58. data/lib/bundler/errors.rb +115 -14
  59. data/lib/bundler/feature_flag.rb +15 -39
  60. data/lib/bundler/fetcher/base.rb +12 -12
  61. data/lib/bundler/fetcher/compact_index.rb +41 -47
  62. data/lib/bundler/fetcher/dependency.rb +4 -8
  63. data/lib/bundler/fetcher/downloader.rb +27 -20
  64. data/lib/bundler/fetcher/gem_remote_fetcher.rb +16 -0
  65. data/lib/bundler/fetcher/index.rb +6 -33
  66. data/lib/bundler/fetcher.rb +109 -90
  67. data/lib/bundler/force_platform.rb +16 -0
  68. data/lib/bundler/friendly_errors.rb +50 -55
  69. data/lib/bundler/gem_helper.rb +81 -46
  70. data/lib/bundler/gem_helpers.rb +78 -29
  71. data/lib/bundler/gem_tasks.rb +1 -1
  72. data/lib/bundler/gem_version_promoter.rb +68 -109
  73. data/lib/bundler/graph.rb +11 -11
  74. data/lib/bundler/index.rb +74 -82
  75. data/lib/bundler/injector.rb +58 -26
  76. data/lib/bundler/inline.rb +59 -35
  77. data/lib/bundler/installer/gem_installer.rb +29 -29
  78. data/lib/bundler/installer/parallel_installer.rb +38 -68
  79. data/lib/bundler/installer/standalone.rb +76 -16
  80. data/lib/bundler/installer.rb +60 -135
  81. data/lib/bundler/lazy_specification.rb +161 -63
  82. data/lib/bundler/lockfile_generator.rb +14 -5
  83. data/lib/bundler/lockfile_parser.rb +150 -109
  84. data/lib/bundler/man/bundle-add.1 +76 -0
  85. data/lib/bundler/man/bundle-add.1.ronn +87 -0
  86. data/{man → lib/bundler/man}/bundle-binstubs.1 +15 -22
  87. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +8 -7
  88. data/lib/bundler/man/bundle-cache.1 +68 -0
  89. data/lib/bundler/man/bundle-cache.1.ronn +108 -0
  90. data/{man → lib/bundler/man}/bundle-check.1 +7 -14
  91. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +7 -2
  92. data/{man → lib/bundler/man}/bundle-clean.1 +4 -11
  93. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +1 -1
  94. data/{man → lib/bundler/man}/bundle-config.1 +80 -260
  95. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +104 -98
  96. data/lib/bundler/man/bundle-console.1 +33 -0
  97. data/lib/bundler/man/bundle-console.1.ronn +39 -0
  98. data/{man → lib/bundler/man}/bundle-doctor.1 +5 -19
  99. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +1 -1
  100. data/lib/bundler/man/bundle-env.1 +9 -0
  101. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  102. data/{man → lib/bundler/man}/bundle-exec.1 +20 -78
  103. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +12 -10
  104. data/lib/bundler/man/bundle-fund.1 +22 -0
  105. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  106. data/lib/bundler/man/bundle-gem.1 +87 -0
  107. data/lib/bundler/man/bundle-gem.1.ronn +149 -0
  108. data/lib/bundler/man/bundle-help.1 +9 -0
  109. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  110. data/lib/bundler/man/bundle-info.1 +17 -0
  111. data/lib/bundler/man/bundle-info.1.ronn +21 -0
  112. data/{man → lib/bundler/man}/bundle-init.1 +8 -13
  113. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +5 -2
  114. data/lib/bundler/man/bundle-inject.1 +31 -0
  115. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +12 -2
  116. data/{man → lib/bundler/man}/bundle-install.1 +65 -155
  117. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +66 -57
  118. data/lib/bundler/man/bundle-issue.1 +45 -0
  119. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  120. data/lib/bundler/man/bundle-licenses.1 +9 -0
  121. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  122. data/{man → lib/bundler/man}/bundle-list.1 +9 -24
  123. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +10 -7
  124. data/{man → lib/bundler/man}/bundle-lock.1 +25 -34
  125. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +25 -4
  126. data/lib/bundler/man/bundle-open.1 +32 -0
  127. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +10 -1
  128. data/{man → lib/bundler/man}/bundle-outdated.1 +23 -75
  129. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +21 -22
  130. data/lib/bundler/man/bundle-platform.1 +49 -0
  131. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +14 -7
  132. data/lib/bundler/man/bundle-plugin.1 +58 -0
  133. data/lib/bundler/man/bundle-plugin.1.ronn +63 -0
  134. data/{man → lib/bundler/man}/bundle-pristine.1 +5 -16
  135. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +1 -1
  136. data/{man → lib/bundler/man}/bundle-remove.1 +4 -14
  137. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +1 -1
  138. data/{man → lib/bundler/man}/bundle-show.1 +7 -11
  139. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +4 -0
  140. data/{man → lib/bundler/man}/bundle-update.1 +35 -148
  141. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +21 -12
  142. data/lib/bundler/man/bundle-version.1 +22 -0
  143. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  144. data/{man → lib/bundler/man}/bundle-viz.1 +9 -18
  145. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +9 -3
  146. data/{man → lib/bundler/man}/bundle.1 +19 -53
  147. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +14 -9
  148. data/{man → lib/bundler/man}/gemfile.5 +139 -356
  149. data/{man → lib/bundler/man}/gemfile.5.ronn +134 -97
  150. data/{man → lib/bundler/man}/index.txt +9 -1
  151. data/lib/bundler/match_metadata.rb +17 -0
  152. data/lib/bundler/match_platform.rb +2 -3
  153. data/lib/bundler/match_remote_metadata.rb +29 -0
  154. data/lib/bundler/materialization.rb +59 -0
  155. data/lib/bundler/mirror.rb +10 -12
  156. data/lib/bundler/plugin/api/source.rb +34 -18
  157. data/lib/bundler/plugin/api.rb +1 -1
  158. data/lib/bundler/plugin/dsl.rb +1 -1
  159. data/lib/bundler/plugin/events.rb +24 -0
  160. data/lib/bundler/plugin/index.rb +44 -9
  161. data/lib/bundler/plugin/installer/git.rb +0 -4
  162. data/lib/bundler/plugin/installer/path.rb +18 -0
  163. data/lib/bundler/plugin/installer/rubygems.rb +1 -9
  164. data/lib/bundler/plugin/installer.rb +63 -27
  165. data/lib/bundler/plugin/source_list.rb +5 -1
  166. data/lib/bundler/plugin.rb +131 -45
  167. data/lib/bundler/process_lock.rb +10 -14
  168. data/lib/bundler/remote_specification.rb +22 -10
  169. data/lib/bundler/resolver/base.rb +118 -0
  170. data/lib/bundler/resolver/candidate.rb +82 -0
  171. data/lib/bundler/resolver/incompatibility.rb +15 -0
  172. data/lib/bundler/resolver/package.rb +90 -0
  173. data/lib/bundler/resolver/root.rb +25 -0
  174. data/lib/bundler/resolver/spec_group.rb +60 -68
  175. data/lib/bundler/resolver.rb +454 -303
  176. data/lib/bundler/retry.rb +6 -6
  177. data/lib/bundler/ruby_dsl.rb +51 -7
  178. data/lib/bundler/ruby_version.rb +23 -38
  179. data/lib/bundler/rubygems_ext.rb +357 -98
  180. data/lib/bundler/rubygems_gem_installer.rb +131 -65
  181. data/lib/bundler/rubygems_integration.rb +149 -591
  182. data/lib/bundler/runtime.rb +51 -51
  183. data/lib/bundler/safe_marshal.rb +31 -0
  184. data/lib/bundler/self_manager.rb +206 -0
  185. data/lib/bundler/settings.rb +271 -135
  186. data/lib/bundler/setup.rb +23 -12
  187. data/lib/bundler/shared_helpers.rb +127 -117
  188. data/lib/bundler/similarity_detector.rb +3 -3
  189. data/lib/bundler/source/git/git_proxy.rb +326 -127
  190. data/lib/bundler/source/git.rb +207 -88
  191. data/lib/bundler/source/metadata.rb +19 -18
  192. data/lib/bundler/source/path/installer.rb +11 -32
  193. data/lib/bundler/source/path.rb +39 -38
  194. data/lib/bundler/source/rubygems/remote.rb +3 -4
  195. data/lib/bundler/source/rubygems.rb +223 -255
  196. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  197. data/lib/bundler/source.rb +33 -11
  198. data/lib/bundler/source_list.rb +131 -66
  199. data/lib/bundler/source_map.rb +71 -0
  200. data/lib/bundler/spec_set.rb +239 -94
  201. data/lib/bundler/stub_specification.rb +77 -39
  202. data/lib/bundler/templates/Executable +3 -5
  203. data/lib/bundler/templates/Executable.bundler +23 -19
  204. data/lib/bundler/templates/Executable.standalone +4 -4
  205. data/lib/bundler/templates/Gemfile +0 -2
  206. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  207. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +104 -46
  208. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  209. data/lib/bundler/templates/newgem/Gemfile.tt +19 -2
  210. data/lib/bundler/templates/newgem/README.md.tt +18 -16
  211. data/lib/bundler/templates/newgem/Rakefile.tt +44 -6
  212. data/lib/bundler/templates/newgem/bin/console.tt +1 -4
  213. data/lib/bundler/templates/newgem/circleci/config.yml.tt +25 -0
  214. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  215. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  216. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  217. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  218. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  219. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +37 -0
  220. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  221. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +18 -0
  222. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  223. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  224. data/lib/bundler/templates/newgem/newgem.gemspec.tt +37 -40
  225. data/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  226. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  227. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  228. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  229. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  230. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  231. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  232. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  233. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  234. data/lib/bundler/ui/rg_proxy.rb +2 -2
  235. data/lib/bundler/ui/shell.rb +64 -23
  236. data/lib/bundler/ui/silent.rb +33 -6
  237. data/lib/bundler/ui.rb +3 -3
  238. data/lib/bundler/uri_credentials_filter.rb +11 -5
  239. data/lib/bundler/uri_normalizer.rb +23 -0
  240. data/lib/bundler/vendor/.document +1 -0
  241. data/lib/bundler/vendor/connection_pool/.document +1 -0
  242. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  243. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +174 -0
  244. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  245. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  246. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +175 -0
  247. data/lib/bundler/vendor/fileutils/.document +1 -0
  248. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  249. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1490 -432
  250. data/lib/bundler/vendor/net-http-persistent/.document +1 -0
  251. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  252. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  253. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  254. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  255. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +362 -484
  256. data/lib/bundler/vendor/pub_grub/.document +1 -0
  257. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  258. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  259. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  260. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  261. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  262. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  263. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  264. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  265. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  266. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  267. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  268. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  269. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  270. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  271. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  272. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  273. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  274. data/lib/bundler/vendor/securerandom/.document +1 -0
  275. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  276. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  277. data/lib/bundler/vendor/thor/.document +1 -0
  278. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  279. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +4 -3
  280. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +3 -2
  281. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +8 -18
  282. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +1 -1
  283. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +27 -20
  284. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +34 -13
  285. data/lib/bundler/vendor/thor/lib/thor/actions.rb +47 -28
  286. data/lib/bundler/vendor/thor/lib/thor/base.rb +200 -54
  287. data/lib/bundler/vendor/thor/lib/thor/command.rb +34 -18
  288. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +10 -0
  289. data/lib/bundler/vendor/thor/lib/thor/error.rb +74 -0
  290. data/lib/bundler/vendor/thor/lib/thor/group.rb +15 -4
  291. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +2 -1
  292. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  293. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  294. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  295. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  296. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +17 -1
  297. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +35 -15
  298. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +45 -13
  299. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +86 -13
  300. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  301. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +3 -2
  302. data/lib/bundler/vendor/thor/lib/thor/runner.rb +51 -40
  303. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +99 -148
  304. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -43
  305. data/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  306. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -49
  307. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  308. data/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  309. data/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  310. data/lib/bundler/vendor/thor/lib/thor/shell.rb +6 -6
  311. data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
  312. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  313. data/lib/bundler/vendor/thor/lib/thor.rb +182 -17
  314. data/lib/bundler/vendor/tsort/.document +1 -0
  315. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  316. data/lib/bundler/vendor/tsort/lib/tsort.rb +455 -0
  317. data/lib/bundler/vendor/uri/.document +1 -0
  318. data/lib/bundler/vendor/uri/COPYING +56 -0
  319. data/lib/bundler/vendor/uri/lib/uri/common.rb +876 -0
  320. data/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  321. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  322. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1578 -0
  323. data/lib/bundler/vendor/uri/lib/uri/http.rb +125 -0
  324. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  325. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  326. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  327. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  328. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  329. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  330. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  331. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  332. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  333. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  334. data/lib/bundler/vendored_fileutils.rb +1 -6
  335. data/lib/bundler/vendored_net_http.rb +23 -0
  336. data/lib/bundler/vendored_persistent.rb +1 -42
  337. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  338. data/lib/bundler/vendored_securerandom.rb +12 -0
  339. data/lib/bundler/vendored_thor.rb +2 -2
  340. data/lib/bundler/vendored_timeout.rb +12 -0
  341. data/lib/bundler/vendored_tsort.rb +4 -0
  342. data/lib/bundler/vendored_uri.rb +21 -0
  343. data/lib/bundler/version.rb +5 -20
  344. data/lib/bundler/vlad.rb +3 -3
  345. data/lib/bundler/worker.rb +26 -15
  346. data/lib/bundler/yaml_serializer.rb +21 -13
  347. data/lib/bundler.rb +364 -230
  348. metadata +186 -218
  349. data/exe/bundle_ruby +0 -60
  350. data/lib/bundler/cli/package.rb +0 -49
  351. data/lib/bundler/compatibility_guard.rb +0 -14
  352. data/lib/bundler/dep_proxy.rb +0 -48
  353. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  354. data/lib/bundler/gemdeps.rb +0 -29
  355. data/lib/bundler/psyched_yaml.rb +0 -37
  356. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  357. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  358. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  359. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  360. data/lib/bundler/templates/gems.rb +0 -8
  361. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -3
  362. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  363. data/lib/bundler/templates/newgem/travis.yml.tt +0 -7
  364. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  365. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  366. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -81
  367. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  368. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  369. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  370. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  371. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  372. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  373. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  374. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  375. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -136
  376. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -223
  377. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  378. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  379. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -101
  380. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  381. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -837
  382. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  383. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  384. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -12
  385. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  386. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  387. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  388. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  389. data/lib/bundler/version_ranges.rb +0 -76
  390. data/man/bundle-add.1 +0 -58
  391. data/man/bundle-add.1.txt +0 -52
  392. data/man/bundle-add.ronn +0 -40
  393. data/man/bundle-binstubs.1.txt +0 -48
  394. data/man/bundle-check.1.txt +0 -33
  395. data/man/bundle-clean.1.txt +0 -26
  396. data/man/bundle-config.1.txt +0 -529
  397. data/man/bundle-doctor.1.txt +0 -44
  398. data/man/bundle-exec.1.txt +0 -178
  399. data/man/bundle-gem.1 +0 -80
  400. data/man/bundle-gem.1.txt +0 -91
  401. data/man/bundle-gem.ronn +0 -78
  402. data/man/bundle-info.1 +0 -20
  403. data/man/bundle-info.1.txt +0 -21
  404. data/man/bundle-info.ronn +0 -17
  405. data/man/bundle-init.1.txt +0 -34
  406. data/man/bundle-inject.1 +0 -33
  407. data/man/bundle-inject.1.txt +0 -32
  408. data/man/bundle-install.1.txt +0 -396
  409. data/man/bundle-list.1.txt +0 -43
  410. data/man/bundle-lock.1.txt +0 -93
  411. data/man/bundle-open.1 +0 -32
  412. data/man/bundle-open.1.txt +0 -29
  413. data/man/bundle-outdated.1.txt +0 -131
  414. data/man/bundle-package.1 +0 -55
  415. data/man/bundle-package.1.txt +0 -79
  416. data/man/bundle-package.ronn +0 -72
  417. data/man/bundle-platform.1 +0 -61
  418. data/man/bundle-platform.1.txt +0 -57
  419. data/man/bundle-pristine.1.txt +0 -44
  420. data/man/bundle-remove.1.txt +0 -34
  421. data/man/bundle-show.1.txt +0 -27
  422. data/man/bundle-update.1.txt +0 -391
  423. data/man/bundle-viz.1.txt +0 -39
  424. data/man/bundle.1.txt +0 -116
  425. data/man/gemfile.5.txt +0 -653
  426. /data/lib/bundler/{ssl_certs → man}/.document +0 -0
data/lib/bundler.rb CHANGED
@@ -1,77 +1,101 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/compatibility_guard"
4
-
5
- require "bundler/vendored_fileutils"
3
+ require_relative "bundler/vendored_fileutils"
6
4
  require "pathname"
7
5
  require "rbconfig"
8
- require "thread"
9
-
10
- require "bundler/errors"
11
- require "bundler/environment_preserver"
12
- require "bundler/plugin"
13
- require "bundler/rubygems_ext"
14
- require "bundler/rubygems_integration"
15
- require "bundler/version"
16
- require "bundler/constants"
17
- require "bundler/current_ruby"
18
- require "bundler/build_metadata"
19
6
 
7
+ require_relative "bundler/errors"
8
+ require_relative "bundler/environment_preserver"
9
+ require_relative "bundler/plugin"
10
+ require_relative "bundler/rubygems_ext"
11
+ require_relative "bundler/rubygems_integration"
12
+ require_relative "bundler/version"
13
+ require_relative "bundler/current_ruby"
14
+ require_relative "bundler/build_metadata"
15
+
16
+ # Bundler provides a consistent environment for Ruby projects by
17
+ # tracking and installing the exact gems and versions that are needed.
18
+ #
19
+ # Bundler is a part of Ruby's standard library.
20
+ #
21
+ # Bundler is used by creating _gemfiles_ listing all the project dependencies
22
+ # and (optionally) their versions and then using
23
+ #
24
+ # require 'bundler/setup'
25
+ #
26
+ # or Bundler.setup to setup environment where only specified gems and their
27
+ # specified versions could be used.
28
+ #
29
+ # See {Bundler website}[https://bundler.io/docs.html] for extensive documentation
30
+ # on gemfiles creation and Bundler usage.
31
+ #
32
+ # As a standard library inside project, Bundler could be used for introspection
33
+ # of loaded and required modules.
34
+ #
20
35
  module Bundler
21
- environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS)
36
+ environment_preserver = EnvironmentPreserver.from_env
22
37
  ORIGINAL_ENV = environment_preserver.restore
23
- ENV.replace(environment_preserver.backup)
24
- SUDO_MUTEX = Mutex.new
25
-
26
- autoload :Definition, "bundler/definition"
27
- autoload :Dependency, "bundler/dependency"
28
- autoload :DepProxy, "bundler/dep_proxy"
29
- autoload :Deprecate, "bundler/deprecate"
30
- autoload :Dsl, "bundler/dsl"
31
- autoload :EndpointSpecification, "bundler/endpoint_specification"
32
- autoload :Env, "bundler/env"
33
- autoload :Fetcher, "bundler/fetcher"
34
- autoload :FeatureFlag, "bundler/feature_flag"
35
- autoload :GemHelper, "bundler/gem_helper"
36
- autoload :GemHelpers, "bundler/gem_helpers"
37
- autoload :GemRemoteFetcher, "bundler/gem_remote_fetcher"
38
- autoload :GemVersionPromoter, "bundler/gem_version_promoter"
39
- autoload :Graph, "bundler/graph"
40
- autoload :Index, "bundler/index"
41
- autoload :Injector, "bundler/injector"
42
- autoload :Installer, "bundler/installer"
43
- autoload :LazySpecification, "bundler/lazy_specification"
44
- autoload :LockfileParser, "bundler/lockfile_parser"
45
- autoload :MatchPlatform, "bundler/match_platform"
46
- autoload :ProcessLock, "bundler/process_lock"
47
- autoload :RemoteSpecification, "bundler/remote_specification"
48
- autoload :Resolver, "bundler/resolver"
49
- autoload :Retry, "bundler/retry"
50
- autoload :RubyDsl, "bundler/ruby_dsl"
51
- autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
52
- autoload :RubyVersion, "bundler/ruby_version"
53
- autoload :Runtime, "bundler/runtime"
54
- autoload :Settings, "bundler/settings"
55
- autoload :SharedHelpers, "bundler/shared_helpers"
56
- autoload :Source, "bundler/source"
57
- autoload :SourceList, "bundler/source_list"
58
- autoload :SpecSet, "bundler/spec_set"
59
- autoload :StubSpecification, "bundler/stub_specification"
60
- autoload :UI, "bundler/ui"
61
- autoload :URICredentialsFilter, "bundler/uri_credentials_filter"
62
- autoload :VersionRanges, "bundler/version_ranges"
38
+ environment_preserver.replace_with_backup
39
+ SUDO_MUTEX = Thread::Mutex.new
40
+
41
+ autoload :Checksum, File.expand_path("bundler/checksum", __dir__)
42
+ autoload :CLI, File.expand_path("bundler/cli", __dir__)
43
+ autoload :CIDetector, File.expand_path("bundler/ci_detector", __dir__)
44
+ autoload :CompactIndexClient, File.expand_path("bundler/compact_index_client", __dir__)
45
+ autoload :Definition, File.expand_path("bundler/definition", __dir__)
46
+ autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
47
+ autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
48
+ autoload :Digest, File.expand_path("bundler/digest", __dir__)
49
+ autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
50
+ autoload :EndpointSpecification, File.expand_path("bundler/endpoint_specification", __dir__)
51
+ autoload :Env, File.expand_path("bundler/env", __dir__)
52
+ autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
53
+ autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
54
+ autoload :FREEBSD, File.expand_path("bundler/constants", __dir__)
55
+ autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
56
+ autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
57
+ autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
58
+ autoload :Graph, File.expand_path("bundler/graph", __dir__)
59
+ autoload :Index, File.expand_path("bundler/index", __dir__)
60
+ autoload :Injector, File.expand_path("bundler/injector", __dir__)
61
+ autoload :Installer, File.expand_path("bundler/installer", __dir__)
62
+ autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
63
+ autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
64
+ autoload :MatchRemoteMetadata, File.expand_path("bundler/match_remote_metadata", __dir__)
65
+ autoload :Materialization, File.expand_path("bundler/materialization", __dir__)
66
+ autoload :NULL, File.expand_path("bundler/constants", __dir__)
67
+ autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
68
+ autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
69
+ autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
70
+ autoload :Retry, File.expand_path("bundler/retry", __dir__)
71
+ autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
72
+ autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
73
+ autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
74
+ autoload :SelfManager, File.expand_path("bundler/self_manager", __dir__)
75
+ autoload :Settings, File.expand_path("bundler/settings", __dir__)
76
+ autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
77
+ autoload :Source, File.expand_path("bundler/source", __dir__)
78
+ autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
79
+ autoload :SourceMap, File.expand_path("bundler/source_map", __dir__)
80
+ autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
81
+ autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
82
+ autoload :UI, File.expand_path("bundler/ui", __dir__)
83
+ autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
84
+ autoload :URINormalizer, File.expand_path("bundler/uri_normalizer", __dir__)
85
+ autoload :WINDOWS, File.expand_path("bundler/constants", __dir__)
86
+ autoload :SafeMarshal, File.expand_path("bundler/safe_marshal", __dir__)
63
87
 
64
88
  class << self
65
89
  def configure
66
- @configured ||= configure_gem_home_and_path
90
+ @configure ||= configure_gem_home_and_path
67
91
  end
68
92
 
69
93
  def ui
70
- (defined?(@ui) && @ui) || (self.ui = UI::Silent.new)
94
+ (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)
71
95
  end
72
96
 
73
97
  def ui=(ui)
74
- Bundler.rubygems.ui = ui ? UI::RGProxy.new(ui) : nil
98
+ Bundler.rubygems.ui = UI::RGProxy.new(ui)
75
99
  @ui = ui
76
100
  end
77
101
 
@@ -80,6 +104,15 @@ module Bundler
80
104
  @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
81
105
  end
82
106
 
107
+ def create_bundle_path
108
+ mkdir_p(bundle_path) unless bundle_path.exist?
109
+
110
+ @bundle_path = bundle_path.realpath
111
+ rescue Errno::EEXIST
112
+ raise PathError, "Could not install to path `#{bundle_path}` " \
113
+ "because a file already exists at that path. Either remove or rename the file so the directory can be created."
114
+ end
115
+
83
116
  def configured_bundle_path
84
117
  @configured_bundle_path ||= settings.path.tap(&:validate!)
85
118
  end
@@ -89,11 +122,38 @@ module Bundler
89
122
  @bin_path ||= begin
90
123
  path = settings[:bin] || "bin"
91
124
  path = Pathname.new(path).expand_path(root).expand_path
92
- SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
125
+ mkdir_p(path)
93
126
  path
94
127
  end
95
128
  end
96
129
 
130
+ # Turns on the Bundler runtime. After +Bundler.setup+ call, all +load+ or
131
+ # +require+ of the gems would be allowed only if they are part of
132
+ # the Gemfile or Ruby's standard library. If the versions specified
133
+ # in Gemfile, only those versions would be loaded.
134
+ #
135
+ # Assuming Gemfile
136
+ #
137
+ # gem 'first_gem', '= 1.0'
138
+ # group :test do
139
+ # gem 'second_gem', '= 1.0'
140
+ # end
141
+ #
142
+ # The code using Bundler.setup works as follows:
143
+ #
144
+ # require 'third_gem' # allowed, required from global gems
145
+ # require 'first_gem' # allowed, loads the last installed version
146
+ # Bundler.setup
147
+ # require 'fourth_gem' # fails with LoadError
148
+ # require 'second_gem' # loads exactly version 1.0
149
+ #
150
+ # +Bundler.setup+ can be called only once, all subsequent calls are no-op.
151
+ #
152
+ # If _groups_ list is provided, only gems from specified groups would
153
+ # be allowed (gems specified outside groups belong to special +:default+ group).
154
+ #
155
+ # To require all gems from Gemfile (or only some groups), see Bundler.require.
156
+ #
97
157
  def setup(*groups)
98
158
  # Return if all groups are already loaded
99
159
  return @setup if defined?(@setup) && @setup
@@ -110,6 +170,47 @@ module Bundler
110
170
  end
111
171
  end
112
172
 
173
+ def auto_switch
174
+ self_manager.restart_with_locked_bundler_if_needed
175
+ end
176
+
177
+ # Automatically install dependencies if Bundler.settings[:auto_install] exists.
178
+ # This is set through config cmd `bundle config set --global auto_install 1`.
179
+ #
180
+ # Note that this method `nil`s out the global Definition object, so it
181
+ # should be called first, before you instantiate anything like an
182
+ # `Installer` that'll keep a reference to the old one instead.
183
+ def auto_install
184
+ return unless settings[:auto_install]
185
+
186
+ begin
187
+ definition.specs
188
+ rescue GemNotFound, GitError
189
+ ui.info "Automatically installing missing gems."
190
+ reset!
191
+ CLI::Install.new({}).run
192
+ reset!
193
+ end
194
+ end
195
+
196
+ # Setups Bundler environment (see Bundler.setup) if it is not already set,
197
+ # and loads all gems from groups specified. Unlike ::setup, can be called
198
+ # multiple times with different groups (if they were allowed by setup).
199
+ #
200
+ # Assuming Gemfile
201
+ #
202
+ # gem 'first_gem', '= 1.0'
203
+ # group :test do
204
+ # gem 'second_gem', '= 1.0'
205
+ # end
206
+ #
207
+ # The code will work as follows:
208
+ #
209
+ # Bundler.setup # allow all groups
210
+ # Bundler.require(:default) # requires only first_gem
211
+ # # ...later
212
+ # Bundler.require(:test) # requires second_gem
213
+ #
113
214
  def require(*groups)
114
215
  setup(*groups).require(*groups)
115
216
  end
@@ -119,7 +220,7 @@ module Bundler
119
220
  end
120
221
 
121
222
  def environment
122
- SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load"
223
+ SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", print_caller_location: true
123
224
  load
124
225
  end
125
226
 
@@ -127,19 +228,21 @@ module Bundler
127
228
  #
128
229
  # @param unlock [Hash, Boolean, nil] Gems that have been requested
129
230
  # to be updated or true if all gems should be updated
231
+ # @param lockfile [Pathname] Path to Gemfile.lock
130
232
  # @return [Bundler::Definition]
131
- def definition(unlock = nil)
233
+ def definition(unlock = nil, lockfile = default_lockfile)
132
234
  @definition = nil if unlock
133
235
  @definition ||= begin
134
236
  configure
135
- Definition.build(default_gemfile, default_lockfile, unlock)
237
+ Definition.build(default_gemfile, lockfile, unlock)
136
238
  end
137
239
  end
138
240
 
139
241
  def frozen_bundle?
140
- frozen = settings[:deployment]
141
- frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen?
142
- frozen
242
+ frozen = settings[:frozen]
243
+ return frozen unless frozen.nil?
244
+
245
+ settings[:deployment]
143
246
  end
144
247
 
145
248
  def locked_gems
@@ -153,7 +256,7 @@ module Bundler
153
256
  end
154
257
 
155
258
  def ruby_scope
156
- "#{Bundler.rubygems.ruby_engine}/#{Bundler.rubygems.config_map[:ruby_version]}"
259
+ "#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}"
157
260
  end
158
261
 
159
262
  def user_home
@@ -170,9 +273,9 @@ module Bundler
170
273
  end
171
274
 
172
275
  if warning
173
- Kernel.send(:require, "etc")
174
- user_home = tmp_home_path(Etc.getlogin, warning)
175
- Bundler.ui.warn "#{warning}\nBundler will use `#{user_home}' as your home directory temporarily.\n"
276
+ Bundler.ui.warn "#{warning}\n"
277
+ user_home = tmp_home_path
278
+ Bundler.ui.warn "Bundler will use `#{user_home}' as your home directory temporarily.\n"
176
279
  user_home
177
280
  else
178
281
  Pathname.new(home)
@@ -180,37 +283,22 @@ module Bundler
180
283
  end
181
284
  end
182
285
 
183
- def tmp_home_path(login, warning)
184
- login ||= "unknown"
185
- Kernel.send(:require, "tmpdir")
186
- path = Pathname.new(Dir.tmpdir).join("bundler", "home")
187
- SharedHelpers.filesystem_access(path) do |tmp_home_path|
188
- unless tmp_home_path.exist?
189
- tmp_home_path.mkpath
190
- tmp_home_path.chmod(0o777)
191
- end
192
- tmp_home_path.join(login).tap(&:mkpath)
193
- end
194
- rescue RuntimeError => e
195
- raise e.exception("#{warning}\nBundler also failed to create a temporary home directory at `#{path}':\n#{e}")
196
- end
197
-
198
286
  def user_bundle_path(dir = "home")
199
287
  env_var, fallback = case dir
200
288
  when "home"
201
- ["BUNDLE_USER_HOME", Pathname.new(user_home).join(".bundle")]
289
+ ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }]
202
290
  when "cache"
203
- ["BUNDLE_USER_CACHE", user_bundle_path.join("cache")]
291
+ ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }]
204
292
  when "config"
205
- ["BUNDLE_USER_CONFIG", user_bundle_path.join("config")]
293
+ ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }]
206
294
  when "plugin"
207
- ["BUNDLE_USER_PLUGIN", user_bundle_path.join("plugin")]
295
+ ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }]
208
296
  else
209
297
  raise BundlerError, "Unknown user path requested: #{dir}"
210
298
  end
211
299
  # `fallback` will already be a Pathname, but Pathname.new() is
212
300
  # idempotent so it's OK
213
- Pathname.new(ENV.fetch(env_var, fallback))
301
+ Pathname.new(ENV.fetch(env_var, &fallback))
214
302
  end
215
303
 
216
304
  def user_cache
@@ -241,7 +329,13 @@ module Bundler
241
329
 
242
330
  def app_config_path
243
331
  if app_config = ENV["BUNDLE_APP_CONFIG"]
244
- Pathname.new(app_config).expand_path(root)
332
+ app_config_pathname = Pathname.new(app_config)
333
+
334
+ if app_config_pathname.absolute?
335
+ app_config_pathname
336
+ else
337
+ app_config_pathname.expand_path(root)
338
+ end
245
339
  else
246
340
  root.join(".bundle")
247
341
  end
@@ -259,20 +353,12 @@ module Bundler
259
353
 
260
354
  def rm_rf(path)
261
355
  FileUtils.remove_entry_secure(path) if path && File.exist?(path)
262
- rescue ArgumentError
263
- message = <<EOF
264
- It is a security vulnerability to allow your home directory to be world-writable, and bundler can not continue.
265
- You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
266
- Please refer to http://ruby-doc.org/stdlib-2.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
267
- EOF
268
- File.world_writable?(path) ? Bundler.ui.warn(message) : raise
269
- raise PathError, "Please fix the world-writable issue with your #{path} directory"
270
356
  end
271
357
 
272
358
  def settings
273
359
  @settings ||= Settings.new(app_config_path)
274
360
  rescue GemfileNotFound
275
- @settings = Settings.new(Pathname.new(".bundle").expand_path)
361
+ @settings = Settings.new
276
362
  end
277
363
 
278
364
  # @return [Hash] Environment present before Bundler was activated
@@ -280,45 +366,92 @@ EOF
280
366
  ORIGINAL_ENV.clone
281
367
  end
282
368
 
283
- # @deprecated Use `original_env` instead
284
- # @return [Hash] Environment with all bundler-related variables removed
369
+ # @deprecated Use `unbundled_env` instead
285
370
  def clean_env
286
- Bundler::SharedHelpers.major_deprecation(2, "`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
287
- env = original_env
288
-
289
- if env.key?("BUNDLER_ORIG_MANPATH")
290
- env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
291
- end
292
-
293
- env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
294
-
295
- if env.key?("RUBYOPT")
296
- env["RUBYOPT"] = env["RUBYOPT"].sub "-rbundler/setup", ""
297
- end
371
+ message =
372
+ "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
373
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
374
+ removed_message =
375
+ "`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \
376
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
377
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
378
+ unbundled_env
379
+ end
298
380
 
299
- if env.key?("RUBYLIB")
300
- rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
301
- rubylib.delete(File.expand_path("..", __FILE__))
302
- env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
303
- end
381
+ # @return [Hash] Environment with all bundler-related variables removed
382
+ def unbundled_env
383
+ unbundle_env(original_env)
384
+ end
304
385
 
305
- env
386
+ # Remove all bundler-related variables from ENV
387
+ def unbundle_env!
388
+ ENV.replace(unbundle_env(ENV))
306
389
  end
307
390
 
391
+ # Run block with environment present before Bundler was activated
308
392
  def with_original_env
309
393
  with_env(original_env) { yield }
310
394
  end
311
395
 
396
+ # @deprecated Use `with_unbundled_env` instead
312
397
  def with_clean_env
313
- with_env(clean_env) { yield }
398
+ message =
399
+ "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
400
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
401
+ removed_message =
402
+ "`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \
403
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
404
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
405
+ with_env(unbundled_env) { yield }
406
+ end
407
+
408
+ # Run block with all bundler-related variables removed
409
+ def with_unbundled_env
410
+ with_env(unbundled_env) { yield }
314
411
  end
315
412
 
413
+ # Run subcommand with the environment present before Bundler was activated
414
+ def original_system(*args)
415
+ with_original_env { Kernel.system(*args) }
416
+ end
417
+
418
+ # @deprecated Use `unbundled_system` instead
316
419
  def clean_system(*args)
317
- with_clean_env { Kernel.system(*args) }
420
+ message =
421
+ "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
422
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
423
+ removed_message =
424
+ "`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \
425
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
426
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
427
+ with_env(unbundled_env) { Kernel.system(*args) }
428
+ end
429
+
430
+ # Run subcommand in an environment with all bundler related variables removed
431
+ def unbundled_system(*args)
432
+ with_unbundled_env { Kernel.system(*args) }
433
+ end
434
+
435
+ # Run a `Kernel.exec` to a subcommand with the environment present before Bundler was activated
436
+ def original_exec(*args)
437
+ with_original_env { Kernel.exec(*args) }
318
438
  end
319
439
 
440
+ # @deprecated Use `unbundled_exec` instead
320
441
  def clean_exec(*args)
321
- with_clean_env { Kernel.exec(*args) }
442
+ message =
443
+ "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
444
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
445
+ removed_message =
446
+ "`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \
447
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
448
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
449
+ with_env(unbundled_env) { Kernel.exec(*args) }
450
+ end
451
+
452
+ # Run a `Kernel.exec` to a subcommand in an environment with all bundler related variables removed
453
+ def unbundled_exec(*args)
454
+ with_env(unbundled_env) { Kernel.exec(*args) }
322
455
  end
323
456
 
324
457
  def local_platform
@@ -343,87 +476,44 @@ EOF
343
476
  # system binaries. If you put '-n foo' in your .gemrc, RubyGems will
344
477
  # install binstubs there instead. Unfortunately, RubyGems doesn't expose
345
478
  # that directory at all, so rather than parse .gemrc ourselves, we allow
346
- # the directory to be set as well, via `bundle config bindir foo`.
479
+ # the directory to be set as well, via `bundle config set --local bindir foo`.
347
480
  Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
348
481
  end
349
482
 
350
- def use_system_gems?
351
- configured_bundle_path.use_system_gems?
483
+ def preferred_gemfile_name
484
+ Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
352
485
  end
353
486
 
354
- def requires_sudo?
355
- return @requires_sudo if defined?(@requires_sudo_ran)
356
-
357
- sudo_present = which "sudo" if settings.allow_sudo?
358
-
359
- if sudo_present
360
- # the bundle path and subdirectories need to be writable for RubyGems
361
- # to be able to unpack and install gems without exploding
362
- path = bundle_path
363
- path = path.parent until path.exist?
364
-
365
- # bins are written to a different location on OS X
366
- bin_dir = Pathname.new(Bundler.system_bindir)
367
- bin_dir = bin_dir.parent until bin_dir.exist?
368
-
369
- # if any directory is not writable, we need sudo
370
- files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
371
- unwritable_files = files.reject {|f| File.writable?(f) }
372
- sudo_needed = !unwritable_files.empty?
373
- if sudo_needed
374
- Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).sort.join("\n ")}"
375
- end
376
- end
377
-
378
- @requires_sudo_ran = true
379
- @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
487
+ def use_system_gems?
488
+ configured_bundle_path.use_system_gems?
380
489
  end
381
490
 
382
- def mkdir_p(path, options = {})
383
- if requires_sudo? && !options[:no_sudo]
384
- sudo "mkdir -p '#{path}'" unless File.exist?(path)
385
- else
386
- SharedHelpers.filesystem_access(path, :write) do |p|
387
- FileUtils.mkdir_p(p)
388
- end
491
+ def mkdir_p(path)
492
+ SharedHelpers.filesystem_access(path, :create) do |p|
493
+ FileUtils.mkdir_p(p)
389
494
  end
390
495
  end
391
496
 
392
497
  def which(executable)
393
- if File.file?(executable) && File.executable?(executable)
394
- executable
395
- elsif paths = ENV["PATH"]
396
- quote = '"'.freeze
498
+ executable_path = find_executable(executable)
499
+ return executable_path if executable_path
500
+
501
+ if (paths = ENV["PATH"])
502
+ quote = '"'
397
503
  paths.split(File::PATH_SEPARATOR).find do |path|
398
504
  path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
399
- executable_path = File.expand_path(executable, path)
400
- return executable_path if File.file?(executable_path) && File.executable?(executable_path)
505
+ executable_path = find_executable(File.expand_path(executable, path))
506
+ return executable_path if executable_path
401
507
  end
402
508
  end
403
509
  end
404
510
 
405
- def sudo(str)
406
- SUDO_MUTEX.synchronize do
407
- prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
408
- Your user account isn't allowed to install to the system RubyGems.
409
- You can cancel this installation and run:
410
-
411
- bundle install --path vendor/bundle
412
-
413
- to install the gems into ./vendor/bundle/, or you can enter your password
414
- and install the bundled gems to RubyGems using sudo.
415
-
416
- Password:
417
- PROMPT
418
-
419
- unless @prompted_for_sudo ||= system(%(sudo -k -p "#{prompt}" true))
420
- raise SudoNotPermittedError,
421
- "Bundler requires sudo access to install at the moment. " \
422
- "Try installing again, granting Bundler sudo access when prompted, or installing into a different path."
423
- end
511
+ def find_executable(path)
512
+ extensions = RbConfig::CONFIG["EXECUTABLE_EXTS"]&.split
513
+ extensions = [RbConfig::CONFIG["EXEEXT"]] unless extensions&.any?
514
+ candidates = extensions.map {|ext| "#{path}#{ext}" }
424
515
 
425
- `sudo -p "#{prompt}" #{str}`
426
- end
516
+ candidates.find {|candidate| File.file?(candidate) && File.executable?(candidate) }
427
517
  end
428
518
 
429
519
  def read_file(file)
@@ -432,10 +522,17 @@ EOF
432
522
  end
433
523
  end
434
524
 
435
- def load_marshal(data)
436
- Marshal.load(data)
437
- rescue StandardError => e
438
- raise MarshalError, "#{e.class}: #{e.message}"
525
+ def safe_load_marshal(data)
526
+ if Gem.respond_to?(:load_safe_marshal)
527
+ Gem.load_safe_marshal
528
+ begin
529
+ Gem::SafeMarshal.safe_load(data)
530
+ rescue Gem::SafeMarshal::Reader::Error, Gem::SafeMarshal::Visitors::ToRuby::Error => e
531
+ raise MarshalError, "#{e.class}: #{e.message}"
532
+ end
533
+ else
534
+ load_marshal(data, marshal_proc: SafeMarshal.proc)
535
+ end
439
536
  end
440
537
 
441
538
  def load_gemspec(file, validate = false)
@@ -444,21 +541,13 @@ EOF
444
541
  @gemspec_cache[key] ||= load_gemspec_uncached(file, validate)
445
542
  # Protect against caching side-effected gemspecs by returning a
446
543
  # new instance each time.
447
- @gemspec_cache[key].dup if @gemspec_cache[key]
544
+ @gemspec_cache[key]&.dup
448
545
  end
449
546
 
450
547
  def load_gemspec_uncached(file, validate = false)
451
548
  path = Pathname.new(file)
452
549
  contents = read_file(file)
453
- spec = if contents.start_with?("---") # YAML header
454
- eval_yaml_gemspec(path, contents)
455
- else
456
- # Eval the gemspec from its parent directory, because some gemspecs
457
- # depend on "./" relative paths.
458
- SharedHelpers.chdir(path.dirname.to_s) do
459
- eval_gemspec(path, contents)
460
- end
461
- end
550
+ spec = eval_gemspec(path, contents)
462
551
  return unless spec
463
552
  spec.loaded_from = path.expand_path.to_s
464
553
  Bundler.rubygems.validate(spec) if validate
@@ -471,7 +560,7 @@ EOF
471
560
 
472
561
  def git_present?
473
562
  return @git_present if defined?(@git_present)
474
- @git_present = Bundler.which("git") || Bundler.which("git.exe")
563
+ @git_present = Bundler.which("git")
475
564
  end
476
565
 
477
566
  def feature_flag
@@ -484,11 +573,16 @@ EOF
484
573
  reset_rubygems!
485
574
  end
486
575
 
576
+ def reset_settings_and_root!
577
+ @settings = nil
578
+ @root = nil
579
+ end
580
+
487
581
  def reset_paths!
488
582
  @bin_path = nil
489
583
  @bundler_major_version = nil
490
584
  @bundle_path = nil
491
- @configured = nil
585
+ @configure = nil
492
586
  @configured_bundle_path = nil
493
587
  @definition = nil
494
588
  @load = nil
@@ -506,53 +600,93 @@ EOF
506
600
  @rubygems = nil
507
601
  end
508
602
 
509
- private
603
+ def configure_gem_home_and_path(path = bundle_path)
604
+ configure_gem_path
605
+ configure_gem_home(path)
606
+ Bundler.rubygems.clear_paths
607
+ end
608
+
609
+ def self_manager
610
+ @self_manager ||= begin
611
+ require_relative "bundler/self_manager"
612
+ Bundler::SelfManager.new
613
+ end
614
+ end
615
+
616
+ private
617
+
618
+ def unbundle_env(env)
619
+ if env.key?("BUNDLER_ORIG_MANPATH")
620
+ env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
621
+ end
622
+
623
+ env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
624
+ env.delete("BUNDLER_SETUP")
625
+
626
+ if env.key?("RUBYOPT")
627
+ rubyopt = env["RUBYOPT"].split(" ")
628
+ rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
629
+ rubyopt.delete("-rbundler/setup")
630
+ env["RUBYOPT"] = rubyopt.join(" ")
631
+ end
632
+
633
+ if env.key?("RUBYLIB")
634
+ rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
635
+ rubylib.delete(__dir__)
636
+ env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
637
+ end
638
+
639
+ env
640
+ end
641
+
642
+ def load_marshal(data, marshal_proc: nil)
643
+ Marshal.load(data, marshal_proc)
644
+ rescue TypeError => e
645
+ raise MarshalError, "#{e.class}: #{e.message}"
646
+ end
510
647
 
511
648
  def eval_yaml_gemspec(path, contents)
512
- Kernel.send(:require, "bundler/psyched_yaml")
649
+ Kernel.require "psych"
513
650
 
514
- # If the YAML is invalid, Syck raises an ArgumentError, and Psych
515
- # raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
516
651
  Gem::Specification.from_yaml(contents)
517
- rescue YamlLibrarySyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
518
- eval_gemspec(path, contents)
519
652
  end
520
653
 
521
654
  def eval_gemspec(path, contents)
522
- eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
655
+ if contents.start_with?("---") # YAML header
656
+ eval_yaml_gemspec(path, contents)
657
+ else
658
+ # Eval the gemspec from its parent directory, because some gemspecs
659
+ # depend on "./" relative paths.
660
+ SharedHelpers.chdir(path.dirname.to_s) do
661
+ eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
662
+ end
663
+ end
523
664
  rescue ScriptError, StandardError => e
524
665
  msg = "There was an error while loading `#{path.basename}`: #{e.message}"
525
666
 
526
- if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
527
- msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
528
- end
529
-
530
- raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
667
+ raise GemspecError, Dsl::DSLError.new(msg, path.to_s, e.backtrace, contents)
531
668
  end
532
669
 
533
- def configure_gem_home_and_path
534
- configure_gem_path
535
- configure_gem_home
536
- bundle_path
537
- end
538
-
539
- def configure_gem_path(env = ENV)
540
- blank_home = env["GEM_HOME"].nil? || env["GEM_HOME"].empty?
541
- if !use_system_gems?
670
+ def configure_gem_path
671
+ unless use_system_gems?
542
672
  # this needs to be empty string to cause
543
673
  # PathSupport.split_gem_path to only load up the
544
674
  # Bundler --path setting as the GEM_PATH.
545
- env["GEM_PATH"] = ""
546
- elsif blank_home
547
- possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
548
- paths = possibles.flatten.compact.uniq.reject(&:empty?)
549
- env["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
675
+ Bundler::SharedHelpers.set_env "GEM_PATH", ""
550
676
  end
551
677
  end
552
678
 
553
- def configure_gem_home
554
- Bundler::SharedHelpers.set_env "GEM_HOME", File.expand_path(bundle_path, root)
555
- Bundler.rubygems.clear_paths
679
+ def configure_gem_home(path)
680
+ Bundler::SharedHelpers.set_env "GEM_HOME", path.to_s
681
+ end
682
+
683
+ def tmp_home_path
684
+ Kernel.send(:require, "tmpdir")
685
+ SharedHelpers.filesystem_access(Dir.tmpdir) do
686
+ path = Bundler.tmp
687
+ at_exit { Bundler.rm_rf(path) }
688
+ path
689
+ end
556
690
  end
557
691
 
558
692
  # @param env [Hash]