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
@@ -20,18 +20,38 @@ module Bundler
20
20
  @dependency_names = []
21
21
  @allow_remote = false
22
22
  @allow_cached = false
23
+ @allow_local = options["allow_local"] || false
23
24
  @caches = [cache_path, *Bundler.rubygems.gem_cache]
24
25
 
25
- Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
26
+ Array(options["remotes"]).reverse_each {|r| add_remote(r) }
27
+ end
28
+
29
+ def local_only!
30
+ @specs = nil
31
+ @allow_local = true
32
+ @allow_cached = false
33
+ @allow_remote = false
34
+ end
35
+
36
+ def local!
37
+ return if @allow_local
38
+
39
+ @specs = nil
40
+ @allow_local = true
26
41
  end
27
42
 
28
43
  def remote!
44
+ return if @allow_remote
45
+
29
46
  @specs = nil
30
47
  @allow_remote = true
31
48
  end
32
49
 
33
50
  def cached!
51
+ return if @allow_cached
52
+
34
53
  @specs = nil
54
+ @allow_local = true
35
55
  @allow_cached = true
36
56
  end
37
57
 
@@ -49,9 +69,17 @@ module Bundler
49
69
  o.is_a?(Rubygems) && (o.credless_remotes - credless_remotes).empty?
50
70
  end
51
71
 
72
+ def multiple_remotes?
73
+ @remotes.size > 1
74
+ end
75
+
76
+ def no_remotes?
77
+ @remotes.size == 0
78
+ end
79
+
52
80
  def can_lock?(spec)
53
- return super if Bundler.feature_flag.disable_multisource?
54
- spec.source.is_a?(Rubygems)
81
+ return super unless multiple_remotes?
82
+ include?(spec.source)
55
83
  end
56
84
 
57
85
  def options
@@ -73,12 +101,27 @@ module Bundler
73
101
  def to_s
74
102
  if remotes.empty?
75
103
  "locally installed gems"
76
- else
77
- remote_names = remotes.map(&:to_s).join(", ")
104
+ elsif @allow_remote && @allow_cached && @allow_local
105
+ "rubygems repository #{remote_names}, cached gems or installed locally"
106
+ elsif @allow_remote && @allow_local
78
107
  "rubygems repository #{remote_names} or installed locally"
108
+ elsif @allow_remote
109
+ "rubygems repository #{remote_names}"
110
+ elsif @allow_cached && @allow_local
111
+ "cached gems or installed locally"
112
+ else
113
+ "locally installed gems"
79
114
  end
80
115
  end
81
- alias_method :name, :to_s
116
+
117
+ def identifier
118
+ if remotes.empty?
119
+ "locally installed gems"
120
+ else
121
+ "rubygems repository #{remote_names}"
122
+ end
123
+ end
124
+ alias_method :name, :identifier
82
125
 
83
126
  def specs
84
127
  @specs ||= begin
@@ -87,7 +130,7 @@ module Bundler
87
130
  # small_idx.use large_idx.
88
131
  idx = @allow_remote ? remote_specs.dup : Index.new
89
132
  idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
90
- idx.use(installed_specs, :override_dupes)
133
+ idx.use(installed_specs, :override_dupes) if @allow_local
91
134
  idx
92
135
  end
93
136
  end
@@ -96,7 +139,7 @@ module Bundler
96
139
  force = opts[:force]
97
140
  ensure_builtin_gems_cached = opts[:ensure_builtin_gems_cached]
98
141
 
99
- if ensure_builtin_gems_cached && builtin_gem?(spec)
142
+ if ensure_builtin_gems_cached && spec.default_gem?
100
143
  if !cached_path(spec)
101
144
  cached_built_in_gem(spec) unless spec.remote
102
145
  force = true
@@ -105,7 +148,7 @@ module Bundler
105
148
  end
106
149
  end
107
150
 
108
- if (installed?(spec) || Plugin.installed?(spec.name)) && !force
151
+ if installed?(spec) && !force
109
152
  print_using_message "Using #{version_message(spec)}"
110
153
  return nil # no post-install message
111
154
  end
@@ -123,7 +166,7 @@ module Bundler
123
166
  begin
124
167
  s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
125
168
  spec.__swap__(s)
126
- rescue StandardError
169
+ rescue Gem::Package::FormatError
127
170
  Bundler.rm_rf(path)
128
171
  raise
129
172
  end
@@ -135,6 +178,7 @@ module Bundler
135
178
  Bundler.ui.confirm message
136
179
 
137
180
  path = cached_gem(spec)
181
+ raise GemNotFound, "Could not find #{spec.file_name} for installation" unless path
138
182
  if requires_sudo?
139
183
  install_path = Bundler.tmp(spec.full_name)
140
184
  bin_path = install_path.join("bin")
@@ -145,20 +189,19 @@ module Bundler
145
189
 
146
190
  Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
147
191
 
148
- installed_spec = nil
149
- Bundler.rubygems.preserve_paths do
150
- installed_spec = Bundler::RubyGemsGemInstaller.at(
151
- path,
152
- :install_dir => install_path.to_s,
153
- :bin_dir => bin_path.to_s,
154
- :ignore_dependencies => true,
155
- :wrappers => true,
156
- :env_shebang => true,
157
- :build_args => opts[:build_args],
158
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
159
- :bundler_extension_cache_path => extension_cache_path(spec)
160
- ).install
161
- end
192
+ require_relative "../rubygems_gem_installer"
193
+
194
+ installed_spec = Bundler::RubyGemsGemInstaller.at(
195
+ path,
196
+ :install_dir => install_path.to_s,
197
+ :bin_dir => bin_path.to_s,
198
+ :ignore_dependencies => true,
199
+ :wrappers => true,
200
+ :env_shebang => true,
201
+ :build_args => opts[:build_args],
202
+ :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
203
+ :bundler_extension_cache_path => extension_cache_path(spec)
204
+ ).install
162
205
  spec.full_gem_path = installed_spec.full_gem_path
163
206
 
164
207
  # SUDO HAX
@@ -195,12 +238,8 @@ module Bundler
195
238
  end
196
239
 
197
240
  def cache(spec, custom_path = nil)
198
- if builtin_gem?(spec)
199
- cached_path = cached_built_in_gem(spec)
200
- else
201
- cached_path = cached_gem(spec)
202
- end
203
- raise GemNotFound, "Missing gem file '#{spec.full_name}.gem'." unless cached_path
241
+ cached_path = cached_gem(spec)
242
+ raise GemNotFound, "Missing gem file '#{spec.file_name}'." unless cached_path
204
243
  return if File.dirname(cached_path) == Bundler.app_cache.to_s
205
244
  Bundler.ui.info " * #{File.basename(cached_path)}"
206
245
  FileUtils.cp(cached_path, Bundler.app_cache(custom_path))
@@ -227,25 +266,16 @@ module Bundler
227
266
  @remotes.unshift(uri) unless @remotes.include?(uri)
228
267
  end
229
268
 
230
- def equivalent_remotes?(other_remotes)
231
- other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
232
- end
233
-
234
- def replace_remotes(other_remotes, allow_equivalent = false)
235
- return false if other_remotes == @remotes
236
-
237
- equivalent = allow_equivalent && equivalent_remotes?(other_remotes)
238
-
239
- @remotes = []
240
- other_remotes.reverse_each do |r|
241
- add_remote r.to_s
269
+ def spec_names
270
+ if @allow_remote && dependency_api_available?
271
+ remote_specs.spec_names
272
+ else
273
+ []
242
274
  end
243
-
244
- !equivalent
245
275
  end
246
276
 
247
277
  def unmet_deps
248
- if @allow_remote && api_fetchers.any?
278
+ if @allow_remote && dependency_api_available?
249
279
  remote_specs.unmet_dependency_names
250
280
  else
251
281
  []
@@ -261,7 +291,7 @@ module Bundler
261
291
 
262
292
  def double_check_for(unmet_dependency_names)
263
293
  return unless @allow_remote
264
- return unless api_fetchers.any?
294
+ return unless dependency_api_available?
265
295
 
266
296
  unmet_dependency_names = unmet_dependency_names.call
267
297
  unless unmet_dependency_names.nil?
@@ -283,21 +313,32 @@ module Bundler
283
313
  remote_specs.each do |spec|
284
314
  case spec
285
315
  when EndpointSpecification, Gem::Specification, StubSpecification, LazySpecification
286
- names.concat(spec.runtime_dependencies)
316
+ names.concat(spec.runtime_dependencies.map(&:name))
287
317
  when RemoteSpecification # from the full index
288
318
  return nil
289
319
  else
290
320
  raise "unhandled spec type (#{spec.inspect})"
291
321
  end
292
322
  end
293
- names.map!(&:name) if names
294
323
  names
295
324
  end
296
325
 
297
- protected
326
+ def dependency_api_available?
327
+ api_fetchers.any?
328
+ end
329
+
330
+ protected
331
+
332
+ def remote_names
333
+ remotes.map(&:to_s).join(", ")
334
+ end
298
335
 
299
336
  def credless_remotes
300
- remotes.map(&method(:suppress_configured_credentials))
337
+ if Bundler.settings[:allow_deployment_source_credential_changes]
338
+ remotes.map(&method(:remove_auth))
339
+ else
340
+ remotes.map(&method(:suppress_configured_credentials))
341
+ end
301
342
  end
302
343
 
303
344
  def remotes_for_spec(spec)
@@ -312,14 +353,17 @@ module Bundler
312
353
  end
313
354
 
314
355
  def cached_gem(spec)
315
- cached_gem = cached_path(spec)
316
- unless cached_gem
317
- raise Bundler::GemNotFound, "Could not find #{spec.file_name} for installation"
356
+ if spec.default_gem?
357
+ cached_built_in_gem(spec)
358
+ else
359
+ cached_path(spec)
318
360
  end
319
- cached_gem
320
361
  end
321
362
 
322
363
  def cached_path(spec)
364
+ global_cache_path = download_cache_path(spec)
365
+ @caches << global_cache_path if global_cache_path
366
+
323
367
  possibilities = @caches.map {|p| "#{p}/#{spec.file_name}" }
324
368
  possibilities.find {|p| File.exist?(p) }
325
369
  end
@@ -354,7 +398,6 @@ module Bundler
354
398
  def installed_specs
355
399
  @installed_specs ||= Index.build do |idx|
356
400
  Bundler.rubygems.all_specs.reverse_each do |spec|
357
- next if spec.name == "bundler"
358
401
  spec.source = self
359
402
  if Bundler.rubygems.spec_missing_extensions?(spec, false)
360
403
  Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
@@ -367,16 +410,12 @@ module Bundler
367
410
 
368
411
  def cached_specs
369
412
  @cached_specs ||= begin
370
- idx = installed_specs.dup
413
+ idx = @allow_local ? installed_specs.dup : Index.new
371
414
 
372
415
  Dir["#{cache_path}/*.gem"].each do |gemfile|
373
416
  next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
374
417
  s ||= Bundler.rubygems.spec_from_gem(gemfile)
375
418
  s.source = self
376
- if Bundler.rubygems.spec_missing_extensions?(s, false)
377
- Bundler.ui.debug "Source #{self} is ignoring #{s} because it is missing extensions"
378
- next
379
- end
380
419
  idx << s
381
420
  end
382
421
 
@@ -409,11 +448,11 @@ module Bundler
409
448
  def fetch_names(fetchers, dependency_names, index, override_dupes)
410
449
  fetchers.each do |f|
411
450
  if dependency_names
412
- Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug?
451
+ Bundler.ui.info "Fetching gem metadata from #{URICredentialsFilter.credential_filtered_uri(f.uri)}", Bundler.ui.debug?
413
452
  index.use f.specs_with_retry(dependency_names, self), override_dupes
414
453
  Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
415
454
  else
416
- Bundler.ui.info "Fetching source index from #{f.uri}"
455
+ Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}"
417
456
  index.use f.specs_with_retry(nil, self), override_dupes
418
457
  end
419
458
  end
@@ -424,19 +463,26 @@ module Bundler
424
463
 
425
464
  spec.fetch_platform
426
465
 
427
- download_path = requires_sudo? ? Bundler.tmp(spec.full_name) : rubygems_dir
428
- gem_path = "#{rubygems_dir}/cache/#{spec.full_name}.gem"
466
+ cache_path = download_cache_path(spec) || default_cache_path_for(rubygems_dir)
467
+ gem_path = "#{cache_path}/#{spec.file_name}"
468
+
469
+ if requires_sudo?
470
+ download_path = Bundler.tmp(spec.full_name)
471
+ download_cache_path = default_cache_path_for(download_path)
472
+ else
473
+ download_cache_path = cache_path
474
+ end
429
475
 
430
- SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
476
+ SharedHelpers.filesystem_access(download_cache_path) do |p|
431
477
  FileUtils.mkdir_p(p)
432
478
  end
433
- download_gem(spec, download_path)
479
+ download_gem(spec, download_cache_path)
434
480
 
435
481
  if requires_sudo?
436
- SharedHelpers.filesystem_access("#{rubygems_dir}/cache") do |p|
482
+ SharedHelpers.filesystem_access(cache_path) do |p|
437
483
  Bundler.mkdir_p(p)
438
484
  end
439
- Bundler.sudo "mv #{download_path}/cache/#{spec.full_name}.gem #{gem_path}"
485
+ Bundler.sudo "mv #{download_cache_path}/#{spec.file_name} #{gem_path}"
440
486
  end
441
487
 
442
488
  gem_path
@@ -444,16 +490,8 @@ module Bundler
444
490
  Bundler.rm_rf(download_path) if requires_sudo?
445
491
  end
446
492
 
447
- def builtin_gem?(spec)
448
- # Ruby 2.1, where all included gems have this summary
449
- return true if spec.summary =~ /is bundled with Ruby/
450
-
451
- # Ruby 2.0, where gemspecs are stored in specifications/default/
452
- spec.loaded_from && spec.loaded_from.include?("specifications/default/")
453
- end
454
-
455
493
  def installed?(spec)
456
- installed_specs[spec].any?
494
+ installed_specs[spec].any? && !spec.deleted_gem?
457
495
  end
458
496
 
459
497
  def requires_sudo?
@@ -464,11 +502,15 @@ module Bundler
464
502
  Bundler.rubygems.gem_dir
465
503
  end
466
504
 
505
+ def default_cache_path_for(dir)
506
+ "#{dir}/cache"
507
+ end
508
+
467
509
  def cache_path
468
510
  Bundler.app_cache
469
511
  end
470
512
 
471
- private
513
+ private
472
514
 
473
515
  # Checks if the requested spec exists in the global cache. If it does,
474
516
  # we copy it to the download path, and if it does not, we download it.
@@ -476,45 +518,13 @@ module Bundler
476
518
  # @param [Specification] spec
477
519
  # the spec we want to download or retrieve from the cache.
478
520
  #
479
- # @param [String] download_path
521
+ # @param [String] download_cache_path
480
522
  # the local directory the .gem will end up in.
481
523
  #
482
- def download_gem(spec, download_path)
483
- local_path = File.join(download_path, "cache/#{spec.full_name}.gem")
484
-
485
- if (cache_path = download_cache_path(spec)) && cache_path.file?
486
- SharedHelpers.filesystem_access(local_path) do
487
- FileUtils.cp(cache_path, local_path)
488
- end
489
- else
490
- uri = spec.remote.uri
491
- Bundler.ui.confirm("Fetching #{version_message(spec)}")
492
- rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
493
- if rubygems_local_path != local_path
494
- FileUtils.mv(rubygems_local_path, local_path)
495
- end
496
- cache_globally(spec, local_path)
497
- end
498
- end
499
-
500
- # Checks if the requested spec exists in the global cache. If it does
501
- # not, we create the relevant global cache subdirectory if it does not
502
- # exist and copy the spec from the local cache to the global cache.
503
- #
504
- # @param [Specification] spec
505
- # the spec we want to copy to the global cache.
506
- #
507
- # @param [String] local_cache_path
508
- # the local directory from which we want to copy the .gem.
509
- #
510
- def cache_globally(spec, local_cache_path)
511
- return unless cache_path = download_cache_path(spec)
512
- return if cache_path.exist?
513
-
514
- SharedHelpers.filesystem_access(cache_path.dirname, &:mkpath)
515
- SharedHelpers.filesystem_access(cache_path) do
516
- FileUtils.cp(local_cache_path, cache_path)
517
- end
524
+ def download_gem(spec, download_cache_path)
525
+ uri = spec.remote.uri
526
+ Bundler.ui.confirm("Fetching #{version_message(spec)}")
527
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path)
518
528
  end
519
529
 
520
530
  # Returns the global cache path of the calling Rubygems::Source object.
@@ -533,7 +543,7 @@ module Bundler
533
543
  return unless remote = spec.remote
534
544
  return unless cache_slug = remote.cache_slug
535
545
 
536
- Bundler.user_cache.join("gems", cache_slug, spec.file_name)
546
+ Bundler.user_cache.join("gems", cache_slug)
537
547
  end
538
548
 
539
549
  def extension_cache_slug(spec)
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class Source
5
+ class RubygemsAggregate
6
+ attr_reader :source_map, :sources
7
+
8
+ def initialize(sources, source_map)
9
+ @sources = sources
10
+ @source_map = source_map
11
+
12
+ @index = build_index
13
+ end
14
+
15
+ def specs
16
+ @index
17
+ end
18
+
19
+ def identifier
20
+ to_s
21
+ end
22
+
23
+ def to_s
24
+ "any of the sources"
25
+ end
26
+
27
+ private
28
+
29
+ def build_index
30
+ Index.build do |idx|
31
+ dependency_names = source_map.pinned_spec_names
32
+
33
+ sources.all_sources.each do |source|
34
+ source.dependency_names = dependency_names - source_map.pinned_spec_names(source)
35
+ idx.add_source source.specs
36
+ dependency_names.concat(source.unmet_deps).uniq!
37
+ end
38
+
39
+ double_check_for_index(idx, dependency_names)
40
+ end
41
+ end
42
+
43
+ # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both
44
+ # sources A and B. At this point, the API request will have found all the versions of Bar in source A,
45
+ # but will not have found any versions of Bar from source B, which is a problem if the requested version
46
+ # of Foo specifically depends on a version of Bar that is only found in source B. This ensures that for
47
+ # each spec we found, we add all possible versions from all sources to the index.
48
+ def double_check_for_index(idx, dependency_names)
49
+ pinned_names = source_map.pinned_spec_names
50
+
51
+ names = :names # do this so we only have to traverse to get dependency_names from the index once
52
+ unmet_dependency_names = lambda do
53
+ return names unless names == :names
54
+ new_names = sources.all_sources.map(&:dependency_names_to_double_check)
55
+ return names = nil if new_names.compact!
56
+ names = new_names.flatten(1).concat(dependency_names)
57
+ names.uniq!
58
+ names -= pinned_names
59
+ names
60
+ end
61
+
62
+ sources.all_sources.each do |source|
63
+ source.double_check_for(unmet_dependency_names)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -7,6 +7,7 @@ module Bundler
7
7
  autoload :Metadata, File.expand_path("source/metadata", __dir__)
8
8
  autoload :Path, File.expand_path("source/path", __dir__)
9
9
  autoload :Rubygems, File.expand_path("source/rubygems", __dir__)
10
+ autoload :RubygemsAggregate, File.expand_path("source/rubygems_aggregate", __dir__)
10
11
 
11
12
  attr_accessor :dependency_names
12
13
 
@@ -33,6 +34,18 @@ module Bundler
33
34
  spec.source == self
34
35
  end
35
36
 
37
+ def local!; end
38
+
39
+ def local_only!; end
40
+
41
+ def cached!; end
42
+
43
+ def remote!; end
44
+
45
+ def add_dependency_names(names)
46
+ @dependency_names = Array(dependency_names) | Array(names)
47
+ end
48
+
36
49
  # it's possible that gems from one source depend on gems from some
37
50
  # other source, so now we download gemspecs and iterate over those
38
51
  # dependencies, looking for gems we don't have info on yet.
@@ -42,6 +55,10 @@ module Bundler
42
55
  specs.dependency_names
43
56
  end
44
57
 
58
+ def spec_names
59
+ specs.spec_names
60
+ end
61
+
45
62
  def include?(other)
46
63
  other == self
47
64
  end
@@ -50,6 +67,10 @@ module Bundler
50
67
  "#<#{self.class}:0x#{object_id} #{self}>"
51
68
  end
52
69
 
70
+ def identifier
71
+ to_s
72
+ end
73
+
53
74
  def path?
54
75
  instance_of?(Bundler::Source::Path)
55
76
  end
@@ -63,7 +84,7 @@ module Bundler
63
84
  )
64
85
  end
65
86
 
66
- private
87
+ private
67
88
 
68
89
  def version_color(spec_version, locked_spec_version)
69
90
  if Gem::Version.correct?(spec_version) && Gem::Version.correct?(locked_spec_version)