bundler 1.11.1 → 2.2.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (328) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +2125 -840
  3. data/LICENSE.md +18 -19
  4. data/README.md +33 -11
  5. data/bundler.gemspec +34 -21
  6. data/exe/bundle +36 -6
  7. data/exe/bundler +2 -18
  8. data/lib/bundler.rb +435 -160
  9. data/lib/bundler/build_metadata.rb +45 -0
  10. data/lib/bundler/capistrano.rb +9 -3
  11. data/lib/bundler/cli.rb +550 -130
  12. data/lib/bundler/cli/add.rb +47 -0
  13. data/lib/bundler/cli/binstubs.rb +26 -10
  14. data/lib/bundler/cli/cache.rb +25 -17
  15. data/lib/bundler/cli/check.rb +8 -7
  16. data/lib/bundler/cli/clean.rb +8 -8
  17. data/lib/bundler/cli/common.rb +69 -9
  18. data/lib/bundler/cli/config.rb +170 -76
  19. data/lib/bundler/cli/console.rb +6 -1
  20. data/lib/bundler/cli/doctor.rb +140 -0
  21. data/lib/bundler/cli/exec.rb +63 -21
  22. data/lib/bundler/cli/fund.rb +36 -0
  23. data/lib/bundler/cli/gem.rb +158 -42
  24. data/lib/bundler/cli/info.rb +73 -0
  25. data/lib/bundler/cli/init.rb +22 -7
  26. data/lib/bundler/cli/inject.rb +38 -10
  27. data/lib/bundler/cli/install.rb +139 -104
  28. data/lib/bundler/cli/issue.rb +40 -0
  29. data/lib/bundler/cli/list.rb +60 -0
  30. data/lib/bundler/cli/lock.rb +27 -5
  31. data/lib/bundler/cli/open.rb +13 -5
  32. data/lib/bundler/cli/outdated.rb +251 -46
  33. data/lib/bundler/cli/platform.rb +6 -2
  34. data/lib/bundler/cli/plugin.rb +41 -0
  35. data/lib/bundler/cli/pristine.rb +52 -0
  36. data/lib/bundler/cli/remove.rb +18 -0
  37. data/lib/bundler/cli/show.rb +5 -4
  38. data/lib/bundler/cli/update.rb +67 -26
  39. data/lib/bundler/cli/viz.rb +11 -6
  40. data/lib/bundler/compact_index_client.rb +125 -0
  41. data/lib/bundler/compact_index_client/cache.rb +110 -0
  42. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  43. data/lib/bundler/compact_index_client/updater.rb +104 -0
  44. data/lib/bundler/constants.rb +2 -0
  45. data/lib/bundler/current_ruby.rb +51 -174
  46. data/lib/bundler/definition.rb +533 -216
  47. data/lib/bundler/dep_proxy.rb +18 -8
  48. data/lib/bundler/dependency.rb +39 -12
  49. data/lib/bundler/deployment.rb +7 -0
  50. data/lib/bundler/deprecate.rb +31 -2
  51. data/lib/bundler/dsl.rb +188 -91
  52. data/lib/bundler/endpoint_specification.rb +51 -10
  53. data/lib/bundler/env.rb +116 -48
  54. data/lib/bundler/environment_preserver.rb +82 -0
  55. data/lib/bundler/errors.rb +108 -31
  56. data/lib/bundler/feature_flag.rb +60 -0
  57. data/lib/bundler/fetcher.rb +81 -52
  58. data/lib/bundler/fetcher/base.rb +15 -3
  59. data/lib/bundler/fetcher/compact_index.rb +140 -0
  60. data/lib/bundler/fetcher/dependency.rb +36 -42
  61. data/lib/bundler/fetcher/downloader.rb +39 -12
  62. data/lib/bundler/fetcher/index.rb +34 -9
  63. data/lib/bundler/friendly_errors.rb +132 -88
  64. data/lib/bundler/gem_helper.rb +92 -50
  65. data/lib/bundler/gem_helpers.rb +90 -5
  66. data/lib/bundler/gem_tasks.rb +3 -1
  67. data/lib/bundler/gem_version_promoter.rb +190 -0
  68. data/lib/bundler/gemdeps.rb +29 -0
  69. data/lib/bundler/graph.rb +20 -41
  70. data/lib/bundler/index.rb +74 -57
  71. data/lib/bundler/injector.rb +242 -31
  72. data/lib/bundler/inline.rb +49 -23
  73. data/lib/bundler/installer.rb +190 -74
  74. data/lib/bundler/installer/gem_installer.rb +33 -20
  75. data/lib/bundler/installer/parallel_installer.rb +201 -97
  76. data/lib/bundler/installer/standalone.rb +10 -6
  77. data/lib/bundler/lazy_specification.rb +74 -10
  78. data/lib/bundler/lockfile_generator.rb +95 -0
  79. data/lib/bundler/lockfile_parser.rb +126 -74
  80. data/lib/bundler/{ssl_certs → man}/.document +0 -0
  81. data/lib/bundler/man/bundle-add.1 +66 -0
  82. data/lib/bundler/man/bundle-add.1.ronn +46 -0
  83. data/lib/bundler/man/bundle-binstubs.1 +42 -0
  84. data/lib/bundler/man/bundle-binstubs.1.ronn +41 -0
  85. data/lib/bundler/man/bundle-cache.1 +55 -0
  86. data/{man/bundle-package.ronn → lib/bundler/man/bundle-cache.1.ronn} +22 -16
  87. data/lib/bundler/man/bundle-check.1 +31 -0
  88. data/lib/bundler/man/bundle-check.1.ronn +26 -0
  89. data/lib/bundler/man/bundle-clean.1 +24 -0
  90. data/lib/bundler/man/bundle-clean.1.ronn +18 -0
  91. data/lib/bundler/man/bundle-config.1 +488 -0
  92. data/lib/bundler/man/bundle-config.1.ronn +388 -0
  93. data/lib/bundler/man/bundle-doctor.1 +44 -0
  94. data/lib/bundler/man/bundle-doctor.1.ronn +33 -0
  95. data/lib/bundler/man/bundle-exec.1 +165 -0
  96. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +20 -4
  97. data/lib/bundler/man/bundle-gem.1 +102 -0
  98. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +37 -13
  99. data/lib/bundler/man/bundle-info.1 +20 -0
  100. data/lib/bundler/man/bundle-info.1.ronn +17 -0
  101. data/lib/bundler/man/bundle-init.1 +25 -0
  102. data/lib/bundler/man/bundle-init.1.ronn +29 -0
  103. data/lib/bundler/man/bundle-inject.1 +33 -0
  104. data/lib/bundler/man/bundle-inject.1.ronn +22 -0
  105. data/lib/bundler/man/bundle-install.1 +338 -0
  106. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +82 -76
  107. data/lib/bundler/man/bundle-list.1 +50 -0
  108. data/lib/bundler/man/bundle-list.1.ronn +33 -0
  109. data/lib/bundler/man/bundle-lock.1 +84 -0
  110. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +47 -0
  111. data/lib/bundler/man/bundle-open.1 +32 -0
  112. data/lib/bundler/man/bundle-open.1.ronn +19 -0
  113. data/lib/bundler/man/bundle-outdated.1 +155 -0
  114. data/lib/bundler/man/bundle-outdated.1.ronn +111 -0
  115. data/lib/bundler/man/bundle-platform.1 +61 -0
  116. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +1 -1
  117. data/lib/bundler/man/bundle-pristine.1 +34 -0
  118. data/lib/bundler/man/bundle-pristine.1.ronn +34 -0
  119. data/lib/bundler/man/bundle-remove.1 +31 -0
  120. data/lib/bundler/man/bundle-remove.1.ronn +23 -0
  121. data/lib/bundler/man/bundle-show.1 +23 -0
  122. data/lib/bundler/man/bundle-show.1.ronn +21 -0
  123. data/lib/bundler/man/bundle-update.1 +394 -0
  124. data/lib/bundler/man/bundle-update.1.ronn +350 -0
  125. data/lib/bundler/man/bundle-viz.1 +39 -0
  126. data/lib/bundler/man/bundle-viz.1.ronn +30 -0
  127. data/lib/bundler/man/bundle.1 +136 -0
  128. data/lib/bundler/man/bundle.1.ronn +111 -0
  129. data/lib/bundler/man/gemfile.5 +686 -0
  130. data/{man → lib/bundler/man}/gemfile.5.ronn +117 -95
  131. data/lib/bundler/man/index.txt +25 -0
  132. data/lib/bundler/match_platform.rb +15 -4
  133. data/lib/bundler/mirror.rb +223 -0
  134. data/lib/bundler/plugin.rb +330 -0
  135. data/lib/bundler/plugin/api.rb +81 -0
  136. data/lib/bundler/plugin/api/source.rb +304 -0
  137. data/lib/bundler/plugin/dsl.rb +53 -0
  138. data/lib/bundler/plugin/events.rb +61 -0
  139. data/lib/bundler/plugin/index.rb +182 -0
  140. data/lib/bundler/plugin/installer.rb +109 -0
  141. data/lib/bundler/plugin/installer/git.rb +38 -0
  142. data/lib/bundler/plugin/installer/rubygems.rb +27 -0
  143. data/lib/bundler/plugin/source_list.rb +27 -0
  144. data/lib/bundler/process_lock.rb +24 -0
  145. data/lib/bundler/psyched_yaml.rb +2 -6
  146. data/lib/bundler/remote_specification.rb +42 -9
  147. data/lib/bundler/resolver.rb +312 -225
  148. data/lib/bundler/resolver/spec_group.rb +122 -0
  149. data/lib/bundler/retry.rb +11 -5
  150. data/lib/bundler/ruby_dsl.rb +9 -2
  151. data/lib/bundler/ruby_version.rb +84 -61
  152. data/lib/bundler/rubygems_ext.rb +92 -53
  153. data/lib/bundler/rubygems_gem_installer.rb +84 -0
  154. data/lib/bundler/rubygems_integration.rb +320 -395
  155. data/lib/bundler/runtime.rb +87 -75
  156. data/lib/bundler/settings.rb +297 -119
  157. data/lib/bundler/settings/validator.rb +102 -0
  158. data/lib/bundler/setup.rb +13 -12
  159. data/lib/bundler/shared_helpers.rb +234 -53
  160. data/lib/bundler/similarity_detector.rb +5 -3
  161. data/lib/bundler/source.rb +63 -4
  162. data/lib/bundler/source/gemspec.rb +18 -0
  163. data/lib/bundler/source/git.rb +97 -50
  164. data/lib/bundler/source/git/git_proxy.rb +138 -65
  165. data/lib/bundler/source/metadata.rb +67 -0
  166. data/lib/bundler/source/path.rb +83 -47
  167. data/lib/bundler/source/path/installer.rb +42 -11
  168. data/lib/bundler/source/rubygems.rb +231 -116
  169. data/lib/bundler/source/rubygems/remote.rb +30 -1
  170. data/lib/bundler/source_list.rb +103 -21
  171. data/lib/bundler/spec_set.rb +96 -51
  172. data/lib/bundler/stub_specification.rb +87 -4
  173. data/lib/bundler/templates/.document +1 -0
  174. data/lib/bundler/templates/Executable +14 -1
  175. data/lib/bundler/templates/Executable.bundler +114 -0
  176. data/lib/bundler/templates/Executable.standalone +6 -4
  177. data/lib/bundler/templates/Gemfile +4 -1
  178. data/lib/bundler/templates/gems.rb +8 -0
  179. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +79 -44
  180. data/lib/bundler/templates/newgem/Gemfile.tt +18 -2
  181. data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
  182. data/lib/bundler/templates/newgem/README.md.tt +16 -10
  183. data/lib/bundler/templates/newgem/Rakefile.tt +22 -8
  184. data/lib/bundler/templates/newgem/bin/console.tt +2 -1
  185. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  186. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  187. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
  188. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
  189. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +18 -0
  190. data/lib/bundler/templates/newgem/gitignore.tt +5 -1
  191. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  192. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -6
  193. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +6 -4
  194. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -28
  195. data/lib/bundler/templates/newgem/rspec.tt +1 -0
  196. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  197. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +4 -4
  198. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -2
  199. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +3 -1
  200. data/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  201. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  202. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  203. data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
  204. data/lib/bundler/ui.rb +5 -3
  205. data/lib/bundler/ui/rg_proxy.rb +3 -1
  206. data/lib/bundler/ui/shell.rb +54 -21
  207. data/lib/bundler/ui/silent.rb +26 -1
  208. data/lib/bundler/uri_credentials_filter.rb +43 -0
  209. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  210. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  211. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  212. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  213. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1764 -0
  214. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +11 -5
  215. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
  216. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
  217. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +113 -134
  218. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
  219. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
  220. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
  221. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
  222. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
  223. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
  224. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
  225. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +158 -0
  227. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +82 -8
  228. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +4 -1
  229. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +2 -0
  230. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +6 -2
  231. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +555 -150
  232. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +6 -3
  233. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +19 -12
  234. data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +310 -467
  235. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  236. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  237. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  238. data/lib/bundler/vendor/thor/lib/thor.rb +58 -25
  239. data/lib/bundler/vendor/thor/lib/thor/actions.rb +50 -33
  240. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +3 -2
  241. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +5 -3
  242. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +9 -19
  243. data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
  244. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +79 -22
  245. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +33 -20
  246. data/lib/bundler/vendor/thor/lib/thor/base.rb +110 -67
  247. data/lib/bundler/vendor/thor/lib/thor/command.rb +33 -24
  248. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
  249. data/lib/bundler/vendor/thor/lib/thor/error.rb +81 -3
  250. data/lib/bundler/vendor/thor/lib/thor/group.rb +16 -16
  251. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +5 -5
  252. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  253. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
  254. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  255. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  256. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  257. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
  258. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +18 -18
  259. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +60 -26
  260. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +31 -13
  261. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  262. data/lib/bundler/vendor/thor/lib/thor/runner.rb +42 -39
  263. data/lib/bundler/vendor/thor/lib/thor/shell.rb +5 -5
  264. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +109 -39
  265. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +7 -3
  266. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +5 -5
  267. data/lib/bundler/vendor/thor/lib/thor/util.rb +26 -9
  268. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  269. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  270. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  271. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  272. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  273. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  274. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  275. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  276. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  277. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  278. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  279. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  280. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  281. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  282. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  283. data/lib/bundler/vendored_fileutils.rb +4 -0
  284. data/lib/bundler/vendored_molinillo.rb +3 -1
  285. data/lib/bundler/vendored_persistent.rb +45 -9
  286. data/lib/bundler/vendored_thor.rb +8 -3
  287. data/lib/bundler/vendored_tmpdir.rb +4 -0
  288. data/lib/bundler/vendored_uri.rb +4 -0
  289. data/lib/bundler/version.rb +7 -4
  290. data/lib/bundler/version_ranges.rb +122 -0
  291. data/lib/bundler/vlad.rb +8 -2
  292. data/lib/bundler/worker.rb +38 -6
  293. data/lib/bundler/yaml_serializer.rb +89 -0
  294. metadata +164 -158
  295. data/.gitignore +0 -16
  296. data/.rspec +0 -3
  297. data/.rubocop.yml +0 -105
  298. data/.rubocop_todo.yml +0 -120
  299. data/.travis.yml +0 -97
  300. data/CODE_OF_CONDUCT.md +0 -42
  301. data/CONTRIBUTING.md +0 -32
  302. data/DEVELOPMENT.md +0 -118
  303. data/ISSUES.md +0 -96
  304. data/Rakefile +0 -309
  305. data/bin/rake +0 -14
  306. data/bin/rspec +0 -10
  307. data/bin/rubocop +0 -11
  308. data/exe/bundle_ruby +0 -60
  309. data/lib/bundler/cli/package.rb +0 -45
  310. data/lib/bundler/environment.rb +0 -41
  311. data/lib/bundler/gem_path_manipulation.rb +0 -8
  312. data/lib/bundler/gem_remote_fetcher.rb +0 -41
  313. data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
  314. data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +0 -32
  315. data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
  316. data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
  317. data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
  318. data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +0 -20
  319. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -64
  320. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
  321. data/lib/bundler/vendor/net/http/faster.rb +0 -26
  322. data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +0 -128
  323. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -10
  324. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -98
  325. data/man/bundle-config.ronn +0 -187
  326. data/man/bundle-update.ronn +0 -188
  327. data/man/bundle.ronn +0 -98
  328. data/man/index.txt +0 -8
data/LICENSE.md CHANGED
@@ -1,23 +1,22 @@
1
- Portions copyright (c) 2010 Andre Arko
2
- Portions copyright (c) 2009 Engine Yard
1
+ The MIT License
3
2
 
4
- MIT License
3
+ Portions copyright (c) 2010-2019 André Arko
4
+ Portions copyright (c) 2009 Engine Yard
5
5
 
6
- Permission is hereby granted, free of charge, to any person obtaining
7
- a copy of this software and associated documentation files (the
8
- "Software"), to deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify, merge, publish,
10
- distribute, sublicense, and/or sell copies of the Software, and to
11
- permit persons to whom the Software is furnished to do so, subject to
12
- the following conditions:
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
13
12
 
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
16
15
 
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
- [![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
2
- [![Build Status](https://img.shields.io/travis/bundler/bundler/master.svg?style=flat)](https://travis-ci.org/bundler/bundler)
3
- [![Code Climate](https://img.shields.io/codeclimate/github/bundler/bundler.svg?style=flat)](https://codeclimate.com/github/bundler/bundler)
4
- [![Inline docs ](http://inch-ci.org/github/bundler/bundler.svg?style=flat)](http://inch-ci.org/github/bundler/bundler)
1
+ [![Version ](https://img.shields.io/gem/v/bundler.svg?style=flat)](https://rubygems.org/gems/bundler)
2
+ [![Slack ](https://bundler-slackin.herokuapp.com/badge.svg)](https://bundler-slackin.herokuapp.com)
5
3
 
6
4
  # Bundler: a gem to bundle gems
7
5
 
@@ -11,30 +9,54 @@ It does this by managing the gems that the application depends on. Given a list
11
9
 
12
10
  ### Installation and usage
13
11
 
12
+ To install (or update to the latest version):
13
+
14
14
  ```
15
15
  gem install bundler
16
+ ```
17
+
18
+ To install a prerelease version (if one is available), run `gem install bundler --pre`. To uninstall Bundler, run `gem uninstall bundler`.
19
+
20
+ Bundler is most commonly used to manage your application's dependencies. For example, these commands will allow you to use Bundler to manage the `rspec` gem for your application:
21
+
22
+ ```
16
23
  bundle init
17
- echo 'gem "rspec"' >> Gemfile
24
+ bundle add rspec
18
25
  bundle install
19
26
  bundle exec rspec
20
27
  ```
21
28
 
22
- See [bundler.io](http://bundler.io) for the full documentation.
29
+ See [bundler.io](https://bundler.io) for the full documentation.
23
30
 
24
31
  ### Troubleshooting
25
32
 
26
- For help with common problems, see [ISSUES](https://github.com/bundler/bundler/blob/master/ISSUES.md).
33
+ For help with common problems, see [TROUBLESHOOTING](doc/TROUBLESHOOTING.md).
34
+
35
+ Still stuck? Try [filing an issue](doc/contributing/ISSUES.md).
27
36
 
28
37
  ### Other questions
29
38
 
30
- To see what has changed in recent versions of Bundler, see the [CHANGELOG](https://github.com/bundler/bundler/blob/master/CHANGELOG.md).
39
+ To see what has changed in recent versions of Bundler, see the [CHANGELOG](CHANGELOG.md).
31
40
 
32
- Feel free to chat with the Bundler core team (and many other users) on IRC in the [#bundler](irc://irc.freenode.net/bundler) channel on Freenode, or via email on the [Bundler mailing list](http://groups.google.com/group/ruby-bundler).
41
+ To get in touch with the Bundler core team and other Bundler users, please see [getting help](doc/contributing/GETTING_HELP.md).
33
42
 
34
43
  ### Contributing
35
44
 
36
- If you'd like to contribute to Bundler, that's awesome, and we <3 you. There's a guide to contributing to Bundler (both code and general help) over in [DEVELOPMENT](https://github.com/bundler/bundler/blob/master/DEVELOPMENT.md).
45
+ If you'd like to contribute to Bundler, that's awesome, and we <3 you. We've put together [the Bundler contributor guide](https://github.com/rubygems/rubygems/blob/master/bundler/doc/contributing/README.md) with all of the information you need to get started.
46
+
47
+ If you'd like to request a substantial change to Bundler or its documentation, refer to the [Bundler RFC process](https://github.com/bundler/rfcs) for more information.
48
+
49
+ While some Bundler contributors are compensated by Ruby Together, the project maintainers make decisions independent of Ruby Together. As a project, we welcome contributions regardless of the author's affiliation with Ruby Together.
50
+
51
+ ### Supporting
52
+
53
+ <a href="https://rubytogether.org/"><img src="https://rubytogether.org/images/rubies.svg" width="150"></a><br>
54
+ <a href="https://rubytogether.org/">Ruby Together</a> pays some Bundler maintainers for their ongoing work. As a grassroots initiative committed to supporting the critical Ruby infrastructure you rely on, Ruby Together is funded entirely by the Ruby community. Contribute today <a href="https://rubytogether.org/developers">as an individual</a> or (better yet) <a href="https://rubytogether.org/companies">as a company</a> to ensure that Bundler, RubyGems, and other shared tooling is around for years to come.
37
55
 
38
56
  ### Code of Conduct
39
57
 
40
- Everyone interacting in the Bundler projects codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/bundler/bundler/blob/master/CODE_OF_CONDUCT.md).
58
+ Everyone interacting in the Bundler project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [Bundler code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).
59
+
60
+ ### License
61
+
62
+ Bundler is available under an [MIT License](https://github.com/rubygems/rubygems/blob/master/bundler/LICENSE.md).
@@ -1,34 +1,47 @@
1
- # coding: utf-8
2
- lib = File.expand_path("../lib/", __FILE__)
3
- $:.unshift lib unless $:.include?(lib)
4
- require "bundler/version"
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require_relative "lib/bundler/version"
5
+ rescue LoadError
6
+ # for Ruby core repository
7
+ require_relative "version"
8
+ end
5
9
 
6
10
  Gem::Specification.new do |s|
7
11
  s.name = "bundler"
8
12
  s.version = Bundler::VERSION
9
- s.licenses = ["MIT"]
10
- s.authors = ["André Arko", "Terence Lee", "Carl Lerche", "Yehuda Katz"]
11
- s.email = ["andre.arko+terence.lee@gmail.com"]
12
- s.homepage = "http://bundler.io"
13
+ s.license = "MIT"
14
+ s.authors = [
15
+ "André Arko", "Samuel Giddins", "Colby Swandale", "Hiroshi Shibata",
16
+ "David Rodríguez", "Grey Baker", "Stephanie Morillo", "Chris Morris", "James Wen", "Tim Moore",
17
+ "André Medeiros", "Jessica Lynn Suttles", "Terence Lee", "Carl Lerche",
18
+ "Yehuda Katz"
19
+ ]
20
+ s.email = ["team@bundler.io"]
21
+ s.homepage = "https://bundler.io"
13
22
  s.summary = "The best way to manage your application's dependencies"
14
23
  s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably"
15
24
 
16
- s.required_ruby_version = ">= 1.8.7"
17
- s.required_rubygems_version = ">= 1.3.6"
25
+ if s.respond_to?(:metadata=)
26
+ s.metadata = {
27
+ "bug_tracker_uri" => "https://github.com/rubygems/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
28
+ "changelog_uri" => "https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md",
29
+ "homepage_uri" => "https://bundler.io/",
30
+ "source_code_uri" => "https://github.com/rubygems/rubygems/",
31
+ }
32
+ end
33
+
34
+ s.required_ruby_version = ">= 2.3.0"
35
+ s.required_rubygems_version = ">= 2.5.2"
18
36
 
19
- s.add_development_dependency "automatiek", "~> 0.1.0"
20
- s.add_development_dependency "mustache", "0.99.6"
21
- s.add_development_dependency "rake", "~> 10.0"
22
- s.add_development_dependency "rdiscount", "~> 1.6"
23
- s.add_development_dependency "ronn", "~> 0.7.3"
24
- s.add_development_dependency "rspec", "~> 3.0"
37
+ s.files = Dir.glob("{lib,exe}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
25
38
 
26
- s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
27
- # we don't check in man pages, but we need to ship them because
28
- # we use them to generate the long-form help for each command.
29
- s.files += Dir.glob("lib/bundler/man/**/*")
39
+ # Include the CHANGELOG.md, LICENSE.md, README.md manually
40
+ s.files += %w[CHANGELOG.md LICENSE.md README.md]
41
+ # include the gemspec itself because warbler breaks w/o it
42
+ s.files += %w[bundler.gemspec]
30
43
 
31
44
  s.bindir = "exe"
32
- s.executables = %w(bundle bundler)
45
+ s.executables = %w[bundle bundler]
33
46
  s.require_paths = ["lib"]
34
47
  end
data/exe/bundle CHANGED
@@ -1,20 +1,50 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Exit cleanly from an early interrupt
4
- Signal.trap("INT") { exit 1 }
5
+ Signal.trap("INT") do
6
+ Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
7
+ exit 1
8
+ end
9
+
10
+ base_path = File.expand_path("../lib", __dir__)
11
+
12
+ if File.exist?(base_path)
13
+ require_relative "../lib/bundler"
14
+ else
15
+ require "bundler"
16
+ end
17
+
18
+ # Workaround for non-activated bundler spec due to missing https://github.com/rubygems/rubygems/commit/4e306d7bcdee924b8d80ca9db6125aa59ee4e5a3
19
+ gem "bundler", Bundler::VERSION if Gem.rubygems_version < Gem::Version.new("2.6.2")
5
20
 
6
- require "bundler"
7
21
  # Check if an older version of bundler is installed
8
22
  $LOAD_PATH.each do |path|
9
23
  next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
10
- err = "Looks like you have a version of bundler that's older than 0.9.\n"
24
+ err = String.new
25
+ err << "Looks like you have a version of bundler that's older than 0.9.\n"
11
26
  err << "Please remove your old versions.\n"
12
27
  err << "An easy way to do this is by running `gem cleanup bundler`."
13
28
  abort(err)
14
29
  end
15
30
 
16
- require "bundler/friendly_errors"
31
+ if File.exist?(base_path)
32
+ require_relative "../lib/bundler/friendly_errors"
33
+ else
34
+ require "bundler/friendly_errors"
35
+ end
36
+
17
37
  Bundler.with_friendly_errors do
18
- require "bundler/cli"
19
- Bundler::CLI.start(ARGV, :debug => true)
38
+ if File.exist?(base_path)
39
+ require_relative "../lib/bundler/cli"
40
+ else
41
+ require "bundler/cli"
42
+ end
43
+
44
+ # Allow any command to use --help flag to show help for that command
45
+ help_flags = %w[--help -h]
46
+ help_flag_used = ARGV.any? {|a| help_flags.include? a }
47
+ args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
48
+
49
+ Bundler::CLI.start(args, :debug => true)
20
50
  end
@@ -1,20 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- # Exit cleanly from an early interrupt
4
- Signal.trap("INT") { exit 1 }
5
-
6
- require "bundler"
7
- # Check if an older version of bundler is installed
8
- $LOAD_PATH.each do |path|
9
- next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
10
- err = "Looks like you have a version of bundler that's older than 0.9.\n"
11
- err << "Please remove your old versions.\n"
12
- err << "An easy way to do this is by running `gem cleanup bundler`."
13
- abort(err)
14
- end
15
-
16
- require "bundler/friendly_errors"
17
- Bundler.with_friendly_errors do
18
- require "bundler/cli"
19
- Bundler::CLI.start(ARGV, :debug => true)
20
- end
4
+ load File.expand_path("../bundle", __FILE__)
@@ -1,74 +1,101 @@
1
- require "fileutils"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bundler/vendored_fileutils"
2
4
  require "pathname"
3
5
  require "rbconfig"
4
- require "thread"
5
- require "bundler/gem_path_manipulation"
6
- require "bundler/gem_remote_fetcher"
7
- require "bundler/rubygems_ext"
8
- require "bundler/rubygems_integration"
9
- require "bundler/version"
10
- require "bundler/constants"
11
- require "bundler/current_ruby"
12
- require "bundler/errors"
13
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/constants"
14
+ require_relative "bundler/current_ruby"
15
+ require_relative "bundler/build_metadata"
16
+
17
+ # Bundler provides a consistent environment for Ruby projects by
18
+ # tracking and installing the exact gems and versions that are needed.
19
+ #
20
+ # Since Ruby 2.6, Bundler is a part of Ruby's standard library.
21
+ #
22
+ # Bunder is used by creating _gemfiles_ listing all the project dependencies
23
+ # and (optionally) their versions and then using
24
+ #
25
+ # require 'bundler/setup'
26
+ #
27
+ # or Bundler.setup to setup environment where only specified gems and their
28
+ # specified versions could be used.
29
+ #
30
+ # See {Bundler website}[https://bundler.io/docs.html] for extensive documentation
31
+ # on gemfiles creation and Bundler usage.
32
+ #
33
+ # As a standard library inside project, Bundler could be used for introspection
34
+ # of loaded and required modules.
35
+ #
14
36
  module Bundler
15
- preserve_gem_path
16
- ORIGINAL_ENV = ENV.to_hash
37
+ environment_preserver = EnvironmentPreserver.from_env
38
+ ORIGINAL_ENV = environment_preserver.restore
39
+ environment_preserver.replace_with_backup
17
40
  SUDO_MUTEX = Mutex.new
18
41
 
19
- autoload :Definition, "bundler/definition"
20
- autoload :Dependency, "bundler/dependency"
21
- autoload :DepProxy, "bundler/dep_proxy"
22
- autoload :Deprecate, "bundler/deprecate"
23
- autoload :Dsl, "bundler/dsl"
24
- autoload :EndpointSpecification, "bundler/endpoint_specification"
25
- autoload :Environment, "bundler/environment"
26
- autoload :Env, "bundler/env"
27
- autoload :Fetcher, "bundler/fetcher"
28
- autoload :GemHelper, "bundler/gem_helper"
29
- autoload :GemHelpers, "bundler/gem_helpers"
30
- autoload :RubyGemsGemInstaller, "bundler/rubygems_gem_installer"
31
- autoload :Graph, "bundler/graph"
32
- autoload :Index, "bundler/index"
33
- autoload :Installer, "bundler/installer"
34
- autoload :Injector, "bundler/injector"
35
- autoload :LazySpecification, "bundler/lazy_specification"
36
- autoload :LockfileParser, "bundler/lockfile_parser"
37
- autoload :MatchPlatform, "bundler/match_platform"
38
- autoload :RemoteSpecification, "bundler/remote_specification"
39
- autoload :Resolver, "bundler/resolver"
40
- autoload :Retry, "bundler/retry"
41
- autoload :RubyVersion, "bundler/ruby_version"
42
- autoload :RubyDsl, "bundler/ruby_dsl"
43
- autoload :Runtime, "bundler/runtime"
44
- autoload :Settings, "bundler/settings"
45
- autoload :SharedHelpers, "bundler/shared_helpers"
46
- autoload :SpecSet, "bundler/spec_set"
47
- autoload :StubSpecification, "bundler/stub_specification"
48
- autoload :Source, "bundler/source"
49
- autoload :SourceList, "bundler/source_list"
50
- autoload :SystemRubyVersion, "bundler/ruby_version"
51
- autoload :UI, "bundler/ui"
42
+ autoload :Definition, File.expand_path("bundler/definition", __dir__)
43
+ autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
44
+ autoload :DepProxy, File.expand_path("bundler/dep_proxy", __dir__)
45
+ autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
46
+ autoload :Dsl, File.expand_path("bundler/dsl", __dir__)
47
+ autoload :EndpointSpecification, File.expand_path("bundler/endpoint_specification", __dir__)
48
+ autoload :Env, File.expand_path("bundler/env", __dir__)
49
+ autoload :Fetcher, File.expand_path("bundler/fetcher", __dir__)
50
+ autoload :FeatureFlag, File.expand_path("bundler/feature_flag", __dir__)
51
+ autoload :GemHelper, File.expand_path("bundler/gem_helper", __dir__)
52
+ autoload :GemHelpers, File.expand_path("bundler/gem_helpers", __dir__)
53
+ autoload :GemVersionPromoter, File.expand_path("bundler/gem_version_promoter", __dir__)
54
+ autoload :Graph, File.expand_path("bundler/graph", __dir__)
55
+ autoload :Index, File.expand_path("bundler/index", __dir__)
56
+ autoload :Injector, File.expand_path("bundler/injector", __dir__)
57
+ autoload :Installer, File.expand_path("bundler/installer", __dir__)
58
+ autoload :LazySpecification, File.expand_path("bundler/lazy_specification", __dir__)
59
+ autoload :LockfileParser, File.expand_path("bundler/lockfile_parser", __dir__)
60
+ autoload :MatchPlatform, File.expand_path("bundler/match_platform", __dir__)
61
+ autoload :ProcessLock, File.expand_path("bundler/process_lock", __dir__)
62
+ autoload :RemoteSpecification, File.expand_path("bundler/remote_specification", __dir__)
63
+ autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
64
+ autoload :Retry, File.expand_path("bundler/retry", __dir__)
65
+ autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
66
+ autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
67
+ autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
68
+ autoload :Settings, File.expand_path("bundler/settings", __dir__)
69
+ autoload :SharedHelpers, File.expand_path("bundler/shared_helpers", __dir__)
70
+ autoload :Source, File.expand_path("bundler/source", __dir__)
71
+ autoload :SourceList, File.expand_path("bundler/source_list", __dir__)
72
+ autoload :SpecSet, File.expand_path("bundler/spec_set", __dir__)
73
+ autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
74
+ autoload :UI, File.expand_path("bundler/ui", __dir__)
75
+ autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
76
+ autoload :VersionRanges, File.expand_path("bundler/version_ranges", __dir__)
52
77
 
53
78
  class << self
54
- attr_writer :bundle_path
55
-
56
79
  def configure
57
80
  @configured ||= configure_gem_home_and_path
58
81
  end
59
82
 
60
83
  def ui
61
- (defined?(@ui) && @ui) || (self.ui = UI::Silent.new)
84
+ (defined?(@ui) && @ui) || (self.ui = UI::Shell.new)
62
85
  end
63
86
 
64
87
  def ui=(ui)
65
- Bundler.rubygems.ui = ui ? UI::RGProxy.new(ui) : nil
88
+ Bundler.rubygems.ui = UI::RGProxy.new(ui)
66
89
  @ui = ui
67
90
  end
68
91
 
69
92
  # Returns absolute path of where gems are installed on the filesystem.
70
93
  def bundle_path
71
- @bundle_path ||= Pathname.new(settings.path).expand_path(root)
94
+ @bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
95
+ end
96
+
97
+ def configured_bundle_path
98
+ @configured_bundle_path ||= settings.path.tap(&:validate!)
72
99
  end
73
100
 
74
101
  # Returns absolute location of where binstubs are installed to.
@@ -81,11 +108,40 @@ module Bundler
81
108
  end
82
109
  end
83
110
 
111
+ # Turns on the Bundler runtime. After +Bundler.setup+ call, all +load+ or
112
+ # +require+ of the gems would be allowed only if they are part of
113
+ # the Gemfile or Ruby's standard library. If the versions specified
114
+ # in Gemfile, only those versions would be loaded.
115
+ #
116
+ # Assuming Gemfile
117
+ #
118
+ # gem 'first_gem', '= 1.0'
119
+ # group :test do
120
+ # gem 'second_gem', '= 1.0'
121
+ # end
122
+ #
123
+ # The code using Bundler.setup works as follows:
124
+ #
125
+ # require 'third_gem' # allowed, required from global gems
126
+ # require 'first_gem' # allowed, loads the last installed version
127
+ # Bundler.setup
128
+ # require 'fourth_gem' # fails with LoadError
129
+ # require 'second_gem' # loads exactly version 1.0
130
+ #
131
+ # +Bundler.setup+ can be called only once, all subsequent calls are no-op.
132
+ #
133
+ # If _groups_ list is provided, only gems from specified groups would
134
+ # be allowed (gems specified outside groups belong to special +:default+ group).
135
+ #
136
+ # To require all gems from Gemfile (or only some groups), see Bundler.require.
137
+ #
84
138
  def setup(*groups)
85
- # Just return if all groups are already loaded
86
- return @setup if defined?(@setup)
139
+ # Return if all groups are already loaded
140
+ return @setup if defined?(@setup) && @setup
141
+
142
+ definition.validate_runtime!
87
143
 
88
- definition.validate_ruby!
144
+ SharedHelpers.print_major_deprecations!
89
145
 
90
146
  if groups.empty?
91
147
  # Load all groups, but only once
@@ -95,6 +151,24 @@ module Bundler
95
151
  end
96
152
  end
97
153
 
154
+ # Setups Bundler environment (see Bundler.setup) if it is not already set,
155
+ # and loads all gems from groups specified. Unlike ::setup, can be called
156
+ # multiple times with different groups (if they were allowed by setup).
157
+ #
158
+ # Assuming Gemfile
159
+ #
160
+ # gem 'first_gem', '= 1.0'
161
+ # group :test do
162
+ # gem 'second_gem', '= 1.0'
163
+ # end
164
+ #
165
+ # The code will work as follows:
166
+ #
167
+ # Bundler.setup # allow all groups
168
+ # Bundler.require(:default) # requires only first_gem
169
+ # # ...later
170
+ # Bundler.require(:test) # requires second_gem
171
+ #
98
172
  def require(*groups)
99
173
  setup(*groups).require(*groups)
100
174
  end
@@ -104,7 +178,8 @@ module Bundler
104
178
  end
105
179
 
106
180
  def environment
107
- Bundler::Environment.new(root, definition)
181
+ SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true
182
+ load
108
183
  end
109
184
 
110
185
  # Returns an instance of Bundler::Definition for given Gemfile and lockfile
@@ -116,27 +191,79 @@ module Bundler
116
191
  @definition = nil if unlock
117
192
  @definition ||= begin
118
193
  configure
119
- upgrade_lockfile
120
194
  Definition.build(default_gemfile, default_lockfile, unlock)
121
195
  end
122
196
  end
123
197
 
198
+ def frozen_bundle?
199
+ frozen = settings[:deployment]
200
+ frozen ||= settings[:frozen] unless feature_flag.deployment_means_frozen?
201
+ frozen
202
+ end
203
+
124
204
  def locked_gems
125
- return @locked_gems if defined?(@locked_gems)
126
- if Bundler.default_lockfile.exist?
127
- lock = Bundler.read_file(Bundler.default_lockfile)
128
- @locked_gems = LockfileParser.new(lock)
129
- else
130
- @locked_gems = nil
131
- end
205
+ @locked_gems ||=
206
+ if defined?(@definition) && @definition
207
+ definition.locked_gems
208
+ elsif Bundler.default_lockfile.file?
209
+ lock = Bundler.read_file(Bundler.default_lockfile)
210
+ LockfileParser.new(lock)
211
+ end
212
+ end
213
+
214
+ def most_specific_locked_platform?(platform)
215
+ return false unless defined?(@definition) && @definition
216
+
217
+ definition.most_specific_locked_platform == platform
132
218
  end
133
219
 
134
220
  def ruby_scope
135
- "#{Bundler.rubygems.ruby_engine}/#{Bundler.rubygems.config_map[:ruby_version]}"
221
+ "#{Bundler.rubygems.ruby_engine}/#{RbConfig::CONFIG["ruby_version"]}"
136
222
  end
137
223
 
138
- def user_bundle_path
139
- Pathname.new(Bundler.rubygems.user_home).join(".bundler")
224
+ def user_home
225
+ @user_home ||= begin
226
+ home = Bundler.rubygems.user_home
227
+ bundle_home = home ? File.join(home, ".bundle") : nil
228
+
229
+ warning = if home.nil?
230
+ "Your home directory is not set."
231
+ elsif !File.directory?(home)
232
+ "`#{home}` is not a directory."
233
+ elsif !File.writable?(home) && (!File.directory?(bundle_home) || !File.writable?(bundle_home))
234
+ "`#{home}` is not writable."
235
+ end
236
+
237
+ if warning
238
+ user_home = tmp_home_path(warning)
239
+ Bundler.ui.warn "#{warning}\nBundler will use `#{user_home}' as your home directory temporarily.\n"
240
+ user_home
241
+ else
242
+ Pathname.new(home)
243
+ end
244
+ end
245
+ end
246
+
247
+ def user_bundle_path(dir = "home")
248
+ env_var, fallback = case dir
249
+ when "home"
250
+ ["BUNDLE_USER_HOME", proc { Pathname.new(user_home).join(".bundle") }]
251
+ when "cache"
252
+ ["BUNDLE_USER_CACHE", proc { user_bundle_path.join("cache") }]
253
+ when "config"
254
+ ["BUNDLE_USER_CONFIG", proc { user_bundle_path.join("config") }]
255
+ when "plugin"
256
+ ["BUNDLE_USER_PLUGIN", proc { user_bundle_path.join("plugin") }]
257
+ else
258
+ raise BundlerError, "Unknown user path requested: #{dir}"
259
+ end
260
+ # `fallback` will already be a Pathname, but Pathname.new() is
261
+ # idempotent so it's OK
262
+ Pathname.new(ENV.fetch(env_var, &fallback))
263
+ end
264
+
265
+ def user_cache
266
+ user_bundle_path("cache")
140
267
  end
141
268
 
142
269
  def home
@@ -151,13 +278,9 @@ module Bundler
151
278
  bundle_path.join("specifications")
152
279
  end
153
280
 
154
- def cache
155
- bundle_path.join("cache/bundler")
156
- end
157
-
158
281
  def root
159
282
  @root ||= begin
160
- default_gemfile.dirname.expand_path
283
+ SharedHelpers.root
161
284
  rescue GemfileNotFound
162
285
  bundle_dir = default_bundle_dir
163
286
  raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
@@ -166,8 +289,14 @@ module Bundler
166
289
  end
167
290
 
168
291
  def app_config_path
169
- if ENV["BUNDLE_APP_CONFIG"]
170
- Pathname.new(ENV["BUNDLE_APP_CONFIG"]).expand_path(root)
292
+ if app_config = ENV["BUNDLE_APP_CONFIG"]
293
+ app_config_pathname = Pathname.new(app_config)
294
+
295
+ if app_config_pathname.absolute?
296
+ app_config_pathname
297
+ else
298
+ app_config_pathname.expand_path(root)
299
+ end
171
300
  else
172
301
  root.join(".bundle")
173
302
  end
@@ -175,57 +304,144 @@ module Bundler
175
304
 
176
305
  def app_cache(custom_path = nil)
177
306
  path = custom_path || root
178
- path.join(settings.app_cache_path)
307
+ Pathname.new(path).join(settings.app_cache_path)
179
308
  end
180
309
 
181
310
  def tmp(name = Process.pid.to_s)
311
+ Kernel.send(:require, "tmpdir")
182
312
  Pathname.new(Dir.mktmpdir(["bundler", name]))
183
313
  end
184
314
 
185
315
  def rm_rf(path)
186
316
  FileUtils.remove_entry_secure(path) if path && File.exist?(path)
317
+ rescue ArgumentError
318
+ message = <<EOF
319
+ It is a security vulnerability to allow your home directory to be world-writable, and bundler can not continue.
320
+ You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
321
+ Please refer to https://ruby-doc.org/stdlib-2.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
322
+ EOF
323
+ File.world_writable?(path) ? Bundler.ui.warn(message) : raise
324
+ raise PathError, "Please fix the world-writable issue with your #{path} directory"
187
325
  end
188
326
 
189
327
  def settings
190
- return @settings if defined?(@settings)
191
- @settings = Settings.new(app_config_path)
328
+ @settings ||= Settings.new(app_config_path)
192
329
  rescue GemfileNotFound
193
330
  @settings = Settings.new(Pathname.new(".bundle").expand_path)
194
331
  end
195
332
 
333
+ # @return [Hash] Environment present before Bundler was activated
334
+ def original_env
335
+ ORIGINAL_ENV.clone
336
+ end
337
+
338
+ # @deprecated Use `unbundled_env` instead
339
+ def clean_env
340
+ Bundler::SharedHelpers.major_deprecation(
341
+ 2,
342
+ "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
343
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`",
344
+ :print_caller_location => true
345
+ )
346
+
347
+ unbundled_env
348
+ end
349
+
350
+ # @return [Hash] Environment with all bundler-related variables removed
351
+ def unbundled_env
352
+ env = original_env
353
+
354
+ if env.key?("BUNDLER_ORIG_MANPATH")
355
+ env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
356
+ end
357
+
358
+ env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
359
+
360
+ if env.key?("RUBYOPT")
361
+ rubyopt = env["RUBYOPT"].split(" ")
362
+ rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
363
+ rubyopt.delete("-rbundler/setup")
364
+ env["RUBYOPT"] = rubyopt.join(" ")
365
+ end
366
+
367
+ if env.key?("RUBYLIB")
368
+ rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
369
+ rubylib.delete(File.expand_path("..", __FILE__))
370
+ env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
371
+ end
372
+
373
+ env
374
+ end
375
+
376
+ # Run block with environment present before Bundler was activated
196
377
  def with_original_env
197
- bundled_env = ENV.to_hash
198
- ENV.replace(ORIGINAL_ENV)
199
- yield
200
- ensure
201
- ENV.replace(bundled_env.to_hash)
378
+ with_env(original_env) { yield }
202
379
  end
203
380
 
381
+ # @deprecated Use `with_unbundled_env` instead
204
382
  def with_clean_env
205
- with_original_env do
206
- ENV["MANPATH"] = ENV["BUNDLE_ORIG_MANPATH"]
207
- ENV.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
383
+ Bundler::SharedHelpers.major_deprecation(
384
+ 2,
385
+ "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
386
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`",
387
+ :print_caller_location => true
388
+ )
208
389
 
209
- if ENV.key?("RUBYOPT")
210
- ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-rbundler/setup", ""
211
- end
390
+ with_env(unbundled_env) { yield }
391
+ end
212
392
 
213
- if ENV.key?("RUBYLIB")
214
- rubylib = ENV["RUBYLIB"].split(File::PATH_SEPARATOR)
215
- rubylib.delete(File.expand_path("..", __FILE__))
216
- ENV["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
217
- end
393
+ # Run block with all bundler-related variables removed
394
+ def with_unbundled_env
395
+ with_env(unbundled_env) { yield }
396
+ end
218
397
 
219
- yield
220
- end
398
+ # Run subcommand with the environment present before Bundler was activated
399
+ def original_system(*args)
400
+ with_original_env { Kernel.system(*args) }
221
401
  end
222
402
 
403
+ # @deprecated Use `unbundled_system` instead
223
404
  def clean_system(*args)
224
- with_clean_env { Kernel.system(*args) }
405
+ Bundler::SharedHelpers.major_deprecation(
406
+ 2,
407
+ "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
408
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`",
409
+ :print_caller_location => true
410
+ )
411
+
412
+ with_env(unbundled_env) { Kernel.system(*args) }
413
+ end
414
+
415
+ # Run subcommand in an environment with all bundler related variables removed
416
+ def unbundled_system(*args)
417
+ with_unbundled_env { Kernel.system(*args) }
418
+ end
419
+
420
+ # Run a `Kernel.exec` to a subcommand with the environment present before Bundler was activated
421
+ def original_exec(*args)
422
+ with_original_env { Kernel.exec(*args) }
225
423
  end
226
424
 
425
+ # @deprecated Use `unbundled_exec` instead
227
426
  def clean_exec(*args)
228
- with_clean_env { Kernel.exec(*args) }
427
+ Bundler::SharedHelpers.major_deprecation(
428
+ 2,
429
+ "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
430
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`",
431
+ :print_caller_location => true
432
+ )
433
+
434
+ with_env(unbundled_env) { Kernel.exec(*args) }
435
+ end
436
+
437
+ # Run a `Kernel.exec` to a subcommand in an environment with all bundler related variables removed
438
+ def unbundled_exec(*args)
439
+ with_env(unbundled_env) { Kernel.exec(*args) }
440
+ end
441
+
442
+ def local_platform
443
+ return Gem::Platform::RUBY if settings[:force_ruby_platform]
444
+ Gem::Platform.local
229
445
  end
230
446
 
231
447
  def default_gemfile
@@ -241,21 +457,29 @@ module Bundler
241
457
  end
242
458
 
243
459
  def system_bindir
244
- # Gem.bindir doesn't always return the location that Rubygems will install
245
- # system binaries. If you put '-n foo' in your .gemrc, Rubygems will
246
- # install binstubs there instead. Unfortunately, Rubygems doesn't expose
460
+ # Gem.bindir doesn't always return the location that RubyGems will install
461
+ # system binaries. If you put '-n foo' in your .gemrc, RubyGems will
462
+ # install binstubs there instead. Unfortunately, RubyGems doesn't expose
247
463
  # that directory at all, so rather than parse .gemrc ourselves, we allow
248
- # the directory to be set as well, via `bundle config bindir foo`.
464
+ # the directory to be set as well, via `bundle config set --local bindir foo`.
249
465
  Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
250
466
  end
251
467
 
468
+ def preferred_gemfile_name
469
+ Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
470
+ end
471
+
472
+ def use_system_gems?
473
+ configured_bundle_path.use_system_gems?
474
+ end
475
+
252
476
  def requires_sudo?
253
477
  return @requires_sudo if defined?(@requires_sudo_ran)
254
478
 
255
479
  sudo_present = which "sudo" if settings.allow_sudo?
256
480
 
257
481
  if sudo_present
258
- # the bundle path and subdirectories need to be writable for Rubygems
482
+ # the bundle path and subdirectories need to be writable for RubyGems
259
483
  # to be able to unpack and install gems without exploding
260
484
  path = bundle_path
261
485
  path = path.parent until path.exist?
@@ -265,16 +489,20 @@ module Bundler
265
489
  bin_dir = bin_dir.parent until bin_dir.exist?
266
490
 
267
491
  # if any directory is not writable, we need sudo
268
- files = [path, bin_dir] | Dir[path.join("build_info/*").to_s] | Dir[path.join("*").to_s]
269
- sudo_needed = files.any? {|f| !File.writable?(f) }
492
+ files = [path, bin_dir] | Dir[bundle_path.join("build_info/*").to_s] | Dir[bundle_path.join("*").to_s]
493
+ unwritable_files = files.reject {|f| File.writable?(f) }
494
+ sudo_needed = !unwritable_files.empty?
495
+ if sudo_needed
496
+ Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).sort.join("\n ")}"
497
+ end
270
498
  end
271
499
 
272
500
  @requires_sudo_ran = true
273
501
  @requires_sudo = settings.allow_sudo? && sudo_present && sudo_needed
274
502
  end
275
503
 
276
- def mkdir_p(path)
277
- if requires_sudo?
504
+ def mkdir_p(path, options = {})
505
+ if requires_sudo? && !options[:no_sudo]
278
506
  sudo "mkdir -p '#{path}'" unless File.exist?(path)
279
507
  else
280
508
  SharedHelpers.filesystem_access(path, :write) do |p|
@@ -286,40 +514,50 @@ module Bundler
286
514
  def which(executable)
287
515
  if File.file?(executable) && File.executable?(executable)
288
516
  executable
289
- elsif ENV["PATH"]
290
- path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |p|
291
- abs_path = File.join(p, executable)
292
- File.file?(abs_path) && File.executable?(abs_path)
517
+ elsif paths = ENV["PATH"]
518
+ quote = '"'.freeze
519
+ paths.split(File::PATH_SEPARATOR).find do |path|
520
+ path = path[1..-2] if path.start_with?(quote) && path.end_with?(quote)
521
+ executable_path = File.expand_path(executable, path)
522
+ return executable_path if File.file?(executable_path) && File.executable?(executable_path)
293
523
  end
294
- path && File.expand_path(executable, path)
295
524
  end
296
525
  end
297
526
 
298
527
  def sudo(str)
299
528
  SUDO_MUTEX.synchronize do
300
529
  prompt = "\n\n" + <<-PROMPT.gsub(/^ {6}/, "").strip + " "
301
- Your user account isn't allowed to install to the system Rubygems.
530
+ Your user account isn't allowed to install to the system RubyGems.
302
531
  You can cancel this installation and run:
303
532
 
304
- bundle install --path vendor/bundle
533
+ bundle config set --local path 'vendor/bundle'
534
+ bundle install
305
535
 
306
536
  to install the gems into ./vendor/bundle/, or you can enter your password
307
- and install the bundled gems to Rubygems using sudo.
537
+ and install the bundled gems to RubyGems using sudo.
308
538
 
309
539
  Password:
310
540
  PROMPT
311
541
 
542
+ unless @prompted_for_sudo ||= system(%(sudo -k -p "#{prompt}" true))
543
+ raise SudoNotPermittedError,
544
+ "Bundler requires sudo access to install at the moment. " \
545
+ "Try installing again, granting Bundler sudo access when prompted, or installing into a different path."
546
+ end
547
+
312
548
  `sudo -p "#{prompt}" #{str}`
313
549
  end
314
550
  end
315
551
 
316
552
  def read_file(file)
317
- File.open(file, "rb", &:read)
553
+ SharedHelpers.filesystem_access(file, :read) do
554
+ File.open(file, "r:UTF-8", &:read)
555
+ end
318
556
  end
319
557
 
320
558
  def load_marshal(data)
321
559
  Marshal.load(data)
322
- rescue => e
560
+ rescue StandardError => e
323
561
  raise MarshalError, "#{e.class}: #{e.message}"
324
562
  end
325
563
 
@@ -334,22 +572,20 @@ module Bundler
334
572
 
335
573
  def load_gemspec_uncached(file, validate = false)
336
574
  path = Pathname.new(file)
337
- # Eval the gemspec from its parent directory, because some gemspecs
338
- # depend on "./" relative paths.
339
- SharedHelpers.chdir(path.dirname.to_s) do
340
- contents = path.read
341
- if contents[0..2] == "---" # YAML header
342
- spec = eval_yaml_gemspec(path, contents)
343
- else
344
- spec = eval_gemspec(path, contents)
575
+ contents = read_file(file)
576
+ spec = if contents.start_with?("---") # YAML header
577
+ eval_yaml_gemspec(path, contents)
578
+ else
579
+ # Eval the gemspec from its parent directory, because some gemspecs
580
+ # depend on "./" relative paths.
581
+ SharedHelpers.chdir(path.dirname.to_s) do
582
+ eval_gemspec(path, contents)
345
583
  end
346
- Bundler.rubygems.validate(spec) if spec && validate
347
- spec
348
584
  end
349
- rescue Gem::InvalidSpecificationException => e
350
- UI::Shell.new.warn "The gemspec at #{file} is not valid. " \
351
- "The validation error was '#{e.message}'"
352
- nil
585
+ return unless spec
586
+ spec.loaded_from = path.expand_path.to_s
587
+ Bundler.rubygems.validate(spec) if validate
588
+ spec
353
589
  end
354
590
 
355
591
  def clear_gemspec_cache
@@ -361,17 +597,48 @@ module Bundler
361
597
  @git_present = Bundler.which("git") || Bundler.which("git.exe")
362
598
  end
363
599
 
364
- def ruby_version
365
- @ruby_version ||= SystemRubyVersion.new
600
+ def feature_flag
601
+ @feature_flag ||= FeatureFlag.new(VERSION)
366
602
  end
367
603
 
368
604
  def reset!
605
+ reset_paths!
606
+ Plugin.reset!
607
+ reset_rubygems!
608
+ end
609
+
610
+ def reset_settings_and_root!
611
+ @settings = nil
612
+ @root = nil
613
+ end
614
+
615
+ def reset_paths!
616
+ @bin_path = nil
617
+ @bundler_major_version = nil
618
+ @bundle_path = nil
619
+ @configured = nil
620
+ @configured_bundle_path = nil
369
621
  @definition = nil
622
+ @load = nil
623
+ @locked_gems = nil
624
+ @root = nil
625
+ @settings = nil
626
+ @setup = nil
627
+ @user_home = nil
628
+ end
629
+
630
+ def reset_rubygems!
631
+ return unless defined?(@rubygems) && @rubygems
632
+ rubygems.undo_replacements
633
+ rubygems.reset
634
+ @rubygems = nil
370
635
  end
371
636
 
372
- private
637
+ private
373
638
 
374
639
  def eval_yaml_gemspec(path, contents)
640
+ require_relative "bundler/psyched_yaml"
641
+
375
642
  # If the YAML is invalid, Syck raises an ArgumentError, and Psych
376
643
  # raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
377
644
  Gem::Specification.from_yaml(contents)
@@ -380,52 +647,60 @@ module Bundler
380
647
  end
381
648
 
382
649
  def eval_gemspec(path, contents)
383
- eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
650
+ eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
384
651
  rescue ScriptError, StandardError => e
385
- original_line = e.backtrace.find {|line| line.include?(path.to_s) }
386
- msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
387
- msg << " from\n #{original_line}" if original_line
388
- msg << "\n"
652
+ msg = "There was an error while loading `#{path.basename}`: #{e.message}"
389
653
 
390
- if e.is_a?(LoadError) && RUBY_VERSION >= "1.9"
391
- msg << "\nDoes it try to require a relative path? That's been removed in Ruby 1.9."
654
+ if e.is_a?(LoadError)
655
+ msg += "\nDoes it try to require a relative path? That's been removed in Ruby 1.9"
392
656
  end
393
657
 
394
- raise GemspecError, msg
658
+ raise GemspecError, Dsl::DSLError.new(msg, path, e.backtrace, contents)
395
659
  end
396
660
 
397
661
  def configure_gem_home_and_path
398
- blank_home = ENV["GEM_HOME"].nil? || ENV["GEM_HOME"].empty?
399
- if settings[:disable_shared_gems]
400
- ENV["GEM_PATH"] = ""
401
- elsif blank_home || Bundler.rubygems.gem_dir != bundle_path.to_s
402
- possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
403
- paths = possibles.flatten.compact.uniq.reject(&:empty?)
404
- ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
405
- end
406
-
662
+ configure_gem_path
407
663
  configure_gem_home
408
664
  bundle_path
409
665
  end
410
666
 
411
- def configure_gem_home
412
- # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
413
- begin
414
- FileUtils.mkdir_p bundle_path.to_s
415
- rescue
416
- nil
667
+ def configure_gem_path(env = ENV)
668
+ blank_home = env["GEM_HOME"].nil? || env["GEM_HOME"].empty?
669
+ if !use_system_gems?
670
+ # this needs to be empty string to cause
671
+ # PathSupport.split_gem_path to only load up the
672
+ # Bundler --path setting as the GEM_PATH.
673
+ env["GEM_PATH"] = ""
674
+ elsif blank_home
675
+ possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
676
+ paths = possibles.flatten.compact.uniq.reject(&:empty?)
677
+ env["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
417
678
  end
679
+ end
418
680
 
419
- ENV["GEM_HOME"] = File.expand_path(bundle_path, root)
681
+ def configure_gem_home
682
+ Bundler::SharedHelpers.set_env "GEM_HOME", File.expand_path(bundle_path, root)
420
683
  Bundler.rubygems.clear_paths
421
684
  end
422
685
 
423
- def upgrade_lockfile
424
- lockfile = default_lockfile
425
- if lockfile.exist? && lockfile.read(3) == "---"
426
- Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
427
- lockfile.rmtree
686
+ def tmp_home_path(warning)
687
+ Kernel.send(:require, "tmpdir")
688
+ SharedHelpers.filesystem_access(Dir.tmpdir) do
689
+ path = Bundler.tmp
690
+ at_exit { Bundler.rm_rf(path) }
691
+ path
428
692
  end
693
+ rescue RuntimeError => e
694
+ raise e.exception("#{warning}\nBundler also failed to create a temporary home directory':\n#{e}")
695
+ end
696
+
697
+ # @param env [Hash]
698
+ def with_env(env)
699
+ backup = ENV.to_hash
700
+ ENV.replace(env)
701
+ yield
702
+ ensure
703
+ ENV.replace(backup)
429
704
  end
430
705
  end
431
706
  end