bundler 2.1.4 → 2.3.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2164 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +10 -8
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -11
  9. data/lib/bundler/cli/add.rb +1 -1
  10. data/lib/bundler/cli/binstubs.rb +6 -2
  11. data/lib/bundler/cli/cache.rb +3 -8
  12. data/lib/bundler/cli/check.rb +4 -2
  13. data/lib/bundler/cli/clean.rb +1 -1
  14. data/lib/bundler/cli/common.rb +30 -3
  15. data/lib/bundler/cli/config.rb +10 -1
  16. data/lib/bundler/cli/console.rb +1 -1
  17. data/lib/bundler/cli/doctor.rb +25 -6
  18. data/lib/bundler/cli/exec.rb +5 -10
  19. data/lib/bundler/cli/fund.rb +36 -0
  20. data/lib/bundler/cli/gem.rb +219 -28
  21. data/lib/bundler/cli/info.rb +38 -6
  22. data/lib/bundler/cli/init.rb +3 -3
  23. data/lib/bundler/cli/inject.rb +1 -1
  24. data/lib/bundler/cli/install.rb +20 -52
  25. data/lib/bundler/cli/issue.rb +5 -4
  26. data/lib/bundler/cli/list.rb +19 -11
  27. data/lib/bundler/cli/lock.rb +5 -1
  28. data/lib/bundler/cli/open.rb +1 -2
  29. data/lib/bundler/cli/outdated.rb +95 -75
  30. data/lib/bundler/cli/platform.rb +1 -1
  31. data/lib/bundler/cli/plugin.rb +10 -0
  32. data/lib/bundler/cli/pristine.rb +5 -0
  33. data/lib/bundler/cli/remove.rb +1 -2
  34. data/lib/bundler/cli/show.rb +2 -2
  35. data/lib/bundler/cli/update.rb +20 -9
  36. data/lib/bundler/cli.rb +101 -81
  37. data/lib/bundler/compact_index_client/cache.rb +6 -23
  38. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  39. data/lib/bundler/compact_index_client/updater.rb +13 -22
  40. data/lib/bundler/compact_index_client.rb +3 -9
  41. data/lib/bundler/current_ruby.rb +6 -4
  42. data/lib/bundler/definition.rb +201 -385
  43. data/lib/bundler/dep_proxy.rb +16 -9
  44. data/lib/bundler/dependency.rb +23 -14
  45. data/lib/bundler/digest.rb +71 -0
  46. data/lib/bundler/dsl.rb +71 -74
  47. data/lib/bundler/endpoint_specification.rb +22 -12
  48. data/lib/bundler/env.rb +2 -2
  49. data/lib/bundler/environment_preserver.rb +29 -2
  50. data/lib/bundler/errors.rb +20 -3
  51. data/lib/bundler/feature_flag.rb +0 -8
  52. data/lib/bundler/fetcher/base.rb +1 -1
  53. data/lib/bundler/fetcher/compact_index.rb +11 -16
  54. data/lib/bundler/fetcher/downloader.rb +10 -7
  55. data/lib/bundler/fetcher/index.rb +2 -30
  56. data/lib/bundler/fetcher.rb +18 -23
  57. data/lib/bundler/friendly_errors.rb +25 -43
  58. data/lib/bundler/gem_helper.rb +53 -31
  59. data/lib/bundler/gem_helpers.rb +36 -25
  60. data/lib/bundler/gem_version_promoter.rb +4 -4
  61. data/lib/bundler/graph.rb +1 -1
  62. data/lib/bundler/index.rb +9 -9
  63. data/lib/bundler/injector.rb +33 -6
  64. data/lib/bundler/inline.rb +3 -2
  65. data/lib/bundler/installer/gem_installer.rb +7 -25
  66. data/lib/bundler/installer/parallel_installer.rb +46 -25
  67. data/lib/bundler/installer/standalone.rb +30 -10
  68. data/lib/bundler/installer.rb +36 -59
  69. data/lib/bundler/lazy_specification.rb +62 -26
  70. data/lib/bundler/lockfile_generator.rb +2 -2
  71. data/lib/bundler/lockfile_parser.rb +17 -46
  72. data/lib/bundler/man/.document +1 -0
  73. data/{man → lib/bundler/man}/bundle-add.1 +10 -2
  74. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +7 -1
  75. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  76. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  77. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  78. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  79. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  80. data/{man → lib/bundler/man}/bundle-config.1 +44 -45
  81. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +59 -60
  82. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  85. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  86. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  87. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  88. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  89. data/{man → lib/bundler/man}/bundle-install.1 +31 -4
  90. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +27 -5
  91. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  92. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  93. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  94. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  95. data/{man → lib/bundler/man}/bundle-outdated.1 +3 -10
  96. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +1 -10
  97. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  98. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  99. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  100. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  101. data/{man → lib/bundler/man}/bundle-update.1 +5 -5
  102. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +5 -4
  103. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  104. data/{man → lib/bundler/man}/bundle.1 +1 -1
  105. data/{man → lib/bundler/man}/gemfile.5 +31 -5
  106. data/{man → lib/bundler/man}/gemfile.5.ronn +13 -5
  107. data/lib/bundler/mirror.rb +2 -2
  108. data/lib/bundler/plugin/api/source.rb +23 -7
  109. data/lib/bundler/plugin/dsl.rb +1 -1
  110. data/lib/bundler/plugin/index.rb +13 -1
  111. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  112. data/lib/bundler/plugin/installer.rb +11 -11
  113. data/lib/bundler/plugin/source_list.rb +5 -1
  114. data/lib/bundler/plugin.rb +56 -11
  115. data/lib/bundler/process_lock.rb +1 -1
  116. data/lib/bundler/remote_specification.rb +12 -2
  117. data/lib/bundler/resolver/spec_group.rb +58 -55
  118. data/lib/bundler/resolver.rb +176 -177
  119. data/lib/bundler/retry.rb +2 -2
  120. data/lib/bundler/ruby_version.rb +2 -15
  121. data/lib/bundler/rubygems_ext.rb +137 -28
  122. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  123. data/lib/bundler/rubygems_integration.rb +69 -133
  124. data/lib/bundler/runtime.rb +22 -25
  125. data/lib/bundler/self_manager.rb +168 -0
  126. data/lib/bundler/settings.rb +144 -65
  127. data/lib/bundler/setup.rb +2 -2
  128. data/lib/bundler/shared_helpers.rb +12 -27
  129. data/lib/bundler/similarity_detector.rb +1 -1
  130. data/lib/bundler/source/git/git_proxy.rb +88 -84
  131. data/lib/bundler/source/git.rb +43 -23
  132. data/lib/bundler/source/metadata.rb +3 -7
  133. data/lib/bundler/source/path/installer.rb +10 -10
  134. data/lib/bundler/source/path.rb +10 -4
  135. data/lib/bundler/source/rubygems/remote.rb +1 -1
  136. data/lib/bundler/source/rubygems.rb +126 -116
  137. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  138. data/lib/bundler/source.rb +22 -1
  139. data/lib/bundler/source_list.rb +101 -63
  140. data/lib/bundler/source_map.rb +71 -0
  141. data/lib/bundler/spec_set.rb +26 -41
  142. data/lib/bundler/stub_specification.rb +25 -7
  143. data/lib/bundler/templates/Executable +2 -4
  144. data/lib/bundler/templates/Executable.bundler +8 -8
  145. data/lib/bundler/templates/Executable.standalone +2 -4
  146. data/lib/bundler/templates/Gemfile +0 -2
  147. data/lib/bundler/templates/gems.rb +0 -3
  148. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  149. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  150. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  151. data/lib/bundler/templates/newgem/README.md.tt +9 -14
  152. data/lib/bundler/templates/newgem/Rakefile.tt +32 -5
  153. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  154. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  155. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  156. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  157. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  158. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  159. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  160. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  161. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  162. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  163. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  164. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  165. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  166. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  167. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/test_newgem.rb.tt} +3 -1
  168. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  169. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  170. data/lib/bundler/ui/shell.rb +6 -6
  171. data/lib/bundler/uri_credentials_filter.rb +3 -1
  172. data/lib/bundler/vendor/.document +1 -0
  173. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  174. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  175. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  176. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  177. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  178. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  179. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  180. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  181. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  182. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  183. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +37 -5
  184. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +34 -28
  185. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  186. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  187. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  188. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  189. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  190. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  191. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  192. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  193. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +9 -7
  194. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  195. data/lib/bundler/vendor/thor/lib/thor/actions.rb +7 -3
  196. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  197. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  198. data/lib/bundler/vendor/thor/lib/thor/error.rb +10 -5
  199. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  200. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +28 -9
  201. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +27 -6
  202. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  203. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  204. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  206. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  207. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  208. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  209. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  210. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  211. data/lib/bundler/vendor/uri/lib/uri/common.rb +17 -80
  212. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +0 -1
  213. data/lib/bundler/vendor/uri/lib/uri/generic.rb +5 -6
  214. data/lib/bundler/vendor/uri/lib/uri/http.rb +0 -1
  215. data/lib/bundler/vendor/uri/lib/uri/https.rb +0 -1
  216. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  217. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +0 -1
  218. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +1 -14
  219. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +1 -12
  220. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  221. data/lib/bundler/vendor/uri/lib/uri/ws.rb +84 -0
  222. data/lib/bundler/vendor/uri/lib/uri/wss.rb +22 -0
  223. data/lib/bundler/vendor/uri/lib/uri.rb +0 -1
  224. data/lib/bundler/vendored_persistent.rb +0 -7
  225. data/lib/bundler/vendored_tmpdir.rb +4 -0
  226. data/lib/bundler/vendored_tsort.rb +4 -0
  227. data/lib/bundler/version.rb +1 -1
  228. data/lib/bundler/worker.rb +20 -5
  229. data/lib/bundler/yaml_serializer.rb +1 -1
  230. data/lib/bundler.rb +64 -43
  231. metadata +94 -91
  232. data/lib/bundler/gemdeps.rb +0 -29
  233. data/lib/bundler/psyched_yaml.rb +0 -37
  234. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  235. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  236. data/man/bundle-add.1.txt +0 -58
  237. data/man/bundle-binstubs.1.txt +0 -48
  238. data/man/bundle-cache.1.txt +0 -78
  239. data/man/bundle-check.1.txt +0 -33
  240. data/man/bundle-clean.1.txt +0 -26
  241. data/man/bundle-config.1.txt +0 -528
  242. data/man/bundle-doctor.1.txt +0 -44
  243. data/man/bundle-exec.1.txt +0 -178
  244. data/man/bundle-gem.1.txt +0 -91
  245. data/man/bundle-info.1.txt +0 -21
  246. data/man/bundle-init.1.txt +0 -34
  247. data/man/bundle-inject.1.txt +0 -32
  248. data/man/bundle-install.1.txt +0 -401
  249. data/man/bundle-list.1.txt +0 -43
  250. data/man/bundle-lock.1.txt +0 -93
  251. data/man/bundle-open.1.txt +0 -29
  252. data/man/bundle-outdated.1.txt +0 -131
  253. data/man/bundle-platform.1.txt +0 -57
  254. data/man/bundle-pristine.1.txt +0 -44
  255. data/man/bundle-remove.1.txt +0 -34
  256. data/man/bundle-show.1.txt +0 -27
  257. data/man/bundle-update.1.txt +0 -390
  258. data/man/bundle-viz.1.txt +0 -39
  259. data/man/bundle.1.txt +0 -116
  260. data/man/gemfile.5.txt +0 -649
  261. /data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  262. /data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  263. /data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  264. /data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  265. /data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  266. /data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  267. /data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  268. /data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  269. /data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  270. /data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  271. /data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  272. /data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  273. /data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  274. /data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  275. /data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  276. /data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  277. /data/{man → lib/bundler/man}/index.txt +0 -0
@@ -1,30 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "set"
4
-
5
3
  module Bundler
6
4
  class SourceList
7
5
  attr_reader :path_sources,
8
6
  :git_sources,
9
7
  :plugin_sources,
10
- :global_rubygems_source,
8
+ :global_path_source,
11
9
  :metadata_source
12
10
 
11
+ def global_rubygems_source
12
+ @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
13
+ end
14
+
13
15
  def initialize
14
16
  @path_sources = []
15
17
  @git_sources = []
16
18
  @plugin_sources = []
17
19
  @global_rubygems_source = nil
18
- @rubygems_aggregate = rubygems_aggregate_class.new
20
+ @global_path_source = nil
19
21
  @rubygems_sources = []
20
22
  @metadata_source = Source::Metadata.new
23
+
24
+ @merged_gem_lockfile_sections = false
25
+ end
26
+
27
+ def merged_gem_lockfile_sections?
28
+ @merged_gem_lockfile_sections
29
+ end
30
+
31
+ def merged_gem_lockfile_sections!(replacement_source)
32
+ @merged_gem_lockfile_sections = true
33
+ @global_rubygems_source = replacement_source
34
+ end
35
+
36
+ def aggregate_global_source?
37
+ global_rubygems_source.multiple_remotes?
38
+ end
39
+
40
+ def implicit_global_source?
41
+ global_rubygems_source.no_remotes?
21
42
  end
22
43
 
23
44
  def add_path_source(options = {})
24
45
  if options["gemspec"]
25
46
  add_source_to_list Source::Gemspec.new(options), path_sources
26
47
  else
27
- add_source_to_list Source::Path.new(options), path_sources
48
+ path_source = add_source_to_list Source::Path.new(options), path_sources
49
+ @global_path_source ||= path_source if options["global"]
50
+ path_source
28
51
  end
29
52
  end
30
53
 
@@ -35,32 +58,31 @@ module Bundler
35
58
  end
36
59
 
37
60
  def add_rubygems_source(options = {})
38
- add_source_to_list Source::Rubygems.new(options), @rubygems_sources
61
+ new_source = Source::Rubygems.new(options)
62
+ return @global_rubygems_source if @global_rubygems_source == new_source
63
+
64
+ add_source_to_list new_source, @rubygems_sources
39
65
  end
40
66
 
41
67
  def add_plugin_source(source, options = {})
42
68
  add_source_to_list Plugin.source(source).new(options), @plugin_sources
43
69
  end
44
70
 
45
- def global_rubygems_source=(uri)
46
- if Bundler.feature_flag.disable_multisource?
47
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri)
48
- end
49
- add_rubygems_remote(uri)
50
- end
51
-
52
- def add_rubygems_remote(uri)
53
- return if Bundler.feature_flag.disable_multisource?
54
- @rubygems_aggregate.add_remote(uri)
55
- @rubygems_aggregate
71
+ def add_global_rubygems_remote(uri)
72
+ global_rubygems_source.add_remote(uri)
73
+ global_rubygems_source
56
74
  end
57
75
 
58
76
  def default_source
59
- global_rubygems_source || @rubygems_aggregate
77
+ global_path_source || global_rubygems_source
60
78
  end
61
79
 
62
80
  def rubygems_sources
63
- @rubygems_sources + [default_source]
81
+ non_global_rubygems_sources + [global_rubygems_source]
82
+ end
83
+
84
+ def non_global_rubygems_sources
85
+ @rubygems_sources
64
86
  end
65
87
 
66
88
  def rubygems_remotes
@@ -71,37 +93,51 @@ module Bundler
71
93
  path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
72
94
  end
73
95
 
96
+ def non_default_explicit_sources
97
+ all_sources - [default_source, metadata_source]
98
+ end
99
+
74
100
  def get(source)
75
- source_list_for(source).find {|s| equal_source?(source, s) || equivalent_source?(source, s) }
101
+ source_list_for(source).find {|s| equivalent_source?(source, s) }
76
102
  end
77
103
 
78
104
  def lock_sources
79
- lock_sources = (path_sources + git_sources + plugin_sources).sort_by(&:to_s)
80
- if Bundler.feature_flag.disable_multisource?
81
- lock_sources + rubygems_sources.sort_by(&:to_s)
105
+ lock_other_sources + lock_rubygems_sources
106
+ end
107
+
108
+ def lock_other_sources
109
+ (path_sources + git_sources + plugin_sources).sort_by(&:identifier)
110
+ end
111
+
112
+ def lock_rubygems_sources
113
+ if merged_gem_lockfile_sections?
114
+ [combine_rubygems_sources]
82
115
  else
83
- lock_sources << combine_rubygems_sources
116
+ rubygems_sources.sort_by(&:identifier)
84
117
  end
85
118
  end
86
119
 
87
120
  # Returns true if there are changes
88
121
  def replace_sources!(replacement_sources)
89
- return true if replacement_sources.empty?
122
+ return false if replacement_sources.empty?
90
123
 
91
- [path_sources, git_sources, plugin_sources].each do |source_list|
92
- source_list.map! do |source|
93
- replacement_sources.find {|s| s == source } || source
94
- end
95
- end
124
+ @rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
125
+ @global_rubygems_source = global_replacement_source(replacement_sources)
96
126
 
97
- replacement_rubygems = !Bundler.feature_flag.disable_multisource? &&
98
- replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
99
- @rubygems_aggregate = replacement_rubygems if replacement_rubygems
127
+ different_sources?(lock_sources, replacement_sources)
128
+ end
100
129
 
101
- return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
102
- return true if replacement_rubygems && rubygems_remotes.to_set != replacement_rubygems.remotes.to_set
130
+ # Returns true if there are changes
131
+ def expired_sources?(replacement_sources)
132
+ return false if replacement_sources.empty?
133
+
134
+ lock_sources = dup_with_replaced_sources(replacement_sources).lock_sources
135
+
136
+ different_sources?(lock_sources, replacement_sources)
137
+ end
103
138
 
104
- false
139
+ def local_only!
140
+ all_sources.each(&:local_only!)
105
141
  end
106
142
 
107
143
  def cached!
@@ -112,11 +148,33 @@ module Bundler
112
148
  all_sources.each(&:remote!)
113
149
  end
114
150
 
115
- def rubygems_primary_remotes
116
- @rubygems_aggregate.remotes
151
+ private
152
+
153
+ def dup_with_replaced_sources(replacement_sources)
154
+ new_source_list = dup
155
+ new_source_list.replace_sources!(replacement_sources)
156
+ new_source_list
157
+ end
158
+
159
+ def map_sources(replacement_sources)
160
+ [@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
161
+ sources.map do |source|
162
+ replacement_sources.find {|s| s == source } || source
163
+ end
164
+ end
117
165
  end
118
166
 
119
- private
167
+ def global_replacement_source(replacement_sources)
168
+ replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
169
+ return global_rubygems_source unless replacement_source
170
+
171
+ replacement_source.local!
172
+ replacement_source
173
+ end
174
+
175
+ def different_sources?(lock_sources, replacement_sources)
176
+ !equivalent_sources?(lock_sources, replacement_sources)
177
+ end
120
178
 
121
179
  def rubygems_aggregate_class
122
180
  Source::Rubygems
@@ -147,37 +205,17 @@ module Bundler
147
205
  if source.uri =~ /^git\:/
148
206
  Bundler.ui.warn "The git source `#{source.uri}` uses the `git` protocol, " \
149
207
  "which transmits data without encryption. Disable this warning with " \
150
- "`bundle config set git.allow_insecure true`, or switch to the `https` " \
208
+ "`bundle config set --local git.allow_insecure true`, or switch to the `https` " \
151
209
  "protocol to keep your data secure."
152
210
  end
153
211
  end
154
212
 
155
- def equal_sources?(lock_sources, replacement_sources)
156
- lock_sources.to_set == replacement_sources.to_set
157
- end
158
-
159
- def equal_source?(source, other_source)
160
- source == other_source
161
- end
162
-
163
- def equivalent_source?(source, other_source)
164
- return false unless Bundler.settings[:allow_deployment_source_credential_changes] && source.is_a?(Source::Rubygems)
165
-
166
- equivalent_rubygems_sources?([source], [other_source])
167
- end
168
-
169
213
  def equivalent_sources?(lock_sources, replacement_sources)
170
- return false unless Bundler.settings[:allow_deployment_source_credential_changes]
171
-
172
- lock_rubygems_sources, lock_other_sources = lock_sources.partition {|s| s.is_a?(Source::Rubygems) }
173
- replacement_rubygems_sources, replacement_other_sources = replacement_sources.partition {|s| s.is_a?(Source::Rubygems) }
174
-
175
- equivalent_rubygems_sources?(lock_rubygems_sources, replacement_rubygems_sources) && equal_sources?(lock_other_sources, replacement_other_sources)
214
+ lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
176
215
  end
177
216
 
178
- def equivalent_rubygems_sources?(lock_sources, replacement_sources)
179
- actual_remotes = replacement_sources.map(&:remotes).flatten.uniq
180
- lock_sources.all? {|s| s.equivalent_remotes?(actual_remotes) }
217
+ def equivalent_source?(source, other_source)
218
+ source == other_source
181
219
  end
182
220
  end
183
221
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class SourceMap
5
+ attr_reader :sources, :dependencies, :locked_specs
6
+
7
+ def initialize(sources, dependencies, locked_specs)
8
+ @sources = sources
9
+ @dependencies = dependencies
10
+ @locked_specs = locked_specs
11
+ end
12
+
13
+ def pinned_spec_names(skip = nil)
14
+ direct_requirements.reject {|_, source| source == skip }.keys
15
+ end
16
+
17
+ def all_requirements
18
+ requirements = direct_requirements.dup
19
+
20
+ unmet_deps = sources.non_default_explicit_sources.map do |source|
21
+ (source.spec_names - pinned_spec_names).each do |indirect_dependency_name|
22
+ previous_source = requirements[indirect_dependency_name]
23
+ if previous_source.nil?
24
+ requirements[indirect_dependency_name] = source
25
+ else
26
+ no_ambiguous_sources = Bundler.feature_flag.bundler_3_mode?
27
+
28
+ msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
29
+ msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
30
+ msg << "You #{no_ambiguous_sources ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
31
+ msg = msg.join("\n")
32
+
33
+ raise SecurityError, msg if no_ambiguous_sources
34
+ Bundler.ui.warn "Warning: #{msg}"
35
+ end
36
+ end
37
+
38
+ source.unmet_deps
39
+ end
40
+
41
+ sources.default_source.add_dependency_names(unmet_deps.flatten - requirements.keys)
42
+
43
+ requirements
44
+ end
45
+
46
+ def direct_requirements
47
+ @direct_requirements ||= begin
48
+ requirements = {}
49
+ default = sources.default_source
50
+ dependencies.each do |dep|
51
+ dep_source = dep.source || default
52
+ dep_source.add_dependency_names(dep.name)
53
+ requirements[dep.name] = dep_source
54
+ end
55
+ requirements
56
+ end
57
+ end
58
+
59
+ def locked_requirements
60
+ @locked_requirements ||= begin
61
+ requirements = {}
62
+ locked_specs.each do |locked_spec|
63
+ source = locked_spec.source
64
+ source.add_dependency_names(locked_spec.name)
65
+ requirements[locked_spec.name] = source
66
+ end
67
+ requirements
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tsort"
4
- require "set"
3
+ require_relative "vendored_tsort"
5
4
 
6
5
  module Bundler
7
6
  class SpecSet
@@ -12,31 +11,28 @@ module Bundler
12
11
  @specs = specs
13
12
  end
14
13
 
15
- def for(dependencies, skip = [], check = false, match_current_platform = false, raise_on_missing = true)
16
- handled = Set.new
14
+ def for(dependencies, check = false, match_current_platform = false)
15
+ handled = []
17
16
  deps = dependencies.dup
18
17
  specs = []
19
- skip += ["bundler"]
20
18
 
21
19
  loop do
22
20
  break unless dep = deps.shift
23
- next if !handled.add?(dep) || skip.include?(dep.name)
21
+ next if handled.any?{|d| d.name == dep.name && (match_current_platform || d.__platform == dep.__platform) } || dep.name == "bundler"
24
22
 
25
- if spec = spec_for_dependency(dep, match_current_platform)
26
- specs << spec
23
+ handled << dep
27
24
 
28
- spec.dependencies.each do |d|
25
+ specs_for_dep = spec_for_dependency(dep, match_current_platform)
26
+ if specs_for_dep.any?
27
+ match_current_platform ? specs += specs_for_dep : specs |= specs_for_dep
28
+
29
+ specs_for_dep.first.dependencies.each do |d|
29
30
  next if d.type == :development
30
- d = DepProxy.new(d, dep.__platform) unless match_current_platform
31
+ d = DepProxy.get_proxy(d, dep.__platform) unless match_current_platform
31
32
  deps << d
32
33
  end
33
34
  elsif check
34
35
  return false
35
- elsif raise_on_missing
36
- others = lookup[dep.name] if match_current_platform
37
- message = "Unable to find a spec satisfying #{dep} in the set. Perhaps the lockfile is corrupted?"
38
- message += " Found #{others.join(", ")} that did not match the current platform." if others && !others.empty?
39
- raise GemNotFound, message
40
36
  end
41
37
  end
42
38
 
@@ -44,11 +40,7 @@ module Bundler
44
40
  specs << spec
45
41
  end
46
42
 
47
- check ? true : SpecSet.new(specs)
48
- end
49
-
50
- def valid_for?(deps)
51
- self.for(deps, [], true)
43
+ check ? true : specs
52
44
  end
53
45
 
54
46
  def [](key)
@@ -74,38 +66,35 @@ module Bundler
74
66
  lookup.dup
75
67
  end
76
68
 
77
- def materialize(deps, missing_specs = nil)
78
- materialized = self.for(deps, [], false, true, !missing_specs).to_a
79
- deps = materialized.map(&:name).uniq
69
+ def materialize(deps)
70
+ materialized = self.for(deps, false, true)
71
+
80
72
  materialized.map! do |s|
81
73
  next s unless s.is_a?(LazySpecification)
82
- s.source.dependency_names = deps if s.source.respond_to?(:dependency_names=)
83
- spec = s.__materialize__
84
- unless spec
85
- unless missing_specs
86
- raise GemNotFound, "Could not find #{s.full_name} in any of the sources"
87
- end
88
- missing_specs << s
89
- end
90
- spec
74
+ s.source.local!
75
+ s.__materialize__ || s
91
76
  end
92
- SpecSet.new(missing_specs ? materialized.compact : materialized)
77
+ SpecSet.new(materialized)
93
78
  end
94
79
 
95
80
  # Materialize for all the specs in the spec set, regardless of what platform they're for
96
81
  # This is in contrast to how for does platform filtering (and specifically different from how `materialize` calls `for` only for the current platform)
97
82
  # @return [Array<Gem::Specification>]
98
83
  def materialized_for_all_platforms
99
- names = @specs.map(&:name).uniq
100
84
  @specs.map do |s|
101
85
  next s unless s.is_a?(LazySpecification)
102
- s.source.dependency_names = names if s.source.respond_to?(:dependency_names=)
86
+ s.source.local!
87
+ s.source.remote!
103
88
  spec = s.__materialize__
104
89
  raise GemNotFound, "Could not find #{s.full_name} in any of the sources" unless spec
105
90
  spec
106
91
  end
107
92
  end
108
93
 
94
+ def missing_specs
95
+ @specs.select {|s| s.is_a?(LazySpecification) }
96
+ end
97
+
109
98
  def merge(set)
110
99
  arr = sorted.dup
111
100
  set.each do |set_spec|
@@ -147,7 +136,7 @@ module Bundler
147
136
  sorted.each(&b)
148
137
  end
149
138
 
150
- private
139
+ private
151
140
 
152
141
  def sorted
153
142
  rake = @specs.find {|s| s.name == "rake" }
@@ -183,11 +172,7 @@ module Bundler
183
172
  def spec_for_dependency(dep, match_current_platform)
184
173
  specs_for_platforms = lookup[dep.name]
185
174
  if match_current_platform
186
- Bundler.rubygems.platforms.reverse_each do |pl|
187
- match = GemHelpers.select_best_platform_match(specs_for_platforms, pl)
188
- return match if match
189
- end
190
- nil
175
+ GemHelpers.select_best_platform_match(specs_for_platforms.select{|s| Gem::Platform.match_spec?(s) }, Bundler.local_platform)
191
176
  else
192
177
  GemHelpers.select_best_platform_match(specs_for_platforms, dep.__platform)
193
178
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "remote_specification"
4
-
5
3
  module Bundler
6
4
  class StubSpecification < RemoteSpecification
7
5
  def self.from_stub(stub)
@@ -28,9 +26,21 @@ module Bundler
28
26
 
29
27
  # @!group Stub Delegates
30
28
 
31
- # This is defined directly to avoid having to load every installed spec
29
+ def manually_installed?
30
+ # This is for manually installed gems which are gems that were fixed in place after a
31
+ # failed installation. Once the issue was resolved, the user then manually created
32
+ # the gem specification using the instructions provided by `gem help install`
33
+ installed_by_version == Gem::Version.new(0)
34
+ end
35
+
36
+ # This is defined directly to avoid having to loading the full spec
32
37
  def missing_extensions?
33
- stub.missing_extensions?
38
+ return false if default_gem?
39
+ return false if extensions.empty?
40
+ return false if File.exist? gem_build_complete_path
41
+ return false if manually_installed?
42
+
43
+ true
34
44
  end
35
45
 
36
46
  def activated
@@ -41,8 +51,16 @@ module Bundler
41
51
  stub.instance_variable_set(:@activated, activated)
42
52
  end
43
53
 
44
- def default_gem
45
- stub.default_gem
54
+ def extensions
55
+ stub.extensions
56
+ end
57
+
58
+ def gem_build_complete_path
59
+ File.join(extension_dir, "gem.build_complete")
60
+ end
61
+
62
+ def default_gem?
63
+ stub.default_gem?
46
64
  end
47
65
 
48
66
  def full_gem_path
@@ -71,7 +89,7 @@ module Bundler
71
89
  stub.raw_require_paths
72
90
  end
73
91
 
74
- private
92
+ private
75
93
 
76
94
  def _remote_specification
77
95
  @_remote_specification ||= begin
@@ -8,11 +8,9 @@
8
8
  # this file is here to facilitate running it.
9
9
  #
10
10
 
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
13
- Pathname.new(__FILE__).realpath)
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("<%= relative_gemfile_path %>", __dir__)
14
12
 
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
13
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
14
 
17
15
  if File.file?(bundle_binstub)
18
16
  if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
@@ -41,7 +41,7 @@ m = Module.new do
41
41
  gemfile = ENV["BUNDLE_GEMFILE"]
42
42
  return gemfile if gemfile && !gemfile.empty?
43
43
 
44
- File.expand_path("../<%= relative_gemfile_path %>", __FILE__)
44
+ File.expand_path("<%= relative_gemfile_path %>", __dir__)
45
45
  end
46
46
 
47
47
  def lockfile
@@ -60,20 +60,20 @@ m = Module.new do
60
60
  Regexp.last_match(1)
61
61
  end
62
62
 
63
- def bundler_version
64
- @bundler_version ||=
63
+ def bundler_requirement
64
+ @bundler_requirement ||=
65
65
  env_var_version || cli_arg_version ||
66
- lockfile_version
66
+ bundler_requirement_for(lockfile_version)
67
67
  end
68
68
 
69
- def bundler_requirement
70
- return "#{Gem::Requirement.default}.a" unless bundler_version
69
+ def bundler_requirement_for(version)
70
+ return "#{Gem::Requirement.default}.a" unless version
71
71
 
72
- bundler_gem_version = Gem::Version.new(bundler_version)
72
+ bundler_gem_version = Gem::Version.new(version)
73
73
 
74
74
  requirement = bundler_gem_version.approximate_recommendation
75
75
 
76
- return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
76
+ return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77
77
 
78
78
  requirement += ".a" if bundler_gem_version.prerelease?
79
79
 
@@ -6,9 +6,7 @@
6
6
  # this file is here to facilitate running it.
7
7
  #
8
8
 
9
- require "pathname"
10
- path = Pathname.new(__FILE__)
11
- $:.unshift File.expand_path "../<%= standalone_path %>", path.realpath
9
+ $:.unshift File.expand_path "<%= standalone_path %>", __dir__
12
10
 
13
11
  require "bundler/setup"
14
- load File.expand_path "../<%= executable_path %>", path.realpath
12
+ load File.expand_path "<%= executable_path %>", __dir__
@@ -2,6 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
-
7
5
  # gem "rails"
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # A sample gems.rb
4
3
  source "https://rubygems.org"
5
4
 
6
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
7
-
8
5
  # gem "rails"
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - <%= Time.now.strftime('%F') %>
4
+
5
+ - Initial release