mini-sharp-lib 0.0.1

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 (345) hide show
  1. checksums.yaml +7 -0
  2. data/bundler-4.0.16/CHANGELOG.md +5687 -0
  3. data/bundler-4.0.16/LICENSE.md +22 -0
  4. data/bundler-4.0.16/README.md +58 -0
  5. data/bundler-4.0.16/bundler.gemspec +46 -0
  6. data/bundler-4.0.16/exe/bundle +29 -0
  7. data/bundler-4.0.16/exe/bundler +4 -0
  8. data/bundler-4.0.16/lib/bundler/build_metadata.rb +44 -0
  9. data/bundler-4.0.16/lib/bundler/capistrano.rb +4 -0
  10. data/bundler-4.0.16/lib/bundler/checksum.rb +270 -0
  11. data/bundler-4.0.16/lib/bundler/ci_detector.rb +75 -0
  12. data/bundler-4.0.16/lib/bundler/cli/add.rb +62 -0
  13. data/bundler-4.0.16/lib/bundler/cli/binstubs.rb +57 -0
  14. data/bundler-4.0.16/lib/bundler/cli/cache.rb +32 -0
  15. data/bundler-4.0.16/lib/bundler/cli/check.rb +40 -0
  16. data/bundler-4.0.16/lib/bundler/cli/clean.rb +25 -0
  17. data/bundler-4.0.16/lib/bundler/cli/common.rb +161 -0
  18. data/bundler-4.0.16/lib/bundler/cli/config.rb +208 -0
  19. data/bundler-4.0.16/lib/bundler/cli/console.rb +47 -0
  20. data/bundler-4.0.16/lib/bundler/cli/doctor/diagnose.rb +167 -0
  21. data/bundler-4.0.16/lib/bundler/cli/doctor/ssl.rb +249 -0
  22. data/bundler-4.0.16/lib/bundler/cli/doctor.rb +33 -0
  23. data/bundler-4.0.16/lib/bundler/cli/exec.rb +114 -0
  24. data/bundler-4.0.16/lib/bundler/cli/fund.rb +36 -0
  25. data/bundler-4.0.16/lib/bundler/cli/gem.rb +492 -0
  26. data/bundler-4.0.16/lib/bundler/cli/info.rb +83 -0
  27. data/bundler-4.0.16/lib/bundler/cli/init.rb +51 -0
  28. data/bundler-4.0.16/lib/bundler/cli/install.rb +127 -0
  29. data/bundler-4.0.16/lib/bundler/cli/issue.rb +41 -0
  30. data/bundler-4.0.16/lib/bundler/cli/list.rb +97 -0
  31. data/bundler-4.0.16/lib/bundler/cli/lock.rb +94 -0
  32. data/bundler-4.0.16/lib/bundler/cli/open.rb +29 -0
  33. data/bundler-4.0.16/lib/bundler/cli/outdated.rb +337 -0
  34. data/bundler-4.0.16/lib/bundler/cli/platform.rb +48 -0
  35. data/bundler-4.0.16/lib/bundler/cli/plugin.rb +39 -0
  36. data/bundler-4.0.16/lib/bundler/cli/pristine.rb +64 -0
  37. data/bundler-4.0.16/lib/bundler/cli/remove.rb +17 -0
  38. data/bundler-4.0.16/lib/bundler/cli/show.rb +71 -0
  39. data/bundler-4.0.16/lib/bundler/cli/update.rb +125 -0
  40. data/bundler-4.0.16/lib/bundler/cli.rb +829 -0
  41. data/bundler-4.0.16/lib/bundler/compact_index_client/cache.rb +96 -0
  42. data/bundler-4.0.16/lib/bundler/compact_index_client/cache_file.rb +148 -0
  43. data/bundler-4.0.16/lib/bundler/compact_index_client/parser.rb +87 -0
  44. data/bundler-4.0.16/lib/bundler/compact_index_client/updater.rb +105 -0
  45. data/bundler-4.0.16/lib/bundler/compact_index_client.rb +92 -0
  46. data/bundler-4.0.16/lib/bundler/constants.rb +14 -0
  47. data/bundler-4.0.16/lib/bundler/current_ruby.rb +94 -0
  48. data/bundler-4.0.16/lib/bundler/definition.rb +1308 -0
  49. data/bundler-4.0.16/lib/bundler/dependency.rb +151 -0
  50. data/bundler-4.0.16/lib/bundler/deployment.rb +6 -0
  51. data/bundler-4.0.16/lib/bundler/deprecate.rb +44 -0
  52. data/bundler-4.0.16/lib/bundler/digest.rb +71 -0
  53. data/bundler-4.0.16/lib/bundler/dsl.rb +645 -0
  54. data/bundler-4.0.16/lib/bundler/endpoint_specification.rb +184 -0
  55. data/bundler-4.0.16/lib/bundler/env.rb +148 -0
  56. data/bundler-4.0.16/lib/bundler/environment_preserver.rb +69 -0
  57. data/bundler-4.0.16/lib/bundler/errors.rb +277 -0
  58. data/bundler-4.0.16/lib/bundler/feature_flag.rb +20 -0
  59. data/bundler-4.0.16/lib/bundler/fetcher/base.rb +55 -0
  60. data/bundler-4.0.16/lib/bundler/fetcher/compact_index.rb +133 -0
  61. data/bundler-4.0.16/lib/bundler/fetcher/dependency.rb +85 -0
  62. data/bundler-4.0.16/lib/bundler/fetcher/downloader.rb +116 -0
  63. data/bundler-4.0.16/lib/bundler/fetcher/gem_remote_fetcher.rb +24 -0
  64. data/bundler-4.0.16/lib/bundler/fetcher/index.rb +25 -0
  65. data/bundler-4.0.16/lib/bundler/fetcher.rb +365 -0
  66. data/bundler-4.0.16/lib/bundler/force_platform.rb +16 -0
  67. data/bundler-4.0.16/lib/bundler/friendly_errors.rb +127 -0
  68. data/bundler-4.0.16/lib/bundler/gem_helper.rb +237 -0
  69. data/bundler-4.0.16/lib/bundler/gem_tasks.rb +7 -0
  70. data/bundler-4.0.16/lib/bundler/gem_version_promoter.rb +147 -0
  71. data/bundler-4.0.16/lib/bundler/index.rb +203 -0
  72. data/bundler-4.0.16/lib/bundler/injector.rb +284 -0
  73. data/bundler-4.0.16/lib/bundler/inline.rb +106 -0
  74. data/bundler-4.0.16/lib/bundler/installer/gem_installer.rb +88 -0
  75. data/bundler-4.0.16/lib/bundler/installer/parallel_installer.rb +286 -0
  76. data/bundler-4.0.16/lib/bundler/installer/standalone.rb +113 -0
  77. data/bundler-4.0.16/lib/bundler/installer.rb +241 -0
  78. data/bundler-4.0.16/lib/bundler/lazy_specification.rb +270 -0
  79. data/bundler-4.0.16/lib/bundler/lockfile_generator.rb +119 -0
  80. data/bundler-4.0.16/lib/bundler/lockfile_parser.rb +328 -0
  81. data/bundler-4.0.16/lib/bundler/man/bundle-add.1 +79 -0
  82. data/bundler-4.0.16/lib/bundler/man/bundle-add.1.ronn +92 -0
  83. data/bundler-4.0.16/lib/bundler/man/bundle-binstubs.1 +30 -0
  84. data/bundler-4.0.16/lib/bundler/man/bundle-binstubs.1.ronn +42 -0
  85. data/bundler-4.0.16/lib/bundler/man/bundle-cache.1 +56 -0
  86. data/bundler-4.0.16/lib/bundler/man/bundle-cache.1.ronn +95 -0
  87. data/bundler-4.0.16/lib/bundler/man/bundle-check.1 +21 -0
  88. data/bundler-4.0.16/lib/bundler/man/bundle-check.1.ronn +26 -0
  89. data/bundler-4.0.16/lib/bundler/man/bundle-clean.1 +17 -0
  90. data/bundler-4.0.16/lib/bundler/man/bundle-clean.1.ronn +18 -0
  91. data/bundler-4.0.16/lib/bundler/man/bundle-config.1 +339 -0
  92. data/bundler-4.0.16/lib/bundler/man/bundle-config.1.ronn +455 -0
  93. data/bundler-4.0.16/lib/bundler/man/bundle-console.1 +33 -0
  94. data/bundler-4.0.16/lib/bundler/man/bundle-console.1.ronn +39 -0
  95. data/bundler-4.0.16/lib/bundler/man/bundle-doctor.1 +69 -0
  96. data/bundler-4.0.16/lib/bundler/man/bundle-doctor.1.ronn +77 -0
  97. data/bundler-4.0.16/lib/bundler/man/bundle-env.1 +9 -0
  98. data/bundler-4.0.16/lib/bundler/man/bundle-env.1.ronn +10 -0
  99. data/bundler-4.0.16/lib/bundler/man/bundle-exec.1 +104 -0
  100. data/bundler-4.0.16/lib/bundler/man/bundle-exec.1.ronn +150 -0
  101. data/bundler-4.0.16/lib/bundler/man/bundle-fund.1 +22 -0
  102. data/bundler-4.0.16/lib/bundler/man/bundle-fund.1.ronn +25 -0
  103. data/bundler-4.0.16/lib/bundler/man/bundle-gem.1 +107 -0
  104. data/bundler-4.0.16/lib/bundler/man/bundle-gem.1.ronn +150 -0
  105. data/bundler-4.0.16/lib/bundler/man/bundle-help.1 +9 -0
  106. data/bundler-4.0.16/lib/bundler/man/bundle-help.1.ronn +12 -0
  107. data/bundler-4.0.16/lib/bundler/man/bundle-info.1 +17 -0
  108. data/bundler-4.0.16/lib/bundler/man/bundle-info.1.ronn +21 -0
  109. data/bundler-4.0.16/lib/bundler/man/bundle-init.1 +20 -0
  110. data/bundler-4.0.16/lib/bundler/man/bundle-init.1.ronn +32 -0
  111. data/bundler-4.0.16/lib/bundler/man/bundle-install.1 +178 -0
  112. data/bundler-4.0.16/lib/bundler/man/bundle-install.1.ronn +314 -0
  113. data/bundler-4.0.16/lib/bundler/man/bundle-issue.1 +45 -0
  114. data/bundler-4.0.16/lib/bundler/man/bundle-issue.1.ronn +37 -0
  115. data/bundler-4.0.16/lib/bundler/man/bundle-licenses.1 +9 -0
  116. data/bundler-4.0.16/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  117. data/bundler-4.0.16/lib/bundler/man/bundle-list.1 +40 -0
  118. data/bundler-4.0.16/lib/bundler/man/bundle-list.1.ronn +41 -0
  119. data/bundler-4.0.16/lib/bundler/man/bundle-lock.1 +75 -0
  120. data/bundler-4.0.16/lib/bundler/man/bundle-lock.1.ronn +115 -0
  121. data/bundler-4.0.16/lib/bundler/man/bundle-open.1 +32 -0
  122. data/bundler-4.0.16/lib/bundler/man/bundle-open.1.ronn +28 -0
  123. data/bundler-4.0.16/lib/bundler/man/bundle-outdated.1 +106 -0
  124. data/bundler-4.0.16/lib/bundler/man/bundle-outdated.1.ronn +117 -0
  125. data/bundler-4.0.16/lib/bundler/man/bundle-platform.1 +49 -0
  126. data/bundler-4.0.16/lib/bundler/man/bundle-platform.1.ronn +49 -0
  127. data/bundler-4.0.16/lib/bundler/man/bundle-plugin.1 +76 -0
  128. data/bundler-4.0.16/lib/bundler/man/bundle-plugin.1.ronn +84 -0
  129. data/bundler-4.0.16/lib/bundler/man/bundle-pristine.1 +23 -0
  130. data/bundler-4.0.16/lib/bundler/man/bundle-pristine.1.ronn +34 -0
  131. data/bundler-4.0.16/lib/bundler/man/bundle-remove.1 +15 -0
  132. data/bundler-4.0.16/lib/bundler/man/bundle-remove.1.ronn +16 -0
  133. data/bundler-4.0.16/lib/bundler/man/bundle-show.1 +16 -0
  134. data/bundler-4.0.16/lib/bundler/man/bundle-show.1.ronn +21 -0
  135. data/bundler-4.0.16/lib/bundler/man/bundle-update.1 +284 -0
  136. data/bundler-4.0.16/lib/bundler/man/bundle-update.1.ronn +367 -0
  137. data/bundler-4.0.16/lib/bundler/man/bundle-version.1 +22 -0
  138. data/bundler-4.0.16/lib/bundler/man/bundle-version.1.ronn +24 -0
  139. data/bundler-4.0.16/lib/bundler/man/bundle.1 +93 -0
  140. data/bundler-4.0.16/lib/bundler/man/bundle.1.ronn +107 -0
  141. data/bundler-4.0.16/lib/bundler/man/gemfile.5 +503 -0
  142. data/bundler-4.0.16/lib/bundler/man/gemfile.5.ronn +586 -0
  143. data/bundler-4.0.16/lib/bundler/man/index.txt +31 -0
  144. data/bundler-4.0.16/lib/bundler/match_metadata.rb +30 -0
  145. data/bundler-4.0.16/lib/bundler/match_platform.rb +42 -0
  146. data/bundler-4.0.16/lib/bundler/match_remote_metadata.rb +29 -0
  147. data/bundler-4.0.16/lib/bundler/materialization.rb +59 -0
  148. data/bundler-4.0.16/lib/bundler/mirror.rb +221 -0
  149. data/bundler-4.0.16/lib/bundler/plugin/api/source.rb +330 -0
  150. data/bundler-4.0.16/lib/bundler/plugin/api.rb +81 -0
  151. data/bundler-4.0.16/lib/bundler/plugin/dsl.rb +53 -0
  152. data/bundler-4.0.16/lib/bundler/plugin/events.rb +85 -0
  153. data/bundler-4.0.16/lib/bundler/plugin/index.rb +203 -0
  154. data/bundler-4.0.16/lib/bundler/plugin/installer/git.rb +34 -0
  155. data/bundler-4.0.16/lib/bundler/plugin/installer/path.rb +26 -0
  156. data/bundler-4.0.16/lib/bundler/plugin/installer/rubygems.rb +19 -0
  157. data/bundler-4.0.16/lib/bundler/plugin/installer.rb +123 -0
  158. data/bundler-4.0.16/lib/bundler/plugin/source_list.rb +31 -0
  159. data/bundler-4.0.16/lib/bundler/plugin/unloaded_source.rb +25 -0
  160. data/bundler-4.0.16/lib/bundler/plugin.rb +387 -0
  161. data/bundler-4.0.16/lib/bundler/process_lock.rb +20 -0
  162. data/bundler-4.0.16/lib/bundler/remote_specification.rb +126 -0
  163. data/bundler-4.0.16/lib/bundler/resolver/base.rb +127 -0
  164. data/bundler-4.0.16/lib/bundler/resolver/candidate.rb +85 -0
  165. data/bundler-4.0.16/lib/bundler/resolver/incompatibility.rb +15 -0
  166. data/bundler-4.0.16/lib/bundler/resolver/package.rb +95 -0
  167. data/bundler-4.0.16/lib/bundler/resolver/root.rb +25 -0
  168. data/bundler-4.0.16/lib/bundler/resolver/spec_group.rb +74 -0
  169. data/bundler-4.0.16/lib/bundler/resolver/strategy.rb +43 -0
  170. data/bundler-4.0.16/lib/bundler/resolver.rb +603 -0
  171. data/bundler-4.0.16/lib/bundler/retry.rb +92 -0
  172. data/bundler-4.0.16/lib/bundler/ruby_dsl.rb +67 -0
  173. data/bundler-4.0.16/lib/bundler/ruby_version.rb +135 -0
  174. data/bundler-4.0.16/lib/bundler/rubygems_ext.rb +503 -0
  175. data/bundler-4.0.16/lib/bundler/rubygems_gem_installer.rb +206 -0
  176. data/bundler-4.0.16/lib/bundler/rubygems_integration.rb +456 -0
  177. data/bundler-4.0.16/lib/bundler/runtime.rb +331 -0
  178. data/bundler-4.0.16/lib/bundler/safe_marshal.rb +31 -0
  179. data/bundler-4.0.16/lib/bundler/self_manager.rb +197 -0
  180. data/bundler-4.0.16/lib/bundler/settings/validator.rb +86 -0
  181. data/bundler-4.0.16/lib/bundler/settings.rb +585 -0
  182. data/bundler-4.0.16/lib/bundler/setup.rb +39 -0
  183. data/bundler-4.0.16/lib/bundler/shared_helpers.rb +392 -0
  184. data/bundler-4.0.16/lib/bundler/source/gemspec.rb +19 -0
  185. data/bundler-4.0.16/lib/bundler/source/git/git_proxy.rb +509 -0
  186. data/bundler-4.0.16/lib/bundler/source/git.rb +451 -0
  187. data/bundler-4.0.16/lib/bundler/source/metadata.rb +67 -0
  188. data/bundler-4.0.16/lib/bundler/source/path/installer.rb +53 -0
  189. data/bundler-4.0.16/lib/bundler/source/path.rb +256 -0
  190. data/bundler-4.0.16/lib/bundler/source/rubygems/remote.rb +86 -0
  191. data/bundler-4.0.16/lib/bundler/source/rubygems.rb +606 -0
  192. data/bundler-4.0.16/lib/bundler/source/rubygems_aggregate.rb +71 -0
  193. data/bundler-4.0.16/lib/bundler/source.rb +120 -0
  194. data/bundler-4.0.16/lib/bundler/source_list.rb +240 -0
  195. data/bundler-4.0.16/lib/bundler/source_map.rb +72 -0
  196. data/bundler-4.0.16/lib/bundler/spec_set.rb +390 -0
  197. data/bundler-4.0.16/lib/bundler/stub_specification.rb +147 -0
  198. data/bundler-4.0.16/lib/bundler/templates/Executable +16 -0
  199. data/bundler-4.0.16/lib/bundler/templates/Executable.standalone +14 -0
  200. data/bundler-4.0.16/lib/bundler/templates/Gemfile +5 -0
  201. data/bundler-4.0.16/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  202. data/bundler-4.0.16/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +10 -0
  203. data/bundler-4.0.16/lib/bundler/templates/newgem/Cargo.toml.tt +13 -0
  204. data/bundler-4.0.16/lib/bundler/templates/newgem/Gemfile.tt +24 -0
  205. data/bundler-4.0.16/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
  206. data/bundler-4.0.16/lib/bundler/templates/newgem/README.md.tt +49 -0
  207. data/bundler-4.0.16/lib/bundler/templates/newgem/Rakefile.tt +72 -0
  208. data/bundler-4.0.16/lib/bundler/templates/newgem/bin/console.tt +11 -0
  209. data/bundler-4.0.16/lib/bundler/templates/newgem/bin/setup.tt +8 -0
  210. data/bundler-4.0.16/lib/bundler/templates/newgem/circleci/config.yml.tt +37 -0
  211. data/bundler-4.0.16/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  212. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +22 -0
  213. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
  214. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  215. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  216. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  217. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  218. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  219. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  220. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  221. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  222. data/bundler-4.0.16/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +23 -0
  223. data/bundler-4.0.16/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
  224. data/bundler-4.0.16/lib/bundler/templates/newgem/github/workflows/main.yml.tt +48 -0
  225. data/bundler-4.0.16/lib/bundler/templates/newgem/gitignore.tt +23 -0
  226. data/bundler-4.0.16/lib/bundler/templates/newgem/gitlab-ci.yml.tt +27 -0
  227. data/bundler-4.0.16/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +9 -0
  228. data/bundler-4.0.16/lib/bundler/templates/newgem/lib/newgem.rb.tt +15 -0
  229. data/bundler-4.0.16/lib/bundler/templates/newgem/newgem.gemspec.tt +58 -0
  230. data/bundler-4.0.16/lib/bundler/templates/newgem/rspec.tt +3 -0
  231. data/bundler-4.0.16/lib/bundler/templates/newgem/rubocop.yml.tt +8 -0
  232. data/bundler-4.0.16/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  233. data/bundler-4.0.16/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +19 -0
  234. data/bundler-4.0.16/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +15 -0
  235. data/bundler-4.0.16/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  236. data/bundler-4.0.16/lib/bundler/templates/newgem/test/minitest/test_helper.rb.tt +6 -0
  237. data/bundler-4.0.16/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +19 -0
  238. data/bundler-4.0.16/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  239. data/bundler-4.0.16/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  240. data/bundler-4.0.16/lib/bundler/ui/rg_proxy.rb +19 -0
  241. data/bundler-4.0.16/lib/bundler/ui/shell.rb +191 -0
  242. data/bundler-4.0.16/lib/bundler/ui/silent.rb +96 -0
  243. data/bundler-4.0.16/lib/bundler/ui.rb +9 -0
  244. data/bundler-4.0.16/lib/bundler/uri_credentials_filter.rb +43 -0
  245. data/bundler-4.0.16/lib/bundler/uri_normalizer.rb +23 -0
  246. data/bundler-4.0.16/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  247. data/bundler-4.0.16/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +227 -0
  248. data/bundler-4.0.16/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  249. data/bundler-4.0.16/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  250. data/bundler-4.0.16/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +230 -0
  251. data/bundler-4.0.16/lib/bundler/vendor/fileutils/COPYING +56 -0
  252. data/bundler-4.0.16/lib/bundler/vendor/fileutils/lib/fileutils.rb +2701 -0
  253. data/bundler-4.0.16/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  254. data/bundler-4.0.16/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +41 -0
  255. data/bundler-4.0.16/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +65 -0
  256. data/bundler-4.0.16/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +80 -0
  257. data/bundler-4.0.16/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1153 -0
  258. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  259. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  260. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +169 -0
  261. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  262. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  263. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  264. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  265. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  266. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  267. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +61 -0
  268. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/strategy.rb +42 -0
  269. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  270. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  271. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  272. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +423 -0
  273. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +236 -0
  274. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  275. data/bundler-4.0.16/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  276. data/bundler-4.0.16/lib/bundler/vendor/securerandom/COPYING +56 -0
  277. data/bundler-4.0.16/lib/bundler/vendor/securerandom/lib/securerandom.rb +102 -0
  278. data/bundler-4.0.16/lib/bundler/vendor/thor/LICENSE.md +20 -0
  279. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +105 -0
  280. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +61 -0
  281. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +108 -0
  282. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
  283. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +407 -0
  284. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +130 -0
  285. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/actions.rb +340 -0
  286. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/base.rb +825 -0
  287. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/command.rb +151 -0
  288. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
  289. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/error.rb +106 -0
  290. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/group.rb +292 -0
  291. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
  292. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
  293. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
  294. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
  295. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  296. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +86 -0
  297. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +195 -0
  298. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/parser/option.rb +178 -0
  299. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/parser/options.rb +294 -0
  300. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
  301. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +72 -0
  302. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/runner.rb +335 -0
  303. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +384 -0
  304. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/color.rb +112 -0
  305. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb +29 -0
  306. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/html.rb +81 -0
  307. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +118 -0
  308. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb +42 -0
  309. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb +38 -0
  310. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
  311. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/util.rb +285 -0
  312. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
  313. data/bundler-4.0.16/lib/bundler/vendor/thor/lib/thor.rb +674 -0
  314. data/bundler-4.0.16/lib/bundler/vendor/uri/COPYING +56 -0
  315. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/common.rb +922 -0
  316. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/file.rb +100 -0
  317. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  318. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/generic.rb +1592 -0
  319. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/http.rb +137 -0
  320. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  321. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  322. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/ldaps.rb +22 -0
  323. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/mailto.rb +293 -0
  324. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +547 -0
  325. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +206 -0
  326. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  327. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  328. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  329. data/bundler-4.0.16/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  330. data/bundler-4.0.16/lib/bundler/vendored_fileutils.rb +4 -0
  331. data/bundler-4.0.16/lib/bundler/vendored_net_http.rb +23 -0
  332. data/bundler-4.0.16/lib/bundler/vendored_persistent.rb +11 -0
  333. data/bundler-4.0.16/lib/bundler/vendored_pub_grub.rb +4 -0
  334. data/bundler-4.0.16/lib/bundler/vendored_securerandom.rb +12 -0
  335. data/bundler-4.0.16/lib/bundler/vendored_thor.rb +8 -0
  336. data/bundler-4.0.16/lib/bundler/vendored_timeout.rb +12 -0
  337. data/bundler-4.0.16/lib/bundler/vendored_tsort.rb +21 -0
  338. data/bundler-4.0.16/lib/bundler/vendored_uri.rb +21 -0
  339. data/bundler-4.0.16/lib/bundler/version.rb +21 -0
  340. data/bundler-4.0.16/lib/bundler/vlad.rb +4 -0
  341. data/bundler-4.0.16/lib/bundler/worker.rb +125 -0
  342. data/bundler-4.0.16/lib/bundler/yaml_serializer.rb +98 -0
  343. data/bundler-4.0.16/lib/bundler.rb +839 -0
  344. data/mini-sharp-lib.gemspec +11 -0
  345. metadata +383 -0
@@ -0,0 +1,1308 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lockfile_parser"
4
+ require_relative "worker"
5
+
6
+ module Bundler
7
+ class Definition
8
+ class << self
9
+ # Do not create or modify a lockfile (Makes #lock a noop)
10
+ attr_accessor :no_lock
11
+ end
12
+
13
+ attr_writer :lockfile
14
+
15
+ attr_reader(
16
+ :dependencies,
17
+ :locked_checksums,
18
+ :locked_deps,
19
+ :locked_gems,
20
+ :platforms,
21
+ :ruby_version,
22
+ :lockfile,
23
+ :gemfiles,
24
+ :sources
25
+ )
26
+
27
+ # Given a gemfile and lockfile creates a Bundler definition
28
+ #
29
+ # @param gemfile [Pathname] Path to Gemfile
30
+ # @param lockfile [Pathname,nil] Path to Gemfile.lock
31
+ # @param unlock [Hash, Boolean, nil] Gems that have been requested
32
+ # to be updated or true if all gems should be updated
33
+ # @return [Bundler::Definition]
34
+ def self.build(gemfile, lockfile, unlock)
35
+ unlock ||= {}
36
+ gemfile = Pathname.new(gemfile).expand_path
37
+
38
+ raise GemfileNotFound, "#{gemfile} not found" unless gemfile.file?
39
+
40
+ Dsl.evaluate(gemfile, lockfile, unlock)
41
+ end
42
+
43
+ #
44
+ # How does the new system work?
45
+ #
46
+ # * Load information from Gemfile and Lockfile
47
+ # * Invalidate stale locked specs
48
+ # * All specs from stale source are stale
49
+ # * All specs that are reachable only through a stale
50
+ # dependency are stale.
51
+ # * If all fresh dependencies are satisfied by the locked
52
+ # specs, then we can try to resolve locally.
53
+ #
54
+ # @param lockfile [Pathname] Path to Gemfile.lock
55
+ # @param dependencies [Array(Bundler::Dependency)] array of dependencies from Gemfile
56
+ # @param sources [Bundler::SourceList]
57
+ # @param unlock [Hash, Boolean, nil] Gems that have been requested
58
+ # to be updated or true if all gems should be updated
59
+ # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
60
+ # @param optional_groups [Array(String)] A list of optional groups
61
+ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, optional_groups = [], gemfiles = [])
62
+ unlock ||= {}
63
+
64
+ if unlock == true
65
+ @unlocking_all = true
66
+ strict = false
67
+ @unlocking_bundler = false
68
+ @unlocking = unlock
69
+ @sources_to_unlock = []
70
+ @unlocking_ruby = false
71
+ @explicit_unlocks = []
72
+ conservative = false
73
+ else
74
+ @unlocking_all = false
75
+ strict = unlock.delete(:strict)
76
+ @unlocking_bundler = unlock.delete(:bundler)
77
+ @unlocking = unlock.any? {|_k, v| !Array(v).empty? }
78
+ @sources_to_unlock = unlock.delete(:sources) || []
79
+ @unlocking_ruby = unlock.delete(:ruby)
80
+ @explicit_unlocks = unlock.delete(:gems) || []
81
+ conservative = unlock.delete(:conservative)
82
+ end
83
+
84
+ @dependencies = dependencies
85
+ @sources = sources
86
+ @optional_groups = optional_groups
87
+ @prefer_local = false
88
+ @specs = nil
89
+ @ruby_version = ruby_version
90
+ @gemfiles = gemfiles
91
+
92
+ @lockfile = lockfile
93
+ @lockfile_contents = String.new
94
+
95
+ @locked_bundler_version = nil
96
+ @resolved_bundler_version = nil
97
+
98
+ @locked_ruby_version = nil
99
+ @new_platforms = []
100
+ @removed_platforms = []
101
+ @originally_invalid_platforms = []
102
+
103
+ if lockfile_exists?
104
+ @lockfile_contents = Bundler.read_file(lockfile)
105
+ @locked_gems = LockfileParser.new(@lockfile_contents, strict: strict)
106
+ @locked_platforms = @locked_gems.platforms
107
+ @most_specific_locked_platform = @locked_gems.most_specific_locked_platform
108
+ @platforms = @locked_platforms.dup
109
+ @locked_bundler_version = @locked_gems.bundler_version
110
+ @locked_ruby_version = @locked_gems.ruby_version
111
+ @locked_deps = @locked_gems.dependencies
112
+ @originally_locked_specs = SpecSet.new(@locked_gems.specs)
113
+ @originally_locked_sources = @locked_gems.sources
114
+ @locked_checksums = @locked_gems.checksums
115
+
116
+ if @unlocking_all
117
+ @locked_specs = SpecSet.new([])
118
+ @locked_sources = []
119
+ else
120
+ @locked_specs = @originally_locked_specs
121
+ @locked_sources = @originally_locked_sources
122
+ end
123
+
124
+ locked_gem_sources = @originally_locked_sources.select {|s| s.is_a?(Source::Rubygems) }
125
+ multisource_lockfile = locked_gem_sources.size == 1 && locked_gem_sources.first.multiple_remotes?
126
+
127
+ if multisource_lockfile
128
+ msg = "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure."
129
+
130
+ Bundler::SharedHelpers.feature_removed! msg
131
+ end
132
+ else
133
+ @locked_gems = nil
134
+ @locked_platforms = []
135
+ @most_specific_locked_platform = nil
136
+ @platforms = []
137
+ @locked_deps = {}
138
+ @locked_specs = SpecSet.new([])
139
+ @locked_sources = []
140
+ @originally_locked_specs = @locked_specs
141
+ @originally_locked_sources = @locked_sources
142
+ @locked_checksums = Bundler.settings[:lockfile_checksums]
143
+ end
144
+
145
+ @unlocking_ruby ||= if @ruby_version && locked_ruby_version_object
146
+ @ruby_version.diff(locked_ruby_version_object)
147
+ end
148
+ @unlocking ||= @unlocking_ruby ||= (!@locked_ruby_version ^ !@ruby_version)
149
+
150
+ @current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
151
+
152
+ @source_changes = converge_sources
153
+ @path_changes = converge_paths
154
+
155
+ if conservative
156
+ @gems_to_unlock = @explicit_unlocks.any? ? @explicit_unlocks : @dependencies.map(&:name)
157
+ else
158
+ eager_unlock = @explicit_unlocks.map {|name| Dependency.new(name, ">= 0") }
159
+ @gems_to_unlock = @locked_specs.for(eager_unlock, platforms).map(&:name).uniq
160
+ end
161
+
162
+ @dependency_changes = converge_dependencies
163
+ @local_changes = converge_locals
164
+
165
+ check_lockfile
166
+ end
167
+
168
+ def gem_version_promoter
169
+ @gem_version_promoter ||= GemVersionPromoter.new
170
+ end
171
+
172
+ def check!
173
+ # If dependencies have changed, we need to resolve remotely. Otherwise,
174
+ # since we'll be resolving with a single local source, we may end up
175
+ # locking gems under the wrong source in the lockfile, and missing lockfile
176
+ # checksums
177
+ resolve_remotely! if @dependency_changes
178
+
179
+ # Now do a local only resolve, to verify if any gems are missing locally
180
+ sources.local_only!
181
+ resolve
182
+ end
183
+
184
+ #
185
+ # Setup sources according to the given options and the state of the
186
+ # definition.
187
+ #
188
+ # @return [Boolean] Whether fetching remote information will be necessary or not
189
+ #
190
+ def setup_domain!(options = {})
191
+ prefer_local! if options[:"prefer-local"]
192
+
193
+ sources.cached!
194
+
195
+ if options[:add_checksums] || (!options[:local] && install_needed?)
196
+ sources.remote!
197
+ true
198
+ else
199
+ Bundler.settings.set_command_option(:jobs, 1) unless install_needed? # to avoid the overhead of Bundler::Worker
200
+ sources.local!
201
+ false
202
+ end
203
+ end
204
+
205
+ def resolve_with_cache!
206
+ with_cache!
207
+
208
+ resolve
209
+ end
210
+
211
+ def with_cache!
212
+ sources.local!
213
+ sources.cached!
214
+ end
215
+
216
+ def resolve_remotely!
217
+ remotely!
218
+
219
+ resolve
220
+ end
221
+
222
+ def remotely!
223
+ sources.cached!
224
+ sources.remote!
225
+ end
226
+
227
+ def prefer_local!
228
+ @prefer_local = true
229
+
230
+ sources.prefer_local!
231
+ end
232
+
233
+ # Releases memory only needed during resolution, such as remote spec
234
+ # indexes and resolver state. Only safe to call once resolution is
235
+ # complete and the result has been materialized, since any further
236
+ # resolution will need to refetch remote specs.
237
+ def release_resolution_memory!
238
+ @resolver = nil
239
+ @resolution_base = nil
240
+ sources.release_resolution_memory!
241
+ end
242
+
243
+ # For given dependency list returns a SpecSet with Gemspec of all the required
244
+ # dependencies.
245
+ # 1. The method first resolves the dependencies specified in Gemfile
246
+ # 2. After that it tries and fetches gemspec of resolved dependencies
247
+ #
248
+ # @return [Bundler::SpecSet]
249
+ def specs
250
+ @specs ||= materialize(requested_dependencies)
251
+ end
252
+
253
+ def new_specs
254
+ specs - @locked_specs
255
+ end
256
+
257
+ def removed_specs
258
+ @locked_specs - specs
259
+ end
260
+
261
+ def missing_specs
262
+ preload_git_sources
263
+ resolve.missing_specs_for(requested_dependencies)
264
+ end
265
+
266
+ def missing_specs?
267
+ missing = missing_specs
268
+ return false if missing.empty?
269
+ Bundler.ui.debug "The definition is missing #{missing.map(&:full_name)}"
270
+ true
271
+ rescue BundlerError => e
272
+ @resolve = nil
273
+ @resolver = nil
274
+ @resolution_base = nil
275
+ @source_requirements = nil
276
+ @specs = nil
277
+
278
+ Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
279
+ true
280
+ end
281
+
282
+ def requested_specs
283
+ specs_for(requested_groups)
284
+ end
285
+
286
+ def requested_dependencies
287
+ dependencies_for(requested_groups)
288
+ end
289
+
290
+ def current_dependencies
291
+ filter_relevant(dependencies)
292
+ end
293
+
294
+ def current_locked_dependencies
295
+ filter_relevant(locked_dependencies)
296
+ end
297
+
298
+ def filter_relevant(dependencies)
299
+ dependencies.select do |d|
300
+ relevant_deps?(d)
301
+ end
302
+ end
303
+
304
+ def relevant_deps?(dep)
305
+ platforms_array = [Bundler.generic_local_platform].freeze
306
+
307
+ dep.should_include? && !dep.gem_platforms(platforms_array).empty?
308
+ end
309
+
310
+ def locked_dependencies
311
+ @locked_deps.values
312
+ end
313
+
314
+ def new_deps
315
+ @new_deps ||= @dependencies - locked_dependencies
316
+ end
317
+
318
+ def deleted_deps
319
+ @deleted_deps ||= locked_dependencies - @dependencies
320
+ end
321
+
322
+ def specs_for(groups)
323
+ return specs if groups.empty?
324
+ deps = dependencies_for(groups)
325
+ materialize(deps)
326
+ end
327
+
328
+ def dependencies_for(groups)
329
+ groups.map!(&:to_sym)
330
+ deps = current_dependencies # always returns a new array
331
+ deps.select! do |d|
332
+ d.groups.intersect?(groups)
333
+ end
334
+ deps
335
+ end
336
+
337
+ # Resolve all the dependencies specified in Gemfile. It ensures that
338
+ # dependencies that have been already resolved via locked file and are fresh
339
+ # are reused when resolving dependencies
340
+ #
341
+ # @return [SpecSet] resolved dependencies
342
+ def resolve
343
+ @resolve ||= if Bundler.frozen_bundle?
344
+ Bundler.ui.debug "Frozen, using resolution from the lockfile"
345
+ @locked_specs
346
+ elsif no_resolve_needed?
347
+ if deleted_deps.any?
348
+ Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile"
349
+ SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
350
+ else
351
+ Bundler.ui.debug "Found no changes, using resolution from the lockfile"
352
+ if @removed_platforms.any? || @locked_gems.may_include_redundant_platform_specific_gems?
353
+ SpecSet.new(filter_specs(@locked_specs, @dependencies))
354
+ else
355
+ @locked_specs
356
+ end
357
+ end
358
+ else
359
+ Bundler.ui.debug resolve_needed_reason
360
+
361
+ start_resolution
362
+ end
363
+ end
364
+
365
+ def spec_git_paths
366
+ sources.git_sources.filter_map {|s| File.realpath(s.path) if File.exist?(s.path) }
367
+ end
368
+
369
+ def groups
370
+ dependencies.flat_map(&:groups).uniq
371
+ end
372
+
373
+ def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
374
+ if [true, false, nil].include?(file_or_preserve_unknown_sections)
375
+ target_lockfile = lockfile
376
+ preserve_unknown_sections = file_or_preserve_unknown_sections
377
+ else
378
+ target_lockfile = file_or_preserve_unknown_sections
379
+ preserve_unknown_sections = preserve_unknown_sections_or_unused
380
+
381
+ suggestion = if target_lockfile == lockfile
382
+ "To fix this warning, remove it from the `Definition#lock` call."
383
+ else
384
+ "Instead, instantiate a new definition passing `#{target_lockfile}`, and call `lock` without a file argument on that definition"
385
+ end
386
+
387
+ msg = "`Definition#lock` was passed a target file argument. #{suggestion}"
388
+
389
+ Bundler::SharedHelpers.feature_removed! msg
390
+ end
391
+
392
+ write_lock(target_lockfile, preserve_unknown_sections)
393
+ end
394
+
395
+ def write_lock(file, preserve_unknown_sections)
396
+ return if Definition.no_lock || !lockfile || file.nil?
397
+
398
+ contents = to_lock
399
+
400
+ if @locked_bundler_version
401
+ locked_major = @locked_bundler_version.segments.first
402
+ current_major = bundler_version_to_lock.segments.first
403
+
404
+ updating_major = locked_major < current_major
405
+ end
406
+
407
+ preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
408
+
409
+ if File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
410
+ return if Bundler.frozen_bundle?
411
+ SharedHelpers.filesystem_access(file) { FileUtils.touch(file) }
412
+ return
413
+ end
414
+
415
+ if Bundler.frozen_bundle?
416
+ Bundler.ui.error "Cannot write a changed lockfile while frozen."
417
+ return
418
+ end
419
+
420
+ # Convert to \r\n if the existing lock has them, i.e., Windows with
421
+ # `git config core.autocrlf=true`. Detect from the bytes on disk because
422
+ # reading in text mode strips carriage returns on Windows, which would
423
+ # otherwise defeat this check and rewrite a `\r\n` lockfile with `\n`.
424
+ if File.exist?(file) && SharedHelpers.filesystem_access(file, :read) {|p| File.binread(p).include?("\r\n") }
425
+ contents.gsub!(/\n/, "\r\n")
426
+ end
427
+
428
+ begin
429
+ SharedHelpers.filesystem_access(file) do |p|
430
+ File.open(p, "wb") {|f| f.puts(contents) }
431
+ end
432
+ rescue ReadOnlyFileSystemError
433
+ raise ProductionError, lockfile_changes_summary("file system is read-only")
434
+ end
435
+ end
436
+
437
+ def locked_ruby_version
438
+ return unless ruby_version
439
+ if @unlocking_ruby || !@locked_ruby_version
440
+ Bundler::RubyVersion.system
441
+ else
442
+ @locked_ruby_version
443
+ end
444
+ end
445
+
446
+ def locked_ruby_version_object
447
+ return unless @locked_ruby_version
448
+ @locked_ruby_version_object ||= begin
449
+ unless version = RubyVersion.from_string(@locked_ruby_version)
450
+ raise LockfileError, "The Ruby version #{@locked_ruby_version} from " \
451
+ "#{@lockfile} could not be parsed. " \
452
+ "Try running bundle update --ruby to resolve this."
453
+ end
454
+ version
455
+ end
456
+ end
457
+
458
+ def bundler_version_to_lock
459
+ @resolved_bundler_version || Bundler.gem_version
460
+ end
461
+
462
+ def to_lock
463
+ require_relative "lockfile_generator"
464
+ LockfileGenerator.generate(self)
465
+ end
466
+
467
+ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
468
+ return unless Bundler.frozen_bundle?
469
+
470
+ raise ProductionError, "Frozen mode is set, but there's no lockfile" unless lockfile_exists?
471
+
472
+ msg = lockfile_changes_summary("frozen mode is set")
473
+ return unless msg
474
+
475
+ unless explicit_flag
476
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
477
+ "bundle config set frozen false"
478
+ end
479
+ msg << "\n\nIf this is a development machine, remove the #{SharedHelpers.relative_lockfile_path} " \
480
+ "freeze by running `#{suggested_command}`." if suggested_command
481
+ end
482
+
483
+ raise ProductionError, msg
484
+ end
485
+
486
+ def validate_runtime!
487
+ validate_ruby!
488
+ validate_platforms!
489
+ end
490
+
491
+ def validate_ruby!
492
+ return unless ruby_version
493
+
494
+ if diff = ruby_version.diff(Bundler::RubyVersion.system)
495
+ problem, expected, actual = diff
496
+
497
+ msg = case problem
498
+ when :engine
499
+ "Your Ruby engine is #{actual}, but your Gemfile specified #{expected}"
500
+ when :version
501
+ "Your Ruby version is #{actual}, but your Gemfile specified #{expected}"
502
+ when :engine_version
503
+ "Your #{Bundler::RubyVersion.system.engine} version is #{actual}, but your Gemfile specified #{ruby_version.engine} #{expected}"
504
+ when :patchlevel
505
+ if !expected.is_a?(String)
506
+ "The Ruby patchlevel in your Gemfile must be a string"
507
+ else
508
+ "Your Ruby patchlevel is #{actual}, but your Gemfile specified #{expected}"
509
+ end
510
+ end
511
+
512
+ raise RubyVersionMismatch, msg
513
+ end
514
+ end
515
+
516
+ def validate_platforms!
517
+ return if current_platform_locked? || @platforms.include?(Gem::Platform::RUBY)
518
+
519
+ raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
520
+ "but your local platform is #{Bundler.local_platform}. " \
521
+ "Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
522
+ end
523
+
524
+ def normalize_platforms
525
+ resolve.normalize_platforms!(current_dependencies, platforms)
526
+
527
+ @resolve = SpecSet.new(resolve.for(current_dependencies, @platforms))
528
+ end
529
+
530
+ def add_platform(platform)
531
+ return if @platforms.include?(platform)
532
+
533
+ @new_platforms << platform
534
+ @platforms << platform
535
+ end
536
+
537
+ def remove_platform(platform)
538
+ raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}" unless @platforms.include?(platform)
539
+
540
+ @removed_platforms << platform
541
+ @platforms.delete(platform)
542
+ end
543
+
544
+ def nothing_changed?
545
+ !something_changed?
546
+ end
547
+
548
+ def no_resolve_needed?
549
+ !resolve_needed?
550
+ end
551
+
552
+ def unlocking?
553
+ @unlocking
554
+ end
555
+
556
+ def add_checksums
557
+ require "rubygems/package"
558
+
559
+ @locked_checksums = true
560
+
561
+ setup_domain!(add_checksums: true)
562
+
563
+ # force materialization to real specifications, so that checksums are fetched
564
+ specs.each do |spec|
565
+ next unless spec.source.is_a?(Bundler::Source::Rubygems)
566
+ # Checksum was fetched from the compact index API.
567
+ next if !spec.source.checksum_store.missing?(spec) && !spec.source.checksum_store.empty?(spec)
568
+ # The gem isn't installed, can't compute the checksum.
569
+ next unless spec.loaded_from
570
+
571
+ package = Gem::Package.new(spec.source.cached_built_in_gem(spec))
572
+ checksum = Checksum.from_gem_package(package)
573
+ spec.source.checksum_store.register(spec, checksum)
574
+ end
575
+ end
576
+
577
+ private
578
+
579
+ def lockfile_changes_summary(update_refused_reason)
580
+ added = []
581
+ deleted = []
582
+ changed = []
583
+
584
+ added.concat @new_platforms.map {|p| "* platform: #{p}" }
585
+ deleted.concat @removed_platforms.map {|p| "* platform: #{p}" }
586
+
587
+ added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
588
+ deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
589
+
590
+ both_sources = Hash.new {|h, k| h[k] = [] }
591
+ current_dependencies.each {|d| both_sources[d.name][0] = d }
592
+ current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
593
+
594
+ both_sources.each do |name, (dep, lock_dep)|
595
+ next if dep.nil? || lock_dep.nil?
596
+
597
+ gemfile_source = dep.source || default_source
598
+ lock_source = lock_dep.source || default_source
599
+ next if lock_source.include?(gemfile_source)
600
+
601
+ gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
602
+ lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
603
+ changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
604
+ end
605
+
606
+ return unless added.any? || deleted.any? || changed.any? || resolve_needed?
607
+
608
+ msg = String.new("#{change_reason[0].upcase}#{change_reason[1..-1].strip}, but ")
609
+ msg << "the lockfile " unless msg.start_with?("Your lockfile")
610
+ msg << "can't be updated because #{update_refused_reason}"
611
+ msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
612
+ msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
613
+ msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
614
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_lockfile_path} to version control.\n" unless unlocking?
615
+ msg
616
+ end
617
+
618
+ def install_needed?
619
+ resolve_needed? || missing_specs?
620
+ end
621
+
622
+ def something_changed?
623
+ return true unless lockfile_exists?
624
+
625
+ @source_changes ||
626
+ @dependency_changes ||
627
+ @current_platform_missing ||
628
+ @new_platforms.any? ||
629
+ @path_changes ||
630
+ @local_changes ||
631
+ @missing_lockfile_dep ||
632
+ @unlocking_bundler ||
633
+ @locked_spec_with_missing_checksums ||
634
+ @locked_spec_with_empty_checksums ||
635
+ @locked_spec_with_missing_deps ||
636
+ @locked_spec_with_invalid_deps
637
+ end
638
+
639
+ def resolve_needed?
640
+ unlocking? || something_changed?
641
+ end
642
+
643
+ def should_add_extra_platforms?
644
+ !lockfile_exists? && Bundler::MatchPlatform.generic_local_platform_is_ruby? && !Bundler.settings[:force_ruby_platform]
645
+ end
646
+
647
+ def lockfile_exists?
648
+ lockfile && File.exist?(lockfile)
649
+ end
650
+
651
+ def resolver
652
+ @resolver ||= new_resolver(resolution_base)
653
+ end
654
+
655
+ def expanded_dependencies
656
+ dependencies_with_bundler + metadata_dependencies
657
+ end
658
+
659
+ def dependencies_with_bundler
660
+ return dependencies unless @unlocking_bundler
661
+ return dependencies if dependencies.any? {|d| d.name == "bundler" }
662
+
663
+ [Dependency.new("bundler", @unlocking_bundler)] + dependencies
664
+ end
665
+
666
+ def resolution_base
667
+ @resolution_base ||= begin
668
+ last_resolve = converge_locked_specs
669
+ remove_invalid_platforms!
670
+ base = new_resolution_base(last_resolve: last_resolve, unlock: @unlocking_all || @gems_to_unlock)
671
+ base = additional_base_requirements_to_prevent_downgrades(base)
672
+ base = additional_base_requirements_to_force_updates(base)
673
+ base
674
+ end
675
+ end
676
+
677
+ def filter_specs(specs, deps, skips: [])
678
+ SpecSet.new(specs).for(deps, platforms, skips: skips)
679
+ end
680
+
681
+ def materialize(dependencies)
682
+ specs = begin
683
+ resolve.materialize(dependencies)
684
+ rescue IncorrectLockfileDependencies => e
685
+ raise if Bundler.frozen_bundle?
686
+
687
+ reresolve_without([e.spec])
688
+ retry
689
+ end
690
+
691
+ missing_specs = resolve.missing_specs
692
+
693
+ if missing_specs.any?
694
+ missing_specs.each do |s|
695
+ locked_gem = @locked_specs[s.name].last
696
+ next if locked_gem.nil? || locked_gem.version != s.version || sources.local_mode?
697
+
698
+ message = if sources.implicit_global_source?
699
+ "Because your Gemfile specifies no global remote source, your bundle is locked to " \
700
+ "#{locked_gem} from #{locked_gem.source}. However, #{locked_gem} is not installed. You'll " \
701
+ "need to either add a global remote source to your Gemfile or make sure #{locked_gem} is " \
702
+ "available locally before rerunning Bundler."
703
+ else
704
+ "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
705
+ "no longer be found in that source. That means either the author of #{locked_gem} has removed it, " \
706
+ "or you no longer have access to that source. You'll need to update your bundle to a version other " \
707
+ "than #{locked_gem} that hasn't been removed, or check your credentials and access rights for " \
708
+ "#{locked_gem.source}, in order to install."
709
+ end
710
+
711
+ raise GemNotFound, message
712
+ end
713
+
714
+ missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source|
715
+ "#{missing_specs_for_source.map(&:full_name).join(", ")} in #{source}"
716
+ end
717
+
718
+ raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}"
719
+ end
720
+
721
+ partially_missing_specs = resolve.partially_missing_specs
722
+
723
+ if partially_missing_specs.any? && !sources.local_mode?
724
+ Bundler.ui.warn "Some locked specs have possibly been yanked (#{partially_missing_specs.map(&:full_name).join(", ")}). Ignoring them..."
725
+
726
+ resolve.delete(partially_missing_specs)
727
+ end
728
+
729
+ incomplete_specs = resolve.incomplete_specs
730
+ loop do
731
+ break if incomplete_specs.empty?
732
+
733
+ Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
734
+ sources.remote!
735
+ reresolve_without(incomplete_specs)
736
+ specs = resolve.materialize(dependencies)
737
+
738
+ still_incomplete_specs = resolve.incomplete_specs
739
+
740
+ if still_incomplete_specs == incomplete_specs
741
+ resolver.raise_incomplete! incomplete_specs
742
+ end
743
+
744
+ incomplete_specs = still_incomplete_specs
745
+ end
746
+
747
+ insecurely_materialized_specs = resolve.insecurely_materialized_specs
748
+
749
+ if insecurely_materialized_specs.any?
750
+ Bundler.ui.warn "The following platform specific gems are getting installed, yet the lockfile includes only their generic ruby version:\n" \
751
+ " * #{insecurely_materialized_specs.map(&:full_name).join("\n * ")}\n" \
752
+ "Please run `bundle lock --normalize-platforms` and commit the resulting lockfile.\n" \
753
+ "Alternatively, you may run `bundle lock --add-platform <list-of-platforms-that-you-want-to-support>`"
754
+ end
755
+
756
+ bundler = sources.metadata_source.specs.search(["bundler", Bundler.gem_version]).last
757
+ specs["bundler"] = bundler
758
+
759
+ specs
760
+ end
761
+
762
+ def reresolve_without(incomplete_specs)
763
+ resolution_base.delete(incomplete_specs)
764
+ @resolve = start_resolution
765
+ end
766
+
767
+ def start_resolution
768
+ local_platform_needed_for_resolvability = @most_specific_non_local_locked_platform && !@platforms.include?(Bundler.local_platform)
769
+ @platforms << Bundler.local_platform if local_platform_needed_for_resolvability
770
+
771
+ result = SpecSet.new(resolver.start)
772
+
773
+ @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
774
+
775
+ @new_platforms.each do |platform|
776
+ incomplete_specs = result.incomplete_specs_for_platform(current_dependencies, platform)
777
+
778
+ if incomplete_specs.any?
779
+ resolver.raise_incomplete! incomplete_specs
780
+ end
781
+ end
782
+
783
+ if @most_specific_non_local_locked_platform
784
+ if result.incomplete_for_platform?(current_dependencies, @most_specific_non_local_locked_platform)
785
+ @platforms.delete(@most_specific_non_local_locked_platform)
786
+ elsif local_platform_needed_for_resolvability
787
+ @platforms.delete(Bundler.local_platform)
788
+ end
789
+ end
790
+
791
+ if should_add_extra_platforms?
792
+ result.add_extra_platforms!(platforms)
793
+ elsif @originally_invalid_platforms.any?
794
+ result.add_originally_invalid_platforms!(platforms, @originally_invalid_platforms)
795
+ end
796
+
797
+ SpecSet.new(result.for(dependencies, @platforms | [Gem::Platform::RUBY]))
798
+ end
799
+
800
+ def precompute_source_requirements_for_indirect_dependencies?
801
+ if sources.non_global_rubygems_sources.all?(&:dependency_api_available?)
802
+ true
803
+ else
804
+ non_dependency_api_warning
805
+ false
806
+ end
807
+ end
808
+
809
+ def non_dependency_api_warning
810
+ non_api_sources = sources.non_global_rubygems_sources.reject(&:dependency_api_available?)
811
+ non_api_source_names = non_api_sources.map {|d| " * #{d}" }.join("\n")
812
+
813
+ msg = String.new
814
+ msg << "Your Gemfile contains scoped sources that don't implement a dependency API, namely:\n\n"
815
+ msg << non_api_source_names
816
+ msg << "\n\nUsing the above gem servers may result in installing unexpected gems. " \
817
+ "To resolve this warning, make sure you use gem servers that implement dependency APIs, " \
818
+ "such as gemstash or geminabox gem servers."
819
+ Bundler.ui.warn msg
820
+ end
821
+
822
+ def current_platform_locked?
823
+ @platforms.any? do |bundle_platform|
824
+ Bundler.generic_local_platform == bundle_platform || Bundler.local_platform === bundle_platform
825
+ end
826
+ end
827
+
828
+ def add_current_platform
829
+ return if @platforms.include?(Bundler.local_platform)
830
+
831
+ @most_specific_non_local_locked_platform = find_most_specific_locked_platform
832
+ return if @most_specific_non_local_locked_platform
833
+
834
+ @platforms << Bundler.local_platform
835
+ true
836
+ end
837
+
838
+ def find_most_specific_locked_platform
839
+ return unless current_platform_locked?
840
+
841
+ @most_specific_locked_platform
842
+ end
843
+
844
+ def resolve_needed_reason
845
+ if lockfile_exists?
846
+ if unlocking?
847
+ "Re-resolving dependencies because #{unlocking_reason}"
848
+ else
849
+ "Found changes from the lockfile, re-resolving dependencies because #{lockfile_changed_reason}"
850
+ end
851
+ else
852
+ "Resolving dependencies because there's no lockfile"
853
+ end
854
+ end
855
+
856
+ def change_reason
857
+ if resolve_needed?
858
+ if unlocking?
859
+ unlocking_reason
860
+ else
861
+ lockfile_changed_reason
862
+ end
863
+ else
864
+ "some dependencies were deleted from your gemfile"
865
+ end
866
+ end
867
+
868
+ def unlocking_reason
869
+ unlock_targets = if @gems_to_unlock.any?
870
+ ["gems", @gems_to_unlock]
871
+ elsif @sources_to_unlock.any?
872
+ ["sources", @sources_to_unlock]
873
+ end
874
+
875
+ unlock_reason = if unlock_targets
876
+ "#{unlock_targets.first}: (#{unlock_targets.last.join(", ")})"
877
+ else
878
+ @unlocking_ruby ? "ruby" : ""
879
+ end
880
+
881
+ "bundler is unlocking #{unlock_reason}"
882
+ end
883
+
884
+ def lockfile_changed_reason
885
+ [
886
+ [@source_changes, "the list of sources changed"],
887
+ [@dependency_changes, "the dependencies in your gemfile changed"],
888
+ [@current_platform_missing, "your lockfile is missing the current platform"],
889
+ [@new_platforms.any?, "you are adding a new platform to your lockfile"],
890
+ [@path_changes, "the gemspecs for path gems changed"],
891
+ [@local_changes, "the gemspecs for git local gems changed"],
892
+ [@missing_lockfile_dep, "your lockfile is missing \"#{@missing_lockfile_dep}\""],
893
+ [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
894
+ [@locked_spec_with_missing_checksums, "your lockfile is missing a CHECKSUMS entry for \"#{@locked_spec_with_missing_checksums}\""],
895
+ [@locked_spec_with_empty_checksums, "your lockfile has an empty CHECKSUMS entry for \"#{@locked_spec_with_empty_checksums}\""],
896
+ [@locked_spec_with_missing_deps, "your lockfile includes \"#{@locked_spec_with_missing_deps}\" but not some of its dependencies"],
897
+ [@locked_spec_with_invalid_deps, "your lockfile does not satisfy dependencies of \"#{@locked_spec_with_invalid_deps}\""],
898
+ ].select(&:first).map(&:last).join(", ")
899
+ end
900
+
901
+ def pretty_dep(dep)
902
+ SharedHelpers.pretty_dependency(dep)
903
+ end
904
+
905
+ # Check if the specs of the given source changed
906
+ # according to the locked source.
907
+ def specs_changed?(source)
908
+ locked = @locked_sources.find {|s| s == source }
909
+
910
+ !locked || dependencies_for_source_changed?(source, locked) || specs_for_source_changed?(source)
911
+ end
912
+
913
+ def dependencies_for_source_changed?(source, locked_source)
914
+ deps_for_source = @dependencies.select {|dep| dep.source == source }
915
+ locked_deps_for_source = locked_dependencies.select {|dep| dep.source == locked_source }
916
+
917
+ deps_for_source.uniq.sort != locked_deps_for_source.sort
918
+ end
919
+
920
+ def specs_for_source_changed?(source)
921
+ locked_index = Index.new
922
+ locked_index.use(@locked_specs.select {|s| s.replace_source_with!(source) })
923
+
924
+ !locked_index.subset?(source.specs)
925
+ rescue PathError, GitError => e
926
+ Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
927
+ false
928
+ end
929
+
930
+ # Get all locals and override their matching sources.
931
+ # Return true if any of the locals changed (for example,
932
+ # they point to a new revision) or depend on new specs.
933
+ def converge_locals
934
+ locals = []
935
+
936
+ Bundler.settings.local_overrides.map do |k, v|
937
+ spec = @dependencies.find {|s| s.name == k }
938
+ source = spec&.source
939
+ if source&.respond_to?(:local_override!)
940
+ source.unlock! if @gems_to_unlock.include?(spec.name)
941
+ locals << [source, source.local_override!(v)]
942
+ end
943
+ end
944
+
945
+ sources_with_changes = locals.select do |source, changed|
946
+ changed || specs_changed?(source)
947
+ end.map(&:first)
948
+ !sources_with_changes.each {|source| @sources_to_unlock << source.name }.empty?
949
+ end
950
+
951
+ def check_lockfile
952
+ @locked_spec_with_invalid_deps = nil
953
+ @locked_spec_with_missing_deps = nil
954
+ @locked_spec_with_missing_checksums = nil
955
+ @locked_spec_with_empty_checksums = nil
956
+
957
+ missing_deps = []
958
+ missing_checksums = []
959
+ empty_checksums = []
960
+ invalid = []
961
+
962
+ @locked_specs.each do |s|
963
+ if @locked_checksums
964
+ checksum_store = s.source.checksum_store
965
+
966
+ if checksum_store.missing?(s)
967
+ missing_checksums << s
968
+ elsif checksum_store.empty?(s)
969
+ empty_checksums << s
970
+ end
971
+ end
972
+
973
+ validation = @locked_specs.validate_deps(s)
974
+
975
+ missing_deps << s if validation == :missing
976
+ invalid << s if validation == :invalid
977
+ end
978
+
979
+ @locked_spec_with_missing_checksums = missing_checksums.first.name if missing_checksums.any?
980
+ @locked_spec_with_empty_checksums = empty_checksums.first.name if empty_checksums.any?
981
+
982
+ if missing_deps.any?
983
+ @locked_specs.delete(missing_deps)
984
+
985
+ @locked_spec_with_missing_deps = missing_deps.first.name
986
+ end
987
+
988
+ if invalid.any?
989
+ @locked_specs.delete(invalid)
990
+
991
+ @locked_spec_with_invalid_deps = invalid.first.name
992
+ end
993
+ end
994
+
995
+ def converge_paths
996
+ sources.path_sources.any? do |source|
997
+ specs_changed?(source)
998
+ end
999
+ end
1000
+
1001
+ def converge_sources
1002
+ # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
1003
+ # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
1004
+ # source in the Gemfile.lock, use the one from the Gemfile.
1005
+ changes = sources.replace_sources!(@locked_sources)
1006
+
1007
+ sources.all_sources.each do |source|
1008
+ # has to be done separately, because we want to keep the locked checksum
1009
+ # store for a source, even when doing a full update
1010
+ if @locked_checksums && @locked_gems && locked_source = @originally_locked_sources.find {|s| s == source && !s.equal?(source) }
1011
+ source.checksum_store.merge!(locked_source.checksum_store)
1012
+ end
1013
+ # If the source is unlockable and the current command allows an unlock of
1014
+ # the source (for example, you are doing a `bundle update <foo>` of a git-pinned
1015
+ # gem), unlock it. For git sources, this means to unlock the revision, which
1016
+ # will cause the `ref` used to be the most recent for the branch (or master) if
1017
+ # an explicit `ref` is not used.
1018
+ if source.respond_to?(:unlock!) && @sources_to_unlock.include?(source.name)
1019
+ source.unlock!
1020
+ changes = true
1021
+ end
1022
+ end
1023
+
1024
+ sources.metadata_source.checksum_store.merge!(@locked_gems.metadata_source.checksum_store) if @locked_gems
1025
+
1026
+ changes
1027
+ end
1028
+
1029
+ def converge_dependencies
1030
+ @missing_lockfile_dep = nil
1031
+ @changed_dependencies = []
1032
+
1033
+ @dependencies.each do |dep|
1034
+ if dep.source
1035
+ dep.source = sources.get(dep.source)
1036
+ end
1037
+ next unless relevant_deps?(dep)
1038
+
1039
+ name = dep.name
1040
+
1041
+ dep_changed = @locked_deps[name].nil?
1042
+
1043
+ unless name == "bundler"
1044
+ locked_specs = @originally_locked_specs[name]
1045
+
1046
+ if locked_specs.empty?
1047
+ @missing_lockfile_dep = name if dep_changed == false
1048
+ else
1049
+ if locked_specs.map(&:source).uniq.size > 1
1050
+ @locked_specs.delete(locked_specs.select {|s| s.source != dep.source })
1051
+ end
1052
+
1053
+ unless dep.matches_spec?(locked_specs.first)
1054
+ @gems_to_unlock << name
1055
+ dep_changed = true
1056
+ end
1057
+ end
1058
+ end
1059
+
1060
+ @changed_dependencies << name if dep_changed
1061
+ end
1062
+
1063
+ @changed_dependencies.any?
1064
+ end
1065
+
1066
+ # Remove elements from the locked specs that are expired. This will most
1067
+ # commonly happen if the Gemfile has changed since the lockfile was last
1068
+ # generated
1069
+ def converge_locked_specs
1070
+ converged = converge_specs(@locked_specs)
1071
+
1072
+ resolve = SpecSet.new(converged)
1073
+
1074
+ diff = nil
1075
+
1076
+ # Now, we unlock any sources that do not have anymore gems pinned to it
1077
+ sources.all_sources.each do |source|
1078
+ next unless source.respond_to?(:unlock!)
1079
+
1080
+ unless resolve.any? {|s| s.source == source }
1081
+ diff ||= @locked_specs.to_a - resolve.to_a
1082
+ source.unlock! if diff.any? {|s| s.source == source }
1083
+ end
1084
+ end
1085
+
1086
+ resolve
1087
+ end
1088
+
1089
+ def converge_specs(specs)
1090
+ converged = []
1091
+ deps = []
1092
+
1093
+ specs.each do |s|
1094
+ name = s.name
1095
+ next if @gems_to_unlock.include?(name)
1096
+
1097
+ dep = @dependencies.find {|d| s.satisfies?(d) }
1098
+ lockfile_source = s.source
1099
+
1100
+ if dep
1101
+ replacement_source = dep.source
1102
+
1103
+ deps << dep if !replacement_source || lockfile_source.include?(replacement_source) || new_deps.include?(dep)
1104
+ else
1105
+ parent_dep = @dependencies.find do |d|
1106
+ next unless d.source && d.source != lockfile_source
1107
+ next if d.source.is_a?(Source::Gemspec)
1108
+
1109
+ parent_locked_specs = @originally_locked_specs[d.name]
1110
+
1111
+ parent_locked_specs.any? do |parent_spec|
1112
+ parent_spec.runtime_dependencies.any? {|rd| rd.name == s.name }
1113
+ end
1114
+ end
1115
+
1116
+ if parent_dep && parent_dep.source.is_a?(Source::Path) && parent_dep.source.specs[s]&.any?
1117
+ replacement_source = parent_dep.source
1118
+ else
1119
+ replacement_source = sources.get(lockfile_source)
1120
+ end
1121
+ end
1122
+
1123
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
1124
+ s.source = replacement_source || default_source
1125
+ next if s.source_changed?
1126
+
1127
+ source = s.source
1128
+ next if @sources_to_unlock.include?(source.name)
1129
+
1130
+ # Path sources have special logic
1131
+ if source.is_a?(Source::Path)
1132
+ new_spec = source.specs[s].first
1133
+ if new_spec
1134
+ s.runtime_dependencies.replace(new_spec.runtime_dependencies)
1135
+ else
1136
+ # If the spec is no longer in the path source, unlock it. This
1137
+ # commonly happens if the version changed in the gemspec
1138
+ @gems_to_unlock << name
1139
+ end
1140
+ end
1141
+
1142
+ converged << s
1143
+ end
1144
+
1145
+ filter_specs(converged, deps, skips: @gems_to_unlock)
1146
+ end
1147
+
1148
+ def metadata_dependencies
1149
+ @metadata_dependencies ||= [
1150
+ Dependency.new("Ruby\0", Bundler::RubyVersion.system.gem_version),
1151
+ Dependency.new("RubyGems\0", Gem::VERSION),
1152
+ ]
1153
+ end
1154
+
1155
+ def source_requirements
1156
+ @source_requirements ||= find_source_requirements
1157
+ end
1158
+
1159
+ def preload_git_source_worker
1160
+ workers = Bundler.settings.installation_parallelization
1161
+
1162
+ @preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(source, _) { source.specs })
1163
+ end
1164
+
1165
+ def preload_git_sources
1166
+ if Gem.ruby_version < Gem::Version.new("3.3")
1167
+ # Ruby 3.2 has a bug that incorrectly triggers a circular dependency warning. This version will continue to
1168
+ # fetch git repositories one by one.
1169
+ return
1170
+ end
1171
+
1172
+ begin
1173
+ needed_git_sources.each {|source| preload_git_source_worker.enq(source) }
1174
+ ensure
1175
+ preload_git_source_worker.stop
1176
+ end
1177
+ end
1178
+
1179
+ # Git sources needed for the requested groups (excludes sources only used by --without groups)
1180
+ def needed_git_sources
1181
+ needed_deps = dependencies_for(requested_groups)
1182
+ sources.git_sources.select do |source|
1183
+ needed_deps.any? {|d| d.source == source }
1184
+ end
1185
+ end
1186
+
1187
+ # Git sources that should be excluded (only used by --without groups)
1188
+ def excluded_git_sources
1189
+ sources.git_sources - needed_git_sources
1190
+ end
1191
+
1192
+ def find_source_requirements
1193
+ preload_git_sources
1194
+
1195
+ # Only safe to exclude when locked_requirements (merged below) backfills the gap.
1196
+ nothing_changed = nothing_changed?
1197
+ excluded = nothing_changed ? excluded_git_sources : []
1198
+
1199
+ # Record the specs available in each gem's source, so that those
1200
+ # specs will be available later when the resolver knows where to
1201
+ # look for that gemspec (or its dependencies)
1202
+ source_requirements = if precompute_source_requirements_for_indirect_dependencies?
1203
+ all_requirements = source_map.all_requirements(excluded)
1204
+ { default: default_source }.merge(all_requirements)
1205
+ else
1206
+ { default: Source::RubygemsAggregate.new(sources, source_map, excluded) }.merge(source_map.direct_requirements)
1207
+ end
1208
+ source_requirements.merge!(source_map.locked_requirements) if nothing_changed
1209
+ metadata_dependencies.each do |dep|
1210
+ source_requirements[dep.name] = sources.metadata_source
1211
+ end
1212
+
1213
+ default_bundler_source = source_requirements["bundler"] || default_source
1214
+
1215
+ if @unlocking_bundler
1216
+ default_bundler_source.add_dependency_names("bundler")
1217
+ else
1218
+ source_requirements[:default_bundler] = default_bundler_source
1219
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
1220
+ end
1221
+
1222
+ source_requirements
1223
+ end
1224
+
1225
+ def default_source
1226
+ sources.default_source
1227
+ end
1228
+
1229
+ def requested_groups
1230
+ values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
1231
+ values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
1232
+ values
1233
+ end
1234
+
1235
+ def lockfiles_equal?(current, proposed, preserve_unknown_sections)
1236
+ if preserve_unknown_sections
1237
+ sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
1238
+ sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
1239
+ sections_to_ignore << LockfileParser::RUBY
1240
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
1241
+ pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
1242
+ whitespace_cleanup = /\n{2,}/
1243
+ current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
1244
+ proposed = proposed.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
1245
+ end
1246
+ current == proposed
1247
+ end
1248
+
1249
+ def additional_base_requirements_to_prevent_downgrades(resolution_base)
1250
+ return resolution_base unless @locked_gems
1251
+ @originally_locked_specs.each do |locked_spec|
1252
+ next if locked_spec.source.is_a?(Source::Path) || locked_spec.source_changed?
1253
+
1254
+ name = locked_spec.name
1255
+ next if @changed_dependencies.include?(name)
1256
+
1257
+ resolution_base.base_requirements[name] = Gem::Requirement.new(">= #{locked_spec.version}")
1258
+ end
1259
+ resolution_base
1260
+ end
1261
+
1262
+ def additional_base_requirements_to_force_updates(resolution_base)
1263
+ return resolution_base if @explicit_unlocks.empty?
1264
+ full_update = SpecSet.new(new_resolver_for_full_update.start)
1265
+ @explicit_unlocks.each do |name|
1266
+ version = full_update.version_for(name)
1267
+ resolution_base.base_requirements[name] = Gem::Requirement.new("= #{version}") if version
1268
+ end
1269
+ resolution_base
1270
+ end
1271
+
1272
+ def remove_invalid_platforms!
1273
+ return if Bundler.frozen_bundle?
1274
+
1275
+ skips = (@new_platforms + [Bundler.local_platform]).uniq
1276
+
1277
+ # We should probably avoid removing non-ruby platforms, since that means
1278
+ # lockfile will no longer install on those platforms, so a error to give
1279
+ # heads up to the user may be better. However, we have tests expecting
1280
+ # non ruby platform autoremoval to work, so leaving that in place for
1281
+ # now.
1282
+ skips |= platforms - [Gem::Platform::RUBY] if @dependency_changes
1283
+
1284
+ @originally_invalid_platforms = @originally_locked_specs.remove_invalid_platforms!(current_dependencies, platforms, skips: skips)
1285
+ end
1286
+
1287
+ def source_map
1288
+ @source_map ||= SourceMap.new(sources, dependencies, @locked_specs)
1289
+ end
1290
+
1291
+ def new_resolver_for_full_update
1292
+ new_resolver(unlocked_resolution_base)
1293
+ end
1294
+
1295
+ def unlocked_resolution_base
1296
+ new_resolution_base(last_resolve: SpecSet.new([]), unlock: true)
1297
+ end
1298
+
1299
+ def new_resolution_base(last_resolve:, unlock:)
1300
+ new_resolution_platforms = @current_platform_missing ? @new_platforms + [Bundler.local_platform] : @new_platforms
1301
+ Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: unlock, prerelease: gem_version_promoter.pre?, prefer_local: @prefer_local, new_platforms: new_resolution_platforms, explicit_unlocks: @explicit_unlocks)
1302
+ end
1303
+
1304
+ def new_resolver(base)
1305
+ Resolver.new(base, gem_version_promoter, @most_specific_locked_platform)
1306
+ end
1307
+ end
1308
+ end