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
@@ -1,10 +1,17 @@
1
- require "digest/sha1"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Bundler
4
- class Runtime < Environment
4
+ class Runtime
5
5
  include SharedHelpers
6
6
 
7
+ def initialize(root, definition)
8
+ @root = root
9
+ @definition = definition
10
+ end
11
+
7
12
  def setup(*groups)
13
+ @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
14
+
8
15
  groups.map!(&:to_sym)
9
16
 
10
17
  # Has to happen first
@@ -12,56 +19,38 @@ module Bundler
12
19
 
13
20
  specs = groups.any? ? @definition.specs_for(groups) : requested_specs
14
21
 
15
- setup_environment
22
+ SharedHelpers.set_bundle_environment
16
23
  Bundler.rubygems.replace_entrypoints(specs)
17
24
 
18
25
  # Activate the specs
19
- specs.each do |spec|
26
+ load_paths = specs.map do |spec|
20
27
  unless spec.loaded_from
21
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
28
+ raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
22
29
  end
23
30
 
24
- if (activated_spec = Bundler.rubygems.loaded_specs(spec.name)) && activated_spec.version != spec.version
25
- e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
26
- "but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
27
- "`bundle exec` to your command may solve this."
28
- e.name = spec.name
29
- if e.respond_to?(:requirement=)
30
- e.requirement = Gem::Requirement.new(spec.version.to_s)
31
- else
32
- e.version_requirement = Gem::Requirement.new(spec.version.to_s)
33
- end
34
- raise e
35
- end
31
+ check_for_activated_spec!(spec)
36
32
 
37
33
  Bundler.rubygems.mark_loaded(spec)
38
- load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
39
- $LOAD_PATH.unshift(*load_paths)
40
- end
34
+ spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
35
+ end.reverse.flatten
36
+
37
+ Bundler.rubygems.add_to_load_path(load_paths)
41
38
 
42
39
  setup_manpath
43
40
 
44
- lock(:preserve_bundled_with => true)
41
+ lock(:preserve_unknown_sections => true)
45
42
 
46
43
  self
47
44
  end
48
45
 
49
- REQUIRE_ERRORS = [
50
- /^no such file to load -- (.+)$/i,
51
- /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
52
- /^Missing API definition file in (.+)$/i,
53
- /^cannot load such file -- (.+)$/i,
54
- /^dlopen\([^)]*\): Library not loaded: (.+)$/i,
55
- ]
56
-
57
46
  def require(*groups)
58
47
  groups.map!(&:to_sym)
59
48
  groups = [:default] if groups.empty?
60
49
 
61
50
  @definition.dependencies.each do |dep|
62
- # Skip the dependency if it is not in any of the requested
63
- # groups
64
- next unless (dep.groups & groups).any? && dep.current_platform?
51
+ # Skip the dependency if it is not in any of the requested groups, or
52
+ # not for the current platform, or doesn't match the gem constraints.
53
+ next unless (dep.groups & groups).any? && dep.should_include?
65
54
 
66
55
  required_file = nil
67
56
 
@@ -75,36 +64,45 @@ module Bundler
75
64
  required_file = file
76
65
  begin
77
66
  Kernel.require file
78
- rescue => e
67
+ rescue RuntimeError => e
79
68
  raise e if e.is_a?(LoadError) # we handle this a little later
80
69
  raise Bundler::GemRequireError.new e,
81
70
  "There was an error while trying to load the gem '#{file}'."
82
71
  end
83
72
  end
84
73
  rescue LoadError => e
85
- REQUIRE_ERRORS.find {|r| r =~ e.message }
86
- raise if dep.autorequire || $1 != required_file
74
+ raise if dep.autorequire || e.path != required_file
87
75
 
88
76
  if dep.autorequire.nil? && dep.name.include?("-")
89
77
  begin
90
78
  namespaced_file = dep.name.tr("-", "/")
91
79
  Kernel.require namespaced_file
92
80
  rescue LoadError => e
93
- REQUIRE_ERRORS.find {|r| r =~ e.message }
94
- raise if $1 != namespaced_file
81
+ raise if e.path != namespaced_file
95
82
  end
96
83
  end
97
84
  end
98
85
  end
99
86
  end
100
87
 
101
- def dependencies_for(*groups)
102
- if groups.empty?
103
- dependencies
104
- else
105
- dependencies.select {|d| (groups & d.groups).any? }
88
+ def self.definition_method(meth)
89
+ define_method(meth) do
90
+ raise ArgumentError, "no definition when calling Runtime##{meth}" unless @definition
91
+ @definition.send(meth)
106
92
  end
107
93
  end
94
+ private_class_method :definition_method
95
+
96
+ definition_method :requested_specs
97
+ definition_method :specs
98
+ definition_method :dependencies
99
+ definition_method :current_dependencies
100
+ definition_method :requires
101
+
102
+ def lock(opts = {})
103
+ return if @definition.nothing_changed? && !@definition.unlocking?
104
+ @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
105
+ end
108
106
 
109
107
  alias_method :gems, :specs
110
108
 
@@ -116,15 +114,10 @@ module Bundler
116
114
 
117
115
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
118
116
 
119
- # Do not try to cache specification for the gem described by the .gemspec
120
- root_gem_name = nil
121
- if gemspec_cache_hash = Bundler.instance_variable_get(:@gemspec_cache)
122
- gemspec = gemspec_cache_hash.values.first
123
- root_gem_name = gemspec.name unless gemspec.nil?
124
- end
125
- specs.each do |spec|
117
+ specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
118
+ specs_to_cache.each do |spec|
126
119
  next if spec.name == "bundler"
127
- next if File.exist?("#{root_gem_name}.gemspec") && spec.source.class == Bundler::Source::Path && root_gem_name && spec.name == root_gem_name
120
+ next if spec.source.is_a?(Source::Gemspec)
128
121
  spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
129
122
  spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
130
123
  end
@@ -153,6 +146,7 @@ module Bundler
153
146
  gem_dirs = Dir["#{Gem.dir}/gems/*"]
154
147
  gem_files = Dir["#{Gem.dir}/cache/*.gem"]
155
148
  gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
149
+ extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"] + Dir["#{Gem.dir}/bundler/gems/extensions/*/*/*"]
156
150
  spec_gem_paths = []
157
151
  # need to keep git sources around
158
152
  spec_git_paths = @definition.spec_git_paths
@@ -160,7 +154,8 @@ module Bundler
160
154
  spec_gem_executables = []
161
155
  spec_cache_paths = []
162
156
  spec_gemspec_paths = []
163
- specs.each do |spec|
157
+ spec_extension_paths = []
158
+ Bundler.rubygems.add_default_gems_to(specs).values.each do |spec|
164
159
  spec_gem_paths << spec.full_gem_path
165
160
  # need to check here in case gems are nested like for the rails git repo
166
161
  md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
@@ -171,6 +166,7 @@ module Bundler
171
166
  end
172
167
  spec_cache_paths << spec.cache_file
173
168
  spec_gemspec_paths << spec.spec_file
169
+ spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
174
170
  spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
175
171
  end
176
172
  spec_gem_paths.uniq!
@@ -182,6 +178,7 @@ module Bundler
182
178
  stale_gem_dirs = gem_dirs - spec_gem_paths
183
179
  stale_gem_files = gem_files - spec_cache_paths
184
180
  stale_gemspec_files = gemspec_files - spec_gemspec_paths
181
+ stale_extension_dirs = extension_dirs - spec_extension_paths
185
182
 
186
183
  removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
187
184
  removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
@@ -189,27 +186,24 @@ module Bundler
189
186
 
190
187
  unless dry_run
191
188
  stale_files = stale_gem_bins + stale_gem_files + stale_gemspec_files
192
- stale_files.each {|file| FileUtils.rm(file) if File.exist?(file) }
193
- stale_git_cache_dirs.each {|dir| FileUtils.rm_rf(dir) if File.exist?(dir) }
194
- end
195
-
196
- output
197
- end
189
+ stale_files.each do |file|
190
+ SharedHelpers.filesystem_access(File.dirname(file)) do |_p|
191
+ FileUtils.rm(file) if File.exist?(file)
192
+ end
193
+ end
198
194
 
199
- def setup_environment
200
- begin
201
- ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
202
- rescue Gem::GemNotFoundException
203
- ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../exe/bundle", __FILE__)
195
+ stale_dirs = stale_git_cache_dirs + stale_extension_dirs
196
+ stale_dirs.each do |stale_dir|
197
+ SharedHelpers.filesystem_access(stale_dir) do |dir|
198
+ FileUtils.rm_rf(dir) if File.exist?(dir)
199
+ end
200
+ end
204
201
  end
205
202
 
206
- # Set BUNDLE_GEMFILE
207
- ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
208
-
209
- SharedHelpers.set_bundle_environment
203
+ output
210
204
  end
211
205
 
212
- private
206
+ private
213
207
 
214
208
  def prune_gem_cache(resolve, cache_path)
215
209
  cached = Dir["#{cache_path}/*.gem"]
@@ -256,20 +250,16 @@ module Bundler
256
250
  end
257
251
 
258
252
  def setup_manpath
259
- # Store original MANPATH for restoration later in with_clean_env()
260
- ENV["BUNDLE_ORIG_MANPATH"] = ENV["MANPATH"]
261
-
262
253
  # Add man/ subdirectories from activated bundles to MANPATH for man(1)
263
254
  manuals = $LOAD_PATH.map do |path|
264
255
  man_subdir = path.sub(/lib$/, "man")
265
256
  man_subdir unless Dir[man_subdir + "/man?/"].empty?
266
257
  end.compact
267
258
 
268
- unless manuals.empty?
269
- ENV["MANPATH"] = manuals.concat(
270
- ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
271
- ).uniq.join(File::PATH_SEPARATOR)
272
- end
259
+ return if manuals.empty?
260
+ Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
261
+ ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
262
+ ).uniq.join(File::PATH_SEPARATOR)
273
263
  end
274
264
 
275
265
  def remove_dir(dir, dry_run)
@@ -289,5 +279,27 @@ module Bundler
289
279
 
290
280
  output
291
281
  end
282
+
283
+ def check_for_activated_spec!(spec)
284
+ return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
285
+ return if activated_spec.version == spec.version
286
+
287
+ suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
288
+ "Since #{spec.name} is a default gem, you can either remove your dependency on it" \
289
+ " or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
290
+ else
291
+ "Prepending `bundle exec` to your command may solve this."
292
+ end
293
+
294
+ e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
295
+ "but your Gemfile requires #{spec.name} #{spec.version}. #{suggestion}"
296
+ e.name = spec.name
297
+ if e.respond_to?(:requirement=)
298
+ e.requirement = Gem::Requirement.new(spec.version.to_s)
299
+ else
300
+ e.version_requirement = Gem::Requirement.new(spec.version.to_s)
301
+ end
302
+ raise e
303
+ end
292
304
  end
293
305
  end
@@ -1,42 +1,121 @@
1
- require "uri"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Bundler
4
4
  class Settings
5
- BOOL_KEYS = %w(frozen cache_all no_prune disable_local_branch_check ignore_messages gem.mit gem.coc silence_root_warning).freeze
6
- NUMBER_KEYS = %w(retry timeout redirect ssl_verify_mode).freeze
7
- DEFAULT_CONFIG = { :retry => 3, :timeout => 10, :redirect => 5 }
5
+ autoload :Mirror, File.expand_path("mirror", __dir__)
6
+ autoload :Mirrors, File.expand_path("mirror", __dir__)
7
+ autoload :Validator, File.expand_path("settings/validator", __dir__)
8
+
9
+ BOOL_KEYS = %w[
10
+ allow_bundler_dependency_conflicts
11
+ allow_deployment_source_credential_changes
12
+ allow_offline_install
13
+ auto_clean_without_path
14
+ auto_install
15
+ cache_all
16
+ cache_all_platforms
17
+ default_install_uses_path
18
+ deployment
19
+ deployment_means_frozen
20
+ disable_checksum_validation
21
+ disable_exec_load
22
+ disable_local_branch_check
23
+ disable_multisource
24
+ disable_shared_gems
25
+ disable_version_check
26
+ force_ruby_platform
27
+ forget_cli_options
28
+ frozen
29
+ gem.coc
30
+ gem.mit
31
+ global_gem_cache
32
+ ignore_messages
33
+ init_gems_rb
34
+ no_install
35
+ no_prune
36
+ only_update_to_newer_versions
37
+ path_relative_to_cwd
38
+ path.system
39
+ plugins
40
+ prefer_patch
41
+ print_only_version_number
42
+ setup_makes_kernel_gem_public
43
+ silence_deprecations
44
+ silence_root_warning
45
+ suppress_install_using_messages
46
+ unlock_source_unlocks_spec
47
+ update_requires_all_flag
48
+ use_gem_version_promoter_for_major_updates
49
+ ].freeze
50
+
51
+ NUMBER_KEYS = %w[
52
+ jobs
53
+ redirect
54
+ retry
55
+ ssl_verify_mode
56
+ timeout
57
+ ].freeze
58
+
59
+ ARRAY_KEYS = %w[
60
+ with
61
+ without
62
+ ].freeze
63
+
64
+ DEFAULT_CONFIG = {
65
+ "BUNDLE_SILENCE_DEPRECATIONS" => false,
66
+ "BUNDLE_DISABLE_VERSION_CHECK" => true,
67
+ "BUNDLE_PREFER_PATCH" => false,
68
+ "BUNDLE_REDIRECT" => 5,
69
+ "BUNDLE_RETRY" => 3,
70
+ "BUNDLE_TIMEOUT" => 10,
71
+ }.freeze
8
72
 
9
73
  def initialize(root = nil)
10
- @root = root
11
- @local_config = load_config(local_config_file)
12
- @global_config = load_config(global_config_file)
74
+ @root = root
75
+ @local_config = load_config(local_config_file)
76
+ @env_config = ENV.to_h.select {|key, _value| key =~ /\ABUNDLE_.+/ }
77
+ @global_config = load_config(global_config_file)
78
+ @temporary = {}
13
79
  end
14
80
 
15
81
  def [](name)
16
82
  key = key_for(name)
17
- value = (@local_config[key] || ENV[key] || @global_config[key] || DEFAULT_CONFIG[name])
83
+ value = configs.values.map {|config| config[key] }.compact.first
18
84
 
19
- case
20
- when value.nil?
21
- nil
22
- when is_bool(name) || value == "false"
23
- to_bool(value)
24
- when is_num(name)
25
- value.to_i
26
- else
85
+ converted_value(value, name)
86
+ end
87
+
88
+ def set_command_option(key, value)
89
+ if Bundler.feature_flag.forget_cli_options?
90
+ temporary(key => value)
27
91
  value
92
+ else
93
+ set_local(key, value)
28
94
  end
29
95
  end
30
96
 
31
- def []=(key, value)
97
+ def set_command_option_if_given(key, value)
98
+ return if value.nil?
99
+ set_command_option(key, value)
100
+ end
101
+
102
+ def set_local(key, value)
32
103
  local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
104
+
33
105
  set_key(key, value, @local_config, local_config_file)
34
106
  end
35
107
 
36
- alias_method :set_local, :[]=
37
-
38
- def delete(key)
39
- @local_config.delete(key_for(key))
108
+ def temporary(update)
109
+ existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
110
+ update.each do |k, v|
111
+ set_key(k, v, @temporary, nil)
112
+ end
113
+ return unless block_given?
114
+ begin
115
+ yield
116
+ ensure
117
+ existing.each {|k, v| set_key(k, v, @temporary, nil) }
118
+ end
40
119
  end
41
120
 
42
121
  def set_global(key, value)
@@ -44,9 +123,7 @@ module Bundler
44
123
  end
45
124
 
46
125
  def all
47
- env_keys = ENV.keys.select {|k| k =~ /BUNDLE_.*/ }
48
-
49
- keys = @global_config.keys | @local_config.keys | env_keys
126
+ keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
50
127
 
51
128
  keys.map do |key|
52
129
  key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
@@ -62,11 +139,12 @@ module Bundler
62
139
  end
63
140
 
64
141
  def mirror_for(uri)
65
- uri = URI(uri.to_s) unless uri.is_a?(URI)
142
+ if uri.is_a?(String)
143
+ require_relative "vendored_uri"
144
+ uri = Bundler::URI(uri)
145
+ end
66
146
 
67
- # Settings keys are all downcased
68
- normalized_key = normalize_uri(uri.to_s.downcase)
69
- gem_mirrors[normalized_key] || uri
147
+ gem_mirrors.for(uri.to_s).uri
70
148
  end
71
149
 
72
150
  def credentials_for(uri)
@@ -74,76 +152,111 @@ module Bundler
74
152
  end
75
153
 
76
154
  def gem_mirrors
77
- all.inject({}) do |h, k|
78
- if k =~ /^mirror\./
79
- uri = normalize_uri($')
80
- h[uri] = normalize_uri(self[k])
81
- end
82
- h
155
+ all.inject(Mirrors.new) do |mirrors, k|
156
+ mirrors.parse(k, self[k]) if k.start_with?("mirror.")
157
+ mirrors
83
158
  end
84
159
  end
85
160
 
86
161
  def locations(key)
87
162
  key = key_for(key)
88
- locations = {}
89
- locations[:local] = @local_config[key] if @local_config.key?(key)
90
- locations[:env] = ENV[key] if ENV[key]
91
- locations[:global] = @global_config[key] if @global_config.key?(key)
92
- locations[:default] = DEFAULT_CONFIG[key] if DEFAULT_CONFIG.key?(key)
93
- locations
163
+ configs.keys.inject({}) do |partial_locations, level|
164
+ value_on_level = configs[level][key]
165
+ partial_locations[level] = value_on_level unless value_on_level.nil?
166
+ partial_locations
167
+ end
94
168
  end
95
169
 
96
170
  def pretty_values_for(exposed_key)
97
171
  key = key_for(exposed_key)
98
172
 
99
173
  locations = []
100
- if @local_config.key?(key)
101
- locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
174
+
175
+ if value = @temporary[key]
176
+ locations << "Set for the current command: #{converted_value(value, exposed_key).inspect}"
177
+ end
178
+
179
+ if value = @local_config[key]
180
+ locations << "Set for your local app (#{local_config_file}): #{converted_value(value, exposed_key).inspect}"
102
181
  end
103
182
 
104
- if value = ENV[key]
105
- locations << "Set via #{key}: #{value.inspect}"
183
+ if value = @env_config[key]
184
+ locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
106
185
  end
107
186
 
108
- if @global_config.key?(key)
109
- locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
187
+ if value = @global_config[key]
188
+ locations << "Set for the current user (#{global_config_file}): #{converted_value(value, exposed_key).inspect}"
110
189
  end
111
190
 
112
191
  return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
113
192
  locations
114
193
  end
115
194
 
116
- def without=(array)
117
- set_array(:without, array)
118
- end
195
+ # for legacy reasons, in Bundler 2, we do not respect :disable_shared_gems
196
+ def path
197
+ configs.each do |_level, settings|
198
+ path = value_for("path", settings)
199
+ path_system = value_for("path.system", settings)
200
+ disabled_shared_gems = value_for("disable_shared_gems", settings)
201
+ next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
202
+ system_path = path_system || (disabled_shared_gems == false)
203
+ return Path.new(path, system_path)
204
+ end
119
205
 
120
- def with=(array)
121
- set_array(:with, array)
206
+ Path.new(nil, false)
122
207
  end
123
208
 
124
- def without
125
- get_array(:without)
126
- end
209
+ Path = Struct.new(:explicit_path, :system_path) do
210
+ def path
211
+ path = base_path
212
+ path = File.join(path, Bundler.ruby_scope) unless use_system_gems?
213
+ path
214
+ end
127
215
 
128
- def with
129
- get_array(:with)
130
- end
216
+ def use_system_gems?
217
+ return true if system_path
218
+ return false if explicit_path
219
+ !Bundler.feature_flag.default_install_uses_path?
220
+ end
131
221
 
132
- # @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
133
- def path
134
- key = key_for(:path)
135
- path = ENV[key] || @global_config[key]
136
- return path if path && !@local_config.key?(key)
222
+ def base_path
223
+ path = explicit_path
224
+ path ||= ".bundle" unless use_system_gems?
225
+ path ||= Bundler.rubygems.gem_dir
226
+ path
227
+ end
137
228
 
138
- if path = self[:path]
139
- "#{path}/#{Bundler.ruby_scope}"
140
- else
141
- Bundler.rubygems.gem_dir
229
+ def base_path_relative_to_pwd
230
+ base_path = Pathname.new(self.base_path)
231
+ expanded_base_path = base_path.expand_path(Bundler.root)
232
+ relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
233
+ if relative_path.to_s.start_with?("..")
234
+ relative_path = base_path if base_path.absolute?
235
+ else
236
+ relative_path = Pathname.new(File.join(".", relative_path))
237
+ end
238
+ relative_path
239
+ rescue ArgumentError
240
+ expanded_base_path
241
+ end
242
+
243
+ def validate!
244
+ return unless explicit_path && system_path
245
+ path = Bundler.settings.pretty_values_for(:path)
246
+ path.unshift(nil, "path:") unless path.empty?
247
+ system_path = Bundler.settings.pretty_values_for("path.system")
248
+ system_path.unshift(nil, "path.system:") unless system_path.empty?
249
+ disable_shared_gems = Bundler.settings.pretty_values_for(:disable_shared_gems)
250
+ disable_shared_gems.unshift(nil, "disable_shared_gems:") unless disable_shared_gems.empty?
251
+ raise InvalidOption,
252
+ "Using a custom path while using system gems is unsupported.\n#{path.join("\n")}\n#{system_path.join("\n")}\n#{disable_shared_gems.join("\n")}"
142
253
  end
143
254
  end
144
255
 
145
256
  def allow_sudo?
146
- !@local_config.key?(key_for(:path))
257
+ key = key_for(:path)
258
+ path_configured = @temporary.key?(key) || @local_config.key?(key)
259
+ !path_configured
147
260
  end
148
261
 
149
262
  def ignore_config?
@@ -151,30 +264,49 @@ module Bundler
151
264
  end
152
265
 
153
266
  def app_cache_path
154
- @app_cache_path ||= begin
155
- path = self[:cache_path] || "vendor/cache"
156
- raise InvalidOption, "Cache path must be relative to the bundle path" if path.start_with?("/")
157
- path
158
- end
267
+ @app_cache_path ||= self[:cache_path] || "vendor/cache"
159
268
  end
160
269
 
161
- private
270
+ def validate!
271
+ all.each do |raw_key|
272
+ [@local_config, @env_config, @global_config].each do |settings|
273
+ value = value_for(raw_key, settings)
274
+ Validator.validate!(raw_key, value, settings.dup)
275
+ end
276
+ end
277
+ end
162
278
 
163
279
  def key_for(key)
164
- key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
280
+ key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
165
281
  key = key.to_s.gsub(".", "__").upcase
166
282
  "BUNDLE_#{key}"
167
283
  end
168
284
 
285
+ private
286
+
287
+ def configs
288
+ {
289
+ :temporary => @temporary,
290
+ :local => @local_config,
291
+ :env => @env_config,
292
+ :global => @global_config,
293
+ :default => DEFAULT_CONFIG,
294
+ }
295
+ end
296
+
297
+ def value_for(name, config)
298
+ converted_value(config[key_for(name)], name)
299
+ end
300
+
169
301
  def parent_setting_for(name)
170
- split_specfic_setting_for(name)[0]
302
+ split_specific_setting_for(name)[0]
171
303
  end
172
304
 
173
- def specfic_gem_for(name)
174
- split_specfic_setting_for(name)[1]
305
+ def specific_gem_for(name)
306
+ split_specific_setting_for(name)[1]
175
307
  end
176
308
 
177
- def split_specfic_setting_for(name)
309
+ def split_specific_setting_for(name)
178
310
  name.split(".")
179
311
  end
180
312
 
@@ -183,40 +315,78 @@ module Bundler
183
315
  end
184
316
 
185
317
  def to_bool(value)
186
- !(value.nil? || value == "" || value =~ /^(false|f|no|n|0)$/i || value == false)
318
+ case value
319
+ when nil, /\A(false|f|no|n|0|)\z/i, false
320
+ false
321
+ else
322
+ true
323
+ end
187
324
  end
188
325
 
189
- def is_num(value)
190
- NUMBER_KEYS.include?(value.to_s)
326
+ def is_num(key)
327
+ NUMBER_KEYS.include?(key.to_s)
191
328
  end
192
329
 
193
- def get_array(key)
194
- self[key] ? self[key].split(":").map(&:to_sym) : []
330
+ def is_array(key)
331
+ ARRAY_KEYS.include?(key.to_s)
195
332
  end
196
333
 
197
- def set_array(key, array)
198
- self[key] = (array.empty? ? nil : array.join(":")) if array
334
+ def to_array(value)
335
+ return [] unless value
336
+ value.split(":").map(&:to_sym)
199
337
  end
200
338
 
201
- def set_key(key, value, hash, file)
202
- key = key_for(key)
339
+ def array_to_s(array)
340
+ array = Array(array)
341
+ return nil if array.empty?
342
+ array.join(":").tr(" ", ":")
343
+ end
203
344
 
204
- unless hash[key] == value
205
- hash[key] = value
206
- hash.delete(key) if value.nil?
207
- SharedHelpers.filesystem_access(file) do |p|
208
- FileUtils.mkdir_p(p.dirname)
209
- require "bundler/psyched_yaml"
210
- File.open(p, "w") {|f| f.puts YAML.dump(hash) }
211
- end
345
+ def set_key(raw_key, value, hash, file)
346
+ raw_key = raw_key.to_s
347
+ value = array_to_s(value) if is_array(raw_key)
348
+
349
+ key = key_for(raw_key)
350
+
351
+ return if hash[key] == value
352
+
353
+ hash[key] = value
354
+ hash.delete(key) if value.nil?
355
+
356
+ Validator.validate!(raw_key, converted_value(value, raw_key), hash)
357
+
358
+ return unless file
359
+ SharedHelpers.filesystem_access(file) do |p|
360
+ FileUtils.mkdir_p(p.dirname)
361
+ require_relative "yaml_serializer"
362
+ p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
212
363
  end
364
+ end
213
365
 
214
- value
366
+ def converted_value(value, key)
367
+ if is_array(key)
368
+ to_array(value)
369
+ elsif value.nil?
370
+ nil
371
+ elsif is_bool(key) || value == "false"
372
+ to_bool(value)
373
+ elsif is_num(key)
374
+ value.to_i
375
+ else
376
+ value.to_s
377
+ end
215
378
  end
216
379
 
217
380
  def global_config_file
218
- file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config")
219
- Pathname.new(file)
381
+ if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
382
+ Pathname.new(ENV["BUNDLE_CONFIG"])
383
+ else
384
+ begin
385
+ Bundler.user_bundle_path("config")
386
+ rescue PermissionError, GenericSystemCallError
387
+ nil
388
+ end
389
+ end
220
390
  end
221
391
 
222
392
  def local_config_file
@@ -224,36 +394,44 @@ module Bundler
224
394
  end
225
395
 
226
396
  def load_config(config_file)
227
- valid_file = config_file && config_file.exist? && !config_file.size.zero?
228
- if !ignore_config? && valid_file
229
- config_regex = /^(BUNDLE_.+): (['"]?)(.*(?:\n(?!BUNDLE).+)?)\2$/
230
- raise PermissionError.new(config_file, :read) unless config_file.readable?
231
- config_pairs = config_file.read.scan(config_regex).map do |m|
232
- key, _, value = m
233
- [convert_to_backward_compatible_key(key), value.gsub(/\s+/, " ").tr('"', "'")]
234
- end
235
- Hash[config_pairs]
236
- else
237
- {}
397
+ return {} if !config_file || ignore_config?
398
+ SharedHelpers.filesystem_access(config_file, :read) do |file|
399
+ valid_file = file.exist? && !file.size.zero?
400
+ return {} unless valid_file
401
+ require_relative "yaml_serializer"
402
+ YAMLSerializer.load file.read
238
403
  end
239
404
  end
240
405
 
241
- def convert_to_backward_compatible_key(key)
242
- key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z}
243
- key = key.gsub(".", "__") if key.include?(".")
244
- key
245
- end
406
+ PER_URI_OPTIONS = %w[
407
+ fallback_timeout
408
+ ].freeze
409
+
410
+ NORMALIZE_URI_OPTIONS_PATTERN =
411
+ /
412
+ \A
413
+ (\w+\.)? # optional prefix key
414
+ (https?.*?) # URI
415
+ (\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
416
+ \z
417
+ /ix.freeze
246
418
 
247
419
  # TODO: duplicates Rubygems#normalize_uri
248
420
  # TODO: is this the correct place to validate mirror URIs?
249
- def normalize_uri(uri)
421
+ def self.normalize_uri(uri)
250
422
  uri = uri.to_s
251
- uri = "#{uri}/" unless uri =~ %r{/\Z}
252
- uri = URI(uri)
423
+ if uri =~ NORMALIZE_URI_OPTIONS_PATTERN
424
+ prefix = $1
425
+ uri = $2
426
+ suffix = $3
427
+ end
428
+ uri = "#{uri}/" unless uri.end_with?("/")
429
+ require_relative "vendored_uri"
430
+ uri = Bundler::URI(uri)
253
431
  unless uri.absolute?
254
- raise ArgumentError, "Gem sources must be absolute. You provided '#{uri}'."
432
+ raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
255
433
  end
256
- uri
434
+ "#{prefix}#{uri}#{suffix}"
257
435
  end
258
436
  end
259
437
  end