bundler 2.2.16 → 2.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +971 -7
  3. data/README.md +4 -7
  4. data/bundler.gemspec +10 -13
  5. data/exe/bundle +12 -24
  6. data/exe/bundler +1 -1
  7. data/lib/bundler/.document +1 -0
  8. data/lib/bundler/build_metadata.rb +3 -3
  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 +1 -1
  12. data/lib/bundler/cli/check.rb +5 -3
  13. data/lib/bundler/cli/common.rb +6 -2
  14. data/lib/bundler/cli/config.rb +10 -1
  15. data/lib/bundler/cli/console.rb +2 -2
  16. data/lib/bundler/cli/doctor.rb +22 -5
  17. data/lib/bundler/cli/exec.rb +1 -6
  18. data/lib/bundler/cli/gem.rb +147 -35
  19. data/lib/bundler/cli/info.rb +28 -7
  20. data/lib/bundler/cli/init.rb +6 -2
  21. data/lib/bundler/cli/install.rb +26 -58
  22. data/lib/bundler/cli/issue.rb +4 -3
  23. data/lib/bundler/cli/list.rb +7 -1
  24. data/lib/bundler/cli/lock.rb +11 -4
  25. data/lib/bundler/cli/open.rb +7 -6
  26. data/lib/bundler/cli/outdated.rb +23 -17
  27. data/lib/bundler/cli/platform.rb +8 -6
  28. data/lib/bundler/cli/remove.rb +1 -2
  29. data/lib/bundler/cli/show.rb +1 -1
  30. data/lib/bundler/cli/update.rb +17 -8
  31. data/lib/bundler/cli/viz.rb +1 -1
  32. data/lib/bundler/cli.rb +95 -65
  33. data/lib/bundler/compact_index_client/cache.rb +1 -10
  34. data/lib/bundler/compact_index_client/updater.rb +56 -43
  35. data/lib/bundler/compact_index_client.rb +2 -8
  36. data/lib/bundler/constants.rb +1 -1
  37. data/lib/bundler/current_ruby.rb +19 -6
  38. data/lib/bundler/definition.rb +386 -419
  39. data/lib/bundler/dependency.rb +24 -71
  40. data/lib/bundler/digest.rb +71 -0
  41. data/lib/bundler/dsl.rb +48 -63
  42. data/lib/bundler/endpoint_specification.rb +15 -13
  43. data/lib/bundler/env.rb +3 -3
  44. data/lib/bundler/environment_preserver.rb +7 -3
  45. data/lib/bundler/errors.rb +30 -14
  46. data/lib/bundler/feature_flag.rb +0 -5
  47. data/lib/bundler/fetcher/base.rb +6 -8
  48. data/lib/bundler/fetcher/compact_index.rb +21 -28
  49. data/lib/bundler/fetcher/dependency.rb +2 -6
  50. data/lib/bundler/fetcher/downloader.rb +12 -10
  51. data/lib/bundler/fetcher/index.rb +1 -29
  52. data/lib/bundler/fetcher.rb +35 -30
  53. data/lib/bundler/force_platform.rb +18 -0
  54. data/lib/bundler/friendly_errors.rb +26 -39
  55. data/lib/bundler/gem_helper.rb +10 -22
  56. data/lib/bundler/gem_helpers.rb +9 -2
  57. data/lib/bundler/gem_version_promoter.rb +53 -98
  58. data/lib/bundler/graph.rb +3 -3
  59. data/lib/bundler/index.rb +14 -57
  60. data/lib/bundler/injector.rb +20 -6
  61. data/lib/bundler/inline.rb +10 -22
  62. data/lib/bundler/installer/gem_installer.rb +16 -21
  63. data/lib/bundler/installer/parallel_installer.rb +4 -34
  64. data/lib/bundler/installer/standalone.rb +53 -17
  65. data/lib/bundler/installer.rb +26 -58
  66. data/lib/bundler/lazy_specification.rb +72 -55
  67. data/lib/bundler/lockfile_generator.rb +3 -3
  68. data/lib/bundler/lockfile_parser.rb +31 -45
  69. data/lib/bundler/man/bundle-add.1 +21 -5
  70. data/lib/bundler/man/bundle-add.1.ronn +16 -4
  71. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  72. data/lib/bundler/man/bundle-cache.1 +9 -3
  73. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  74. data/lib/bundler/man/bundle-check.1 +1 -1
  75. data/lib/bundler/man/bundle-clean.1 +2 -2
  76. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  77. data/lib/bundler/man/bundle-config.1 +50 -26
  78. data/lib/bundler/man/bundle-config.1.ronn +47 -32
  79. data/lib/bundler/man/bundle-console.1 +53 -0
  80. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  81. data/lib/bundler/man/bundle-doctor.1 +1 -1
  82. data/lib/bundler/man/bundle-exec.1 +6 -6
  83. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  84. data/lib/bundler/man/bundle-gem.1 +37 -34
  85. data/lib/bundler/man/bundle-gem.1.ronn +21 -5
  86. data/lib/bundler/man/bundle-help.1 +13 -0
  87. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  88. data/lib/bundler/man/bundle-info.1 +3 -3
  89. data/lib/bundler/man/bundle-info.1.ronn +3 -3
  90. data/lib/bundler/man/bundle-init.1 +5 -1
  91. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  92. data/lib/bundler/man/bundle-inject.1 +5 -2
  93. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  94. data/lib/bundler/man/bundle-install.1 +6 -31
  95. data/lib/bundler/man/bundle-install.1.ronn +8 -31
  96. data/lib/bundler/man/bundle-list.1 +1 -1
  97. data/lib/bundler/man/bundle-lock.1 +1 -1
  98. data/lib/bundler/man/bundle-open.1 +22 -2
  99. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  100. data/lib/bundler/man/bundle-outdated.1 +15 -18
  101. data/lib/bundler/man/bundle-outdated.1.ronn +13 -19
  102. data/lib/bundler/man/bundle-platform.1 +16 -6
  103. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  104. data/lib/bundler/man/bundle-plugin.1 +81 -0
  105. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  106. data/lib/bundler/man/bundle-pristine.1 +1 -1
  107. data/lib/bundler/man/bundle-remove.1 +1 -1
  108. data/lib/bundler/man/bundle-show.1 +1 -1
  109. data/lib/bundler/man/bundle-update.1 +5 -5
  110. data/lib/bundler/man/bundle-update.1.ronn +5 -4
  111. data/lib/bundler/man/bundle-version.1 +35 -0
  112. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  113. data/lib/bundler/man/bundle-viz.1 +4 -1
  114. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  115. data/lib/bundler/man/bundle.1 +15 -10
  116. data/lib/bundler/man/bundle.1.ronn +12 -7
  117. data/lib/bundler/man/gemfile.5 +131 -81
  118. data/lib/bundler/man/gemfile.5.ronn +111 -85
  119. data/lib/bundler/man/index.txt +4 -0
  120. data/lib/bundler/match_metadata.rb +13 -0
  121. data/lib/bundler/match_platform.rb +0 -1
  122. data/lib/bundler/match_remote_metadata.rb +29 -0
  123. data/lib/bundler/mirror.rb +5 -7
  124. data/lib/bundler/plugin/api/source.rb +17 -8
  125. data/lib/bundler/plugin/index.rb +9 -6
  126. data/lib/bundler/plugin/installer/git.rb +0 -4
  127. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  128. data/lib/bundler/plugin/installer.rb +9 -4
  129. data/lib/bundler/plugin.rb +30 -9
  130. data/lib/bundler/process_lock.rb +1 -1
  131. data/lib/bundler/remote_specification.rb +7 -5
  132. data/lib/bundler/resolver/base.rb +107 -0
  133. data/lib/bundler/resolver/candidate.rb +94 -0
  134. data/lib/bundler/resolver/incompatibility.rb +15 -0
  135. data/lib/bundler/resolver/package.rb +72 -0
  136. data/lib/bundler/resolver/root.rb +25 -0
  137. data/lib/bundler/resolver/spec_group.rb +42 -94
  138. data/lib/bundler/resolver.rb +331 -381
  139. data/lib/bundler/retry.rb +1 -1
  140. data/lib/bundler/ruby_dsl.rb +7 -1
  141. data/lib/bundler/ruby_version.rb +8 -21
  142. data/lib/bundler/rubygems_ext.rb +175 -34
  143. data/lib/bundler/rubygems_gem_installer.rb +46 -14
  144. data/lib/bundler/rubygems_integration.rb +57 -108
  145. data/lib/bundler/runtime.rb +20 -18
  146. data/lib/bundler/safe_marshal.rb +31 -0
  147. data/lib/bundler/self_manager.rb +168 -0
  148. data/lib/bundler/settings.rb +101 -30
  149. data/lib/bundler/setup.rb +5 -2
  150. data/lib/bundler/shared_helpers.rb +17 -32
  151. data/lib/bundler/source/git/git_proxy.rb +242 -77
  152. data/lib/bundler/source/git.rb +82 -41
  153. data/lib/bundler/source/metadata.rb +3 -4
  154. data/lib/bundler/source/path/installer.rb +1 -22
  155. data/lib/bundler/source/path.rb +7 -7
  156. data/lib/bundler/source/rubygems.rb +158 -212
  157. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  158. data/lib/bundler/source.rb +19 -5
  159. data/lib/bundler/source_list.rb +91 -52
  160. data/lib/bundler/source_map.rb +71 -0
  161. data/lib/bundler/spec_set.rb +69 -57
  162. data/lib/bundler/stub_specification.rb +5 -3
  163. data/lib/bundler/templates/Executable +3 -5
  164. data/lib/bundler/templates/Executable.bundler +11 -16
  165. data/lib/bundler/templates/Executable.standalone +4 -4
  166. data/lib/bundler/templates/Gemfile +0 -2
  167. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  168. data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
  169. data/lib/bundler/templates/newgem/README.md.tt +7 -11
  170. data/lib/bundler/templates/newgem/Rakefile.tt +27 -3
  171. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  172. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  173. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  174. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  175. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  176. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  177. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  178. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +24 -3
  179. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  180. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  181. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -18
  182. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  183. data/lib/bundler/templates/newgem/standard.yml.tt +3 -0
  184. data/lib/bundler/templates/newgem/test/minitest/{newgem_test.rb.tt → test_newgem.rb.tt} +1 -1
  185. data/lib/bundler/ui/rg_proxy.rb +1 -1
  186. data/lib/bundler/ui/shell.rb +36 -13
  187. data/lib/bundler/ui/silent.rb +21 -5
  188. data/lib/bundler/uri_normalizer.rb +23 -0
  189. data/lib/bundler/vendor/.document +1 -0
  190. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  191. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  192. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  193. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +56 -0
  194. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +41 -74
  195. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  196. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1351 -409
  197. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  198. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  199. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  200. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  201. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  202. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  203. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  204. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  205. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  206. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  207. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  208. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  209. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  210. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  211. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  212. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  213. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  214. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  215. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  216. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  217. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
  218. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +1 -2
  219. data/lib/bundler/vendor/thor/lib/thor/actions.rb +6 -2
  220. data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +6 -0
  221. data/lib/bundler/vendor/thor/lib/thor/error.rb +9 -4
  222. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +19 -1
  223. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +23 -5
  224. data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
  225. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  226. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  227. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  228. data/lib/bundler/vendor/tsort/lib/tsort.rb +452 -0
  229. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  230. data/lib/bundler/vendor/uri/lib/uri/common.rb +76 -91
  231. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  232. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -2
  233. data/lib/bundler/vendor/uri/lib/uri/generic.rb +32 -13
  234. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -3
  235. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -2
  236. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +2 -2
  237. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  238. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -3
  239. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +16 -23
  240. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +12 -18
  241. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  242. data/lib/bundler/vendor/uri/lib/uri/ws.rb +83 -0
  243. data/lib/bundler/vendor/uri/lib/uri/wss.rb +23 -0
  244. data/lib/bundler/vendor/uri/lib/uri.rb +3 -3
  245. data/lib/bundler/vendored_persistent.rb +1 -33
  246. data/lib/bundler/{vendored_molinillo.rb → vendored_pub_grub.rb} +1 -1
  247. data/lib/bundler/{vendored_tmpdir.rb → vendored_tsort.rb} +1 -1
  248. data/lib/bundler/version.rb +5 -1
  249. data/lib/bundler/worker.rb +24 -11
  250. data/lib/bundler.rb +66 -110
  251. metadata +70 -41
  252. data/lib/bundler/dep_proxy.rb +0 -55
  253. data/lib/bundler/gemdeps.rb +0 -29
  254. data/lib/bundler/psyched_yaml.rb +0 -22
  255. data/lib/bundler/templates/gems.rb +0 -8
  256. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  257. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  258. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  259. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  260. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  261. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  262. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  263. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  264. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  265. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  266. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  267. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  268. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  269. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  270. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  271. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -143
  272. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  273. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  274. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  275. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  276. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  277. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  278. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  279. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  280. data/lib/bundler/version_ranges.rb +0 -122
@@ -3,7 +3,7 @@
3
3
  module Bundler
4
4
  class Standalone
5
5
  def initialize(groups, definition)
6
- @specs = groups.empty? ? definition.requested_specs : definition.specs_for(groups.map(&:to_sym))
6
+ @specs = definition.specs_for(groups)
7
7
  end
8
8
 
9
9
  def generate
@@ -12,12 +12,14 @@ module Bundler
12
12
  end
13
13
  File.open File.join(bundler_path, "setup.rb"), "w" do |file|
14
14
  file.puts "require 'rbconfig'"
15
- file.puts "ruby_engine = RUBY_ENGINE"
16
- file.puts "ruby_version = RbConfig::CONFIG[\"ruby_version\"]"
17
- file.puts "path = File.expand_path('..', __FILE__)"
15
+ file.puts define_path_helpers
18
16
  file.puts reverse_rubygems_kernel_mixin
19
17
  paths.each do |path|
20
- file.puts %($:.unshift File.expand_path("\#{path}/#{path}"))
18
+ if Pathname.new(path).absolute?
19
+ file.puts %($:.unshift "#{path}")
20
+ else
21
+ file.puts %($:.unshift File.expand_path("\#{__dir__}/#{path}"))
22
+ end
21
23
  end
22
24
  end
23
25
  end
@@ -28,37 +30,71 @@ module Bundler
28
30
  @specs.map do |spec|
29
31
  next if spec.name == "bundler"
30
32
  Array(spec.require_paths).map do |path|
31
- gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
33
+ gem_path(path, spec).
34
+ sub(version_dir, '#{RUBY_ENGINE}/#{Gem.ruby_api_version}').
35
+ sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
32
36
  # This is a static string intentionally. It's interpolated at a later time.
33
37
  end
34
- end.flatten
38
+ end.flatten.compact
35
39
  end
36
40
 
37
41
  def version_dir
38
- "#{Bundler::RubyVersion.system.engine}/#{RbConfig::CONFIG["ruby_version"]}"
42
+ "#{RUBY_ENGINE}/#{Gem.ruby_api_version}"
43
+ end
44
+
45
+ def extensions_dir
46
+ %r{extensions/(?<platform>[^/]+)/#{Regexp.escape(Gem.extension_api_version)}}
39
47
  end
40
48
 
41
49
  def bundler_path
42
- Bundler.root.join(Bundler.settings[:path], "bundler")
50
+ Bundler.root.join(Bundler.settings[:path].to_s, "bundler")
43
51
  end
44
52
 
45
53
  def gem_path(path, spec)
46
54
  full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
47
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
55
+ if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
56
+ full_path
57
+ else
58
+ Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
59
+ end
48
60
  rescue TypeError
49
61
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
50
62
  raise Gem::InvalidSpecificationException.new(error_message)
51
63
  end
52
64
 
65
+ def define_path_helpers
66
+ <<~'END'
67
+ unless defined?(Gem)
68
+ module Gem
69
+ def self.ruby_api_version
70
+ RbConfig::CONFIG["ruby_version"]
71
+ end
72
+
73
+ def self.extension_api_version
74
+ if 'no' == RbConfig::CONFIG['ENABLE_SHARED']
75
+ "#{ruby_api_version}-static"
76
+ else
77
+ ruby_api_version
78
+ end
79
+ end
80
+ end
81
+ end
82
+ END
83
+ end
84
+
53
85
  def reverse_rubygems_kernel_mixin
54
86
  <<~END
55
- kernel = (class << ::Kernel; self; end)
56
- [kernel, ::Kernel].each do |k|
57
- if k.private_method_defined?(:gem_original_require)
58
- private_require = k.private_method_defined?(:require)
59
- k.send(:remove_method, :require)
60
- k.send(:define_method, :require, k.instance_method(:gem_original_require))
61
- k.send(:private, :require) if private_require
87
+ if Gem.respond_to?(:discover_gems_on_require=)
88
+ Gem.discover_gems_on_require = false
89
+ else
90
+ kernel = (class << ::Kernel; self; end)
91
+ [kernel, ::Kernel].each do |k|
92
+ if k.private_method_defined?(:gem_original_require)
93
+ private_require = k.private_method_defined?(:require)
94
+ k.send(:remove_method, :require)
95
+ k.send(:define_method, :require, k.instance_method(:gem_original_require))
96
+ k.send(:private, :require) if private_require
97
+ end
62
98
  end
63
99
  end
64
100
  END
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rubygems/dependency_installer"
4
3
  require_relative "worker"
5
4
  require_relative "installer/parallel_installer"
6
5
  require_relative "installer/standalone"
@@ -14,7 +13,7 @@ module Bundler
14
13
  Installer.ambiguous_gems = []
15
14
  end
16
15
 
17
- attr_reader :post_install_messages
16
+ attr_reader :post_install_messages, :definition
18
17
 
19
18
  # Begins the installation process for Bundler.
20
19
  # For more information see the #run method on this class.
@@ -67,7 +66,7 @@ module Bundler
67
66
  # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
68
67
  # information.
69
68
  def run(options)
70
- create_bundle_path
69
+ Bundler.create_bundle_path
71
70
 
72
71
  ProcessLock.lock do
73
72
  if Bundler.frozen_bundle?
@@ -91,7 +90,7 @@ module Bundler
91
90
 
92
91
  Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
93
92
 
94
- lock unless Bundler.frozen_bundle?
93
+ lock
95
94
  Standalone.new(options[:standalone], @definition).generate if options[:standalone]
96
95
  end
97
96
  end
@@ -120,7 +119,7 @@ module Bundler
120
119
  relative_gemfile_path = relative_gemfile_path
121
120
  ruby_command = Thor::Util.ruby_command
122
121
  ruby_command = ruby_command
123
- template_path = File.expand_path("../templates/Executable", __FILE__)
122
+ template_path = File.expand_path("templates/Executable", __dir__)
124
123
  if spec.name == "bundler"
125
124
  template_path += ".bundler"
126
125
  spec.executables = %(bundle)
@@ -135,16 +134,12 @@ module Bundler
135
134
  next
136
135
  end
137
136
 
138
- mode = Bundler::WINDOWS ? "wb:UTF-8" : "w"
137
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
139
138
  require "erb"
140
- content = if RUBY_VERSION >= "2.6"
141
- ERB.new(template, :trim_mode => "-").result(binding)
142
- else
143
- ERB.new(template, nil, "-").result(binding)
144
- end
139
+ content = ERB.new(template, :trim_mode => "-").result(binding)
145
140
 
146
141
  File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
147
- if Bundler::WINDOWS || options[:all_platforms]
142
+ if Gem.win_platform? || options[:all_platforms]
148
143
  prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
149
144
  File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
150
145
  end
@@ -173,7 +168,7 @@ module Bundler
173
168
  end
174
169
  standalone_path = Bundler.root.join(path).relative_path_from(bin_path)
175
170
  standalone_path = standalone_path
176
- template = File.read(File.expand_path("../templates/Executable.standalone", __FILE__))
171
+ template = File.read(File.expand_path("templates/Executable.standalone", __dir__))
177
172
  ruby_command = Thor::Util.ruby_command
178
173
  ruby_command = ruby_command
179
174
 
@@ -182,16 +177,12 @@ module Bundler
182
177
  executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
183
178
  executable_path = executable_path
184
179
 
185
- mode = Bundler::WINDOWS ? "wb:UTF-8" : "w"
180
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
186
181
  require "erb"
187
- content = if RUBY_VERSION >= "2.6"
188
- ERB.new(template, :trim_mode => "-").result(binding)
189
- else
190
- ERB.new(template, nil, "-").result(binding)
191
- end
182
+ content = ERB.new(template, :trim_mode => "-").result(binding)
192
183
 
193
184
  File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
194
- if Bundler::WINDOWS || options[:all_platforms]
185
+ if Gem.win_platform? || options[:all_platforms]
195
186
  prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
196
187
  File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
197
188
  end
@@ -219,17 +210,7 @@ module Bundler
219
210
  return jobs
220
211
  end
221
212
 
222
- # Parallelization has some issues on Windows, so it's not yet the default
223
- return 1 if Gem.win_platform?
224
-
225
- processor_count
226
- end
227
-
228
- def processor_count
229
- require "etc"
230
- Etc.nprocessors
231
- rescue StandardError
232
- 1
213
+ Bundler.settings.processor_count
233
214
  end
234
215
 
235
216
  def load_plugins
@@ -237,31 +218,24 @@ module Bundler
237
218
 
238
219
  requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
239
220
  path_plugin_files = requested_path_gems.map do |spec|
240
- begin
241
- Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
242
- rescue TypeError
243
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
244
- raise Gem::InvalidSpecificationException, error_message
245
- end
221
+ Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
222
+ rescue TypeError
223
+ error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
224
+ raise Gem::InvalidSpecificationException, error_message
246
225
  end.flatten
247
226
  Bundler.rubygems.load_plugin_files(path_plugin_files)
248
227
  Bundler.rubygems.load_env_plugins
249
228
  end
250
229
 
251
230
  def ensure_specs_are_compatible!
252
- system_ruby = Bundler::RubyVersion.system
253
- rubygems_version = Gem::Version.create(Gem::VERSION)
254
231
  @definition.specs.each do |spec|
255
- if required_ruby_version = spec.required_ruby_version
256
- unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
257
- raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
258
- "which is incompatible with the current version, #{system_ruby}"
259
- end
232
+ unless spec.matches_current_ruby?
233
+ raise InstallError, "#{spec.full_name} requires ruby version #{spec.required_ruby_version}, " \
234
+ "which is incompatible with the current version, #{Gem.ruby_version}"
260
235
  end
261
- next unless required_rubygems_version = spec.required_rubygems_version
262
- unless required_rubygems_version.satisfied_by?(rubygems_version)
263
- raise InstallError, "#{spec.full_name} requires rubygems version #{required_rubygems_version}, " \
264
- "which is incompatible with the current version, #{rubygems_version}"
236
+ unless spec.matches_current_rubygems?
237
+ raise InstallError, "#{spec.full_name} requires rubygems version #{spec.required_rubygems_version}, " \
238
+ "which is incompatible with the current version, #{Gem.rubygems_version}"
265
239
  end
266
240
  end
267
241
  end
@@ -273,22 +247,16 @@ module Bundler
273
247
  end
274
248
  end
275
249
 
276
- def create_bundle_path
277
- SharedHelpers.filesystem_access(Bundler.bundle_path.to_s) do |p|
278
- Bundler.mkdir_p(p)
279
- end unless Bundler.bundle_path.exist?
280
- rescue Errno::EEXIST
281
- raise PathError, "Could not install to path `#{Bundler.bundle_path}` " \
282
- "because a file already exists at that path. Either remove or rename the file so the directory can be created."
283
- end
284
-
285
250
  # returns whether or not a re-resolve was needed
286
251
  def resolve_if_needed(options)
252
+ @definition.resolution_mode = options
253
+
287
254
  if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
288
255
  return false if @definition.nothing_changed? && !@definition.missing_specs?
289
256
  end
290
257
 
291
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
258
+ @definition.setup_sources_for_resolve
259
+
292
260
  true
293
261
  end
294
262
 
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "match_platform"
3
+ require_relative "force_platform"
4
4
 
5
5
  module Bundler
6
6
  class LazySpecification
7
7
  include MatchPlatform
8
+ include ForcePlatform
8
9
 
9
10
  attr_reader :name, :version, :dependencies, :platform
10
- attr_accessor :source, :remote
11
+ attr_accessor :source, :remote, :force_ruby_platform
11
12
 
12
13
  def initialize(name, version, platform, source = nil)
13
14
  @name = name
@@ -15,11 +16,11 @@ module Bundler
15
16
  @dependencies = []
16
17
  @platform = platform || Gem::Platform::RUBY
17
18
  @source = source
18
- @specification = nil
19
+ @force_ruby_platform = default_force_ruby_platform
19
20
  end
20
21
 
21
22
  def full_name
22
- if platform == Gem::Platform::RUBY || platform.nil?
23
+ @full_name ||= if platform == Gem::Platform::RUBY
23
24
  "#{@name}-#{@version}"
24
25
  else
25
26
  "#{@name}-#{@version}-#{platform}"
@@ -27,25 +28,41 @@ module Bundler
27
28
  end
28
29
 
29
30
  def ==(other)
30
- identifier == other.identifier
31
+ full_name == other.full_name
31
32
  end
32
33
 
33
34
  def eql?(other)
34
- identifier.eql?(other.identifier)
35
+ full_name.eql?(other.full_name)
35
36
  end
36
37
 
37
38
  def hash
38
- identifier.hash
39
+ full_name.hash
39
40
  end
40
41
 
42
+ ##
43
+ # Does this locked specification satisfy +dependency+?
44
+ #
45
+ # NOTE: Rubygems default requirement is ">= 0", which doesn't match
46
+ # prereleases of 0 versions, like "0.0.0.dev" or "0.0.0.SNAPSHOT". However,
47
+ # bundler users expect those to work. We need to make sure that Gemfile
48
+ # dependencies without explicit requirements (which use ">= 0" under the
49
+ # hood by default) are still valid for locked specs using this kind of
50
+ # versions. The method implements an ad-hoc fix for that. A better solution
51
+ # might be to change default rubygems requirement of dependencies to be ">=
52
+ # 0.A" but that's a major refactoring likely to break things. Hopefully we
53
+ # can attempt it in the future.
54
+ #
55
+
41
56
  def satisfies?(dependency)
42
- @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
57
+ effective_requirement = dependency.requirement == Gem::Requirement.default ? Gem::Requirement.new(">= 0.A") : dependency.requirement
58
+
59
+ @name == dependency.name && effective_requirement.satisfied_by?(Gem::Version.new(@version))
43
60
  end
44
61
 
45
62
  def to_lock
46
63
  out = String.new
47
64
 
48
- if platform == Gem::Platform::RUBY || platform.nil?
65
+ if platform == Gem::Platform::RUBY
49
66
  out << " #{name} (#{version})\n"
50
67
  else
51
68
  out << " #{name} (#{version}-#{platform})\n"
@@ -59,76 +76,74 @@ module Bundler
59
76
  out
60
77
  end
61
78
 
62
- def __materialize__
63
- @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
64
- source.gemspec.tap {|s| s.source = source }
79
+ def materialize_for_installation
80
+ source.local!
81
+
82
+ matching_specs = source.specs.search(use_exact_resolved_specifications? ? self : [name, version])
83
+ return self if matching_specs.empty?
84
+
85
+ candidates = if use_exact_resolved_specifications?
86
+ matching_specs
65
87
  else
66
- search_object = if source.is_a?(Source::Path)
67
- Dependency.new(name, version)
68
- else
69
- ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
70
- end
71
- platform_object = Gem::Platform.new(platform)
72
- candidates = source.specs.search(search_object)
73
- same_platform_candidates = candidates.select do |spec|
74
- MatchPlatform.platforms_match?(spec.platform, platform_object)
75
- end
76
- installable_candidates = same_platform_candidates.select do |spec|
77
- !spec.is_a?(EndpointSpecification) ||
78
- (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
79
- spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
88
+ target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
89
+
90
+ installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
91
+
92
+ specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
93
+ return specification unless specification.nil?
94
+
95
+ if target_platform != platform
96
+ installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
80
97
  end
81
- search = installable_candidates.last || same_platform_candidates.last
82
- search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
83
- search
98
+
99
+ installable_candidates
84
100
  end
101
+
102
+ __materialize__(candidates)
85
103
  end
86
104
 
87
- def respond_to?(*args)
88
- super || @specification ? @specification.respond_to?(*args) : nil
105
+ # If in frozen mode, we fallback to a non-installable candidate because by
106
+ # doing this we avoid re-resolving and potentially end up changing the
107
+ # lock file, which is not allowed. In that case, we will give a proper error
108
+ # about the mismatch higher up the stack, right before trying to install the
109
+ # bad gem.
110
+ def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
111
+ search = candidates.reverse.find do |spec|
112
+ spec.is_a?(StubSpecification) ||
113
+ (spec.matches_current_ruby? &&
114
+ spec.matches_current_rubygems?)
115
+ end
116
+ if search.nil? && fallback_to_non_installable
117
+ search = candidates.last
118
+ else
119
+ search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
120
+ end
121
+ search
89
122
  end
90
123
 
91
124
  def to_s
92
- @__to_s ||= if platform == Gem::Platform::RUBY || platform.nil?
125
+ @to_s ||= if platform == Gem::Platform::RUBY
93
126
  "#{name} (#{version})"
94
127
  else
95
128
  "#{name} (#{version}-#{platform})"
96
129
  end
97
130
  end
98
131
 
99
- def identifier
100
- @__identifier ||= [name, version, platform_string]
101
- end
102
-
103
132
  def git_version
104
133
  return unless source.is_a?(Bundler::Source::Git)
105
134
  " #{source.revision[0..6]}"
106
135
  end
107
136
 
108
- protected
109
-
110
- def platform_string
111
- platform_string = platform.to_s
112
- platform_string == Index::RUBY ? Index::NULL : platform_string
113
- end
114
-
115
137
  private
116
138
 
117
- def to_ary
118
- nil
119
- end
120
-
121
- def method_missing(method, *args, &blk)
122
- raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
123
-
124
- return super unless respond_to?(method)
125
-
126
- @specification.send(method, *args, &blk)
139
+ def use_exact_resolved_specifications?
140
+ @use_exact_resolved_specifications ||= !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
127
141
  end
128
142
 
129
143
  #
130
144
  # For backwards compatibility with existing lockfiles, if the most specific
131
- # locked platform is RUBY, we keep the previous behaviour of resolving the
145
+ # locked platform is not a specific platform like x86_64-linux or
146
+ # universal-java-11, then we keep the previous behaviour of resolving the
132
147
  # best platform variant at materiliazation time. For previous bundler
133
148
  # versions (before 2.2.0) this was always the case (except when the lockfile
134
149
  # only included non-ruby platforms), but we're also keeping this behaviour
@@ -136,7 +151,9 @@ module Bundler
136
151
  # explicitly add a more specific platform.
137
152
  #
138
153
  def ruby_platform_materializes_to_ruby_platform?
139
- !Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform]
154
+ generic_platform = generic_local_platform == Gem::Platform::JAVA ? Gem::Platform::JAVA : Gem::Platform::RUBY
155
+
156
+ !Bundler.most_specific_locked_platform?(generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
140
157
  end
141
158
  end
142
159
  end
@@ -45,7 +45,7 @@ module Bundler
45
45
  # gems with the same name, but different platform
46
46
  # are ordered consistently
47
47
  specs.sort_by(&:full_name).each do |spec|
48
- next if spec.name == "bundler".freeze
48
+ next if spec.name == "bundler"
49
49
  out << spec.to_lock
50
50
  end
51
51
  end
@@ -60,7 +60,7 @@ module Bundler
60
60
  handled = []
61
61
  definition.dependencies.sort_by(&:to_s).each do |dep|
62
62
  next if handled.include?(dep.name)
63
- out << dep.to_lock
63
+ out << dep.to_lock << "\n"
64
64
  handled << dep.name
65
65
  end
66
66
  end
@@ -71,7 +71,7 @@ module Bundler
71
71
  end
72
72
 
73
73
  def add_bundled_with
74
- add_section("BUNDLED WITH", definition.locked_bundler_version.to_s)
74
+ add_section("BUNDLED WITH", definition.bundler_version_to_lock.to_s)
75
75
  end
76
76
 
77
77
  def add_section(name, value)
@@ -1,29 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- #--
4
- # Some versions of the Bundler 1.1 RC series introduced corrupted
5
- # lockfiles. There were two major problems:
6
- #
7
- # * multiple copies of the same GIT section appeared in the lockfile
8
- # * when this happened, those sections got multiple copies of gems
9
- # in those sections.
10
- #
11
- # As a result, Bundler 1.1 contains code that fixes the earlier
12
- # corruption. We will remove this fix-up code in Bundler 1.2.
13
-
14
3
  module Bundler
15
4
  class LockfileParser
16
5
  attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
17
6
 
18
- BUNDLED = "BUNDLED WITH".freeze
19
- DEPENDENCIES = "DEPENDENCIES".freeze
20
- PLATFORMS = "PLATFORMS".freeze
21
- RUBY = "RUBY VERSION".freeze
22
- GIT = "GIT".freeze
23
- GEM = "GEM".freeze
24
- PATH = "PATH".freeze
25
- PLUGIN = "PLUGIN SOURCE".freeze
26
- SPECS = " specs:".freeze
7
+ BUNDLED = "BUNDLED WITH"
8
+ DEPENDENCIES = "DEPENDENCIES"
9
+ PLATFORMS = "PLATFORMS"
10
+ RUBY = "RUBY VERSION"
11
+ GIT = "GIT"
12
+ GEM = "GEM"
13
+ PATH = "PATH"
14
+ PLUGIN = "PLUGIN SOURCE"
15
+ SPECS = " specs:"
27
16
  OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
28
17
  SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
29
18
 
@@ -37,6 +26,7 @@ module Bundler
37
26
  KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
38
27
 
39
28
  ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
29
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
40
30
 
41
31
  def self.sections_in_lockfile(lockfile_contents)
42
32
  lockfile_contents.scan(/^\w[\w ]*$/).uniq
@@ -57,6 +47,16 @@ module Bundler
57
47
  attributes
58
48
  end
59
49
 
50
+ def self.bundled_with
51
+ lockfile = Bundler.default_lockfile
52
+ return unless lockfile.file?
53
+
54
+ lockfile_contents = Bundler.read_file(lockfile)
55
+ return unless lockfile_contents.include?(BUNDLED)
56
+
57
+ lockfile_contents.split(BUNDLED).last.strip
58
+ end
59
+
60
60
  def initialize(lockfile)
61
61
  @platforms = []
62
62
  @sources = []
@@ -64,7 +64,7 @@ module Bundler
64
64
  @state = nil
65
65
  @specs = {}
66
66
 
67
- if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
67
+ if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
68
68
  raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
69
69
  "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
70
70
  end
@@ -81,37 +81,29 @@ module Bundler
81
81
  @state = :ruby
82
82
  elsif line == BUNDLED
83
83
  @state = :bundled_with
84
- elsif line =~ /^[^\s]/
84
+ elsif /^[^\s]/.match?(line)
85
85
  @state = nil
86
86
  elsif @state
87
87
  send("parse_#{@state}", line)
88
88
  end
89
89
  end
90
- @specs = @specs.values.sort_by(&:identifier)
91
- warn_for_outdated_bundler_version
90
+ @specs = @specs.values.sort_by(&:full_name)
92
91
  rescue ArgumentError => e
93
92
  Bundler.ui.debug(e)
94
93
  raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
95
94
  "and then `bundle install` to generate a new lockfile."
96
95
  end
97
96
 
98
- def warn_for_outdated_bundler_version
99
- return unless bundler_version
100
- prerelease_text = bundler_version.prerelease? ? " --pre" : ""
101
- current_version = Gem::Version.create(Bundler::VERSION)
102
- return unless current_version < bundler_version
103
- Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
104
- "than the version that created the lockfile (#{bundler_version}). We suggest you to " \
105
- "upgrade to the version that created the lockfile by running `gem install " \
106
- "bundler:#{bundler_version}#{prerelease_text}`.\n"
97
+ def may_include_redundant_platform_specific_gems?
98
+ bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
107
99
  end
108
100
 
109
101
  private
110
102
 
111
103
  TYPES = {
112
- GIT => Bundler::Source::Git,
113
- GEM => Bundler::Source::Rubygems,
114
- PATH => Bundler::Source::Path,
104
+ GIT => Bundler::Source::Git,
105
+ GEM => Bundler::Source::Rubygems,
106
+ PATH => Bundler::Source::Path,
115
107
  PLUGIN => Bundler::Plugin,
116
108
  }.freeze
117
109
 
@@ -124,12 +116,7 @@ module Bundler
124
116
  @sources << @current_source
125
117
  when GIT
126
118
  @current_source = TYPES[@type].from_lock(@opts)
127
- # Strip out duplicate GIT sections
128
- if @sources.include?(@current_source)
129
- @current_source = @sources.find {|s| s == @current_source }
130
- else
131
- @sources << @current_source
132
- end
119
+ @sources << @current_source
133
120
  when GEM
134
121
  @opts["remotes"] = Array(@opts.delete("remote")).reverse
135
122
  @current_source = TYPES[@type].from_lock(@opts)
@@ -211,10 +198,9 @@ module Bundler
211
198
  platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
212
199
  @current_spec = LazySpecification.new(name, version, platform)
213
200
  @current_spec.source = @current_source
201
+ @current_source.add_dependency_names(name)
214
202
 
215
- # Avoid introducing multiple copies of the same spec (caused by
216
- # duplicate GIT sections)
217
- @specs[@current_spec.identifier] ||= @current_spec
203
+ @specs[@current_spec.full_name] = @current_spec
218
204
  elsif spaces.size == 6
219
205
  version = version.split(",").map(&:strip) if version
220
206
  dep = Gem::Dependency.new(name, version)