bundler-clone 4.0.15

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