bundler 2.1.4 → 2.2.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2017 -1430
  3. data/README.md +7 -9
  4. data/bundler.gemspec +5 -6
  5. data/exe/bundle +3 -0
  6. data/lib/bundler/build_metadata.rb +3 -11
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +6 -2
  9. data/lib/bundler/cli/cache.rb +3 -8
  10. data/lib/bundler/cli/check.rb +4 -2
  11. data/lib/bundler/cli/clean.rb +1 -1
  12. data/lib/bundler/cli/common.rb +29 -2
  13. data/lib/bundler/cli/console.rb +1 -1
  14. data/lib/bundler/cli/doctor.rb +16 -5
  15. data/lib/bundler/cli/exec.rb +5 -10
  16. data/lib/bundler/cli/fund.rb +36 -0
  17. data/lib/bundler/cli/gem.rb +209 -28
  18. data/lib/bundler/cli/info.rb +28 -5
  19. data/lib/bundler/cli/init.rb +2 -2
  20. data/lib/bundler/cli/inject.rb +1 -1
  21. data/lib/bundler/cli/install.rb +22 -34
  22. data/lib/bundler/cli/issue.rb +5 -4
  23. data/lib/bundler/cli/list.rb +19 -11
  24. data/lib/bundler/cli/lock.rb +5 -1
  25. data/lib/bundler/cli/open.rb +1 -2
  26. data/lib/bundler/cli/outdated.rb +95 -75
  27. data/lib/bundler/cli/plugin.rb +10 -0
  28. data/lib/bundler/cli/pristine.rb +5 -0
  29. data/lib/bundler/cli/remove.rb +1 -2
  30. data/lib/bundler/cli/show.rb +1 -1
  31. data/lib/bundler/cli/update.rb +14 -7
  32. data/lib/bundler/cli.rb +89 -66
  33. data/lib/bundler/compact_index_client/cache.rb +6 -14
  34. data/lib/bundler/compact_index_client/gem_parser.rb +28 -0
  35. data/lib/bundler/compact_index_client/updater.rb +13 -22
  36. data/lib/bundler/compact_index_client.rb +3 -3
  37. data/lib/bundler/current_ruby.rb +5 -4
  38. data/lib/bundler/definition.rb +193 -363
  39. data/lib/bundler/dep_proxy.rb +16 -9
  40. data/lib/bundler/dependency.rb +3 -10
  41. data/lib/bundler/digest.rb +71 -0
  42. data/lib/bundler/dsl.rb +71 -47
  43. data/lib/bundler/endpoint_specification.rb +1 -1
  44. data/lib/bundler/env.rb +1 -1
  45. data/lib/bundler/environment_preserver.rb +29 -2
  46. data/lib/bundler/errors.rb +20 -3
  47. data/lib/bundler/feature_flag.rb +0 -8
  48. data/lib/bundler/fetcher/base.rb +1 -1
  49. data/lib/bundler/fetcher/compact_index.rb +2 -2
  50. data/lib/bundler/fetcher/downloader.rb +10 -7
  51. data/lib/bundler/fetcher/index.rb +3 -5
  52. data/lib/bundler/fetcher.rb +7 -5
  53. data/lib/bundler/friendly_errors.rb +25 -43
  54. data/lib/bundler/gem_helper.rb +53 -31
  55. data/lib/bundler/gem_helpers.rb +36 -25
  56. data/lib/bundler/gem_version_promoter.rb +4 -4
  57. data/lib/bundler/graph.rb +1 -1
  58. data/lib/bundler/index.rb +9 -9
  59. data/lib/bundler/injector.rb +23 -5
  60. data/lib/bundler/inline.rb +3 -2
  61. data/lib/bundler/installer/gem_installer.rb +6 -19
  62. data/lib/bundler/installer/parallel_installer.rb +46 -25
  63. data/lib/bundler/installer/standalone.rb +30 -10
  64. data/lib/bundler/installer.rb +36 -56
  65. data/lib/bundler/lazy_specification.rb +62 -26
  66. data/lib/bundler/lockfile_generator.rb +1 -1
  67. data/lib/bundler/lockfile_parser.rb +8 -34
  68. data/lib/bundler/man/.document +1 -0
  69. data/{man → lib/bundler/man}/bundle-add.1 +1 -1
  70. data/{man/bundle-add.ronn → lib/bundler/man/bundle-add.1.ronn} +0 -0
  71. data/{man → lib/bundler/man}/bundle-binstubs.1 +5 -3
  72. data/{man/bundle-binstubs.ronn → lib/bundler/man/bundle-binstubs.1.ronn} +2 -4
  73. data/{man → lib/bundler/man}/bundle-cache.1 +1 -1
  74. data/{man/bundle-cache.ronn → lib/bundler/man/bundle-cache.1.ronn} +0 -0
  75. data/{man → lib/bundler/man}/bundle-check.1 +1 -1
  76. data/{man/bundle-check.ronn → lib/bundler/man/bundle-check.1.ronn} +0 -0
  77. data/{man → lib/bundler/man}/bundle-clean.1 +1 -1
  78. data/{man/bundle-clean.ronn → lib/bundler/man/bundle-clean.1.ronn} +0 -0
  79. data/{man → lib/bundler/man}/bundle-config.1 +40 -41
  80. data/{man/bundle-config.ronn → lib/bundler/man/bundle-config.1.ronn} +50 -53
  81. data/{man → lib/bundler/man}/bundle-doctor.1 +1 -1
  82. data/{man/bundle-doctor.ronn → lib/bundler/man/bundle-doctor.1.ronn} +0 -0
  83. data/{man → lib/bundler/man}/bundle-exec.1 +1 -1
  84. data/{man/bundle-exec.ronn → lib/bundler/man/bundle-exec.1.ronn} +0 -0
  85. data/{man → lib/bundler/man}/bundle-gem.1 +38 -3
  86. data/{man/bundle-gem.ronn → lib/bundler/man/bundle-gem.1.ronn} +46 -7
  87. data/{man → lib/bundler/man}/bundle-info.1 +1 -1
  88. data/{man/bundle-info.ronn → lib/bundler/man/bundle-info.1.ronn} +0 -0
  89. data/{man → lib/bundler/man}/bundle-init.1 +1 -1
  90. data/{man/bundle-init.ronn → lib/bundler/man/bundle-init.1.ronn} +0 -0
  91. data/{man → lib/bundler/man}/bundle-inject.1 +1 -1
  92. data/{man/bundle-inject.ronn → lib/bundler/man/bundle-inject.1.ronn} +0 -0
  93. data/{man → lib/bundler/man}/bundle-install.1 +30 -3
  94. data/{man/bundle-install.ronn → lib/bundler/man/bundle-install.1.ronn} +25 -3
  95. data/{man → lib/bundler/man}/bundle-list.1 +7 -7
  96. data/{man/bundle-list.ronn → lib/bundler/man/bundle-list.1.ronn} +6 -6
  97. data/{man → lib/bundler/man}/bundle-lock.1 +1 -1
  98. data/{man/bundle-lock.ronn → lib/bundler/man/bundle-lock.1.ronn} +0 -0
  99. data/{man → lib/bundler/man}/bundle-open.1 +1 -1
  100. data/{man/bundle-open.ronn → lib/bundler/man/bundle-open.1.ronn} +0 -0
  101. data/{man → lib/bundler/man}/bundle-outdated.1 +1 -1
  102. data/{man/bundle-outdated.ronn → lib/bundler/man/bundle-outdated.1.ronn} +0 -0
  103. data/{man → lib/bundler/man}/bundle-platform.1 +1 -1
  104. data/{man/bundle-platform.ronn → lib/bundler/man/bundle-platform.1.ronn} +0 -0
  105. data/{man → lib/bundler/man}/bundle-pristine.1 +1 -1
  106. data/{man/bundle-pristine.ronn → lib/bundler/man/bundle-pristine.1.ronn} +0 -0
  107. data/{man → lib/bundler/man}/bundle-remove.1 +1 -1
  108. data/{man/bundle-remove.ronn → lib/bundler/man/bundle-remove.1.ronn} +0 -0
  109. data/{man → lib/bundler/man}/bundle-show.1 +1 -1
  110. data/{man/bundle-show.ronn → lib/bundler/man/bundle-show.1.ronn} +0 -0
  111. data/{man → lib/bundler/man}/bundle-update.1 +4 -4
  112. data/{man/bundle-update.ronn → lib/bundler/man/bundle-update.1.ronn} +3 -3
  113. data/{man → lib/bundler/man}/bundle-viz.1 +1 -1
  114. data/{man/bundle-viz.ronn → lib/bundler/man/bundle-viz.1.ronn} +0 -0
  115. data/{man → lib/bundler/man}/bundle.1 +1 -1
  116. data/{man/bundle.ronn → lib/bundler/man/bundle.1.ronn} +0 -0
  117. data/{man → lib/bundler/man}/gemfile.5 +30 -4
  118. data/{man → lib/bundler/man}/gemfile.5.ronn +12 -4
  119. data/{man → lib/bundler/man}/index.txt +0 -0
  120. data/lib/bundler/mirror.rb +2 -2
  121. data/lib/bundler/plugin/api/source.rb +23 -1
  122. data/lib/bundler/plugin/dsl.rb +1 -1
  123. data/lib/bundler/plugin/index.rb +13 -1
  124. data/lib/bundler/plugin/installer/rubygems.rb +1 -1
  125. data/lib/bundler/plugin/installer.rb +11 -11
  126. data/lib/bundler/plugin/source_list.rb +5 -1
  127. data/lib/bundler/plugin.rb +56 -11
  128. data/lib/bundler/psyched_yaml.rb +0 -15
  129. data/lib/bundler/remote_specification.rb +5 -2
  130. data/lib/bundler/resolver/spec_group.rb +56 -53
  131. data/lib/bundler/resolver.rb +94 -128
  132. data/lib/bundler/retry.rb +2 -2
  133. data/lib/bundler/ruby_version.rb +1 -1
  134. data/lib/bundler/rubygems_ext.rb +96 -16
  135. data/lib/bundler/rubygems_gem_installer.rb +69 -8
  136. data/lib/bundler/rubygems_integration.rb +57 -72
  137. data/lib/bundler/runtime.rb +22 -25
  138. data/lib/bundler/settings.rb +142 -64
  139. data/lib/bundler/setup.rb +2 -2
  140. data/lib/bundler/shared_helpers.rb +5 -13
  141. data/lib/bundler/similarity_detector.rb +1 -1
  142. data/lib/bundler/source/git/git_proxy.rb +88 -84
  143. data/lib/bundler/source/git.rb +43 -23
  144. data/lib/bundler/source/metadata.rb +0 -4
  145. data/lib/bundler/source/path/installer.rb +10 -10
  146. data/lib/bundler/source/path.rb +10 -4
  147. data/lib/bundler/source/rubygems/remote.rb +1 -1
  148. data/lib/bundler/source/rubygems.rb +126 -116
  149. data/lib/bundler/source/rubygems_aggregate.rb +68 -0
  150. data/lib/bundler/source.rb +22 -1
  151. data/lib/bundler/source_list.rb +101 -63
  152. data/lib/bundler/source_map.rb +58 -0
  153. data/lib/bundler/spec_set.rb +26 -41
  154. data/lib/bundler/stub_specification.rb +25 -7
  155. data/lib/bundler/templates/Executable.bundler +6 -6
  156. data/lib/bundler/templates/Gemfile +1 -1
  157. data/lib/bundler/templates/gems.rb +1 -1
  158. data/lib/bundler/templates/newgem/CHANGELOG.md.tt +5 -0
  159. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +57 -47
  160. data/lib/bundler/templates/newgem/Gemfile.tt +12 -1
  161. data/lib/bundler/templates/newgem/README.md.tt +6 -5
  162. data/lib/bundler/templates/newgem/Rakefile.tt +23 -5
  163. data/lib/bundler/templates/newgem/bin/console.tt +1 -0
  164. data/lib/bundler/templates/newgem/circleci/config.yml.tt +13 -0
  165. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +2 -0
  166. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +27 -0
  167. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  168. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +2 -0
  169. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +4 -2
  170. data/lib/bundler/templates/newgem/newgem.gemspec.tt +27 -17
  171. data/lib/bundler/templates/newgem/rubocop.yml.tt +13 -0
  172. data/lib/bundler/templates/newgem/sig/newgem.rbs.tt +8 -0
  173. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +2 -0
  174. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -1
  175. data/lib/bundler/templates/newgem/standard.yml.tt +2 -0
  176. data/lib/bundler/templates/newgem/test/{newgem_test.rb.tt → minitest/newgem_test.rb.tt} +2 -0
  177. data/lib/bundler/templates/newgem/test/{test_helper.rb.tt → minitest/test_helper.rb.tt} +2 -0
  178. data/lib/bundler/templates/newgem/test/test-unit/newgem_test.rb.tt +15 -0
  179. data/lib/bundler/templates/newgem/test/test-unit/test_helper.rb.tt +6 -0
  180. data/lib/bundler/ui/shell.rb +5 -5
  181. data/lib/bundler/uri_credentials_filter.rb +3 -1
  182. data/lib/bundler/vendor/.document +1 -0
  183. data/lib/bundler/vendor/connection_pool/LICENSE +20 -0
  184. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +19 -21
  185. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  186. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +57 -0
  187. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +39 -74
  188. data/lib/bundler/vendor/fileutils/LICENSE.txt +22 -0
  189. data/lib/bundler/vendor/molinillo/LICENSE +9 -0
  190. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +7 -0
  191. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +2 -2
  192. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +11 -5
  193. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +36 -4
  194. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +3 -3
  195. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  196. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +12 -1
  197. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +49 -47
  198. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -1
  199. data/lib/bundler/vendor/net-http-persistent/README.rdoc +82 -0
  200. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +82 -189
  201. data/lib/bundler/vendor/thor/LICENSE.md +20 -0
  202. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
  203. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +4 -2
  204. data/lib/bundler/vendor/thor/lib/thor/actions.rb +1 -1
  205. data/lib/bundler/vendor/thor/lib/thor/base.rb +9 -0
  206. data/lib/bundler/vendor/thor/lib/thor/error.rb +1 -1
  207. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +5 -1
  208. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +9 -8
  209. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +5 -2
  210. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +5 -1
  211. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  212. data/lib/bundler/vendor/thor/lib/thor.rb +5 -13
  213. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +154 -0
  214. data/lib/bundler/vendor/tsort/LICENSE.txt +22 -0
  215. data/lib/bundler/vendor/tsort/lib/tsort.rb +453 -0
  216. data/lib/bundler/vendor/uri/LICENSE.txt +22 -0
  217. data/lib/bundler/vendored_persistent.rb +0 -7
  218. data/lib/bundler/vendored_tmpdir.rb +4 -0
  219. data/lib/bundler/vendored_tsort.rb +4 -0
  220. data/lib/bundler/version.rb +1 -1
  221. data/lib/bundler/worker.rb +20 -5
  222. data/lib/bundler/yaml_serializer.rb +1 -1
  223. data/lib/bundler.rb +52 -37
  224. metadata +90 -89
  225. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +0 -66
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +0 -26
  227. data/man/bundle-add.1.txt +0 -58
  228. data/man/bundle-binstubs.1.txt +0 -48
  229. data/man/bundle-cache.1.txt +0 -78
  230. data/man/bundle-check.1.txt +0 -33
  231. data/man/bundle-clean.1.txt +0 -26
  232. data/man/bundle-config.1.txt +0 -528
  233. data/man/bundle-doctor.1.txt +0 -44
  234. data/man/bundle-exec.1.txt +0 -178
  235. data/man/bundle-gem.1.txt +0 -91
  236. data/man/bundle-info.1.txt +0 -21
  237. data/man/bundle-init.1.txt +0 -34
  238. data/man/bundle-inject.1.txt +0 -32
  239. data/man/bundle-install.1.txt +0 -401
  240. data/man/bundle-list.1.txt +0 -43
  241. data/man/bundle-lock.1.txt +0 -93
  242. data/man/bundle-open.1.txt +0 -29
  243. data/man/bundle-outdated.1.txt +0 -131
  244. data/man/bundle-platform.1.txt +0 -57
  245. data/man/bundle-pristine.1.txt +0 -44
  246. data/man/bundle-remove.1.txt +0 -34
  247. data/man/bundle-show.1.txt +0 -27
  248. data/man/bundle-update.1.txt +0 -390
  249. data/man/bundle-viz.1.txt +0 -39
  250. data/man/bundle.1.txt +0 -116
  251. data/man/gemfile.5.txt +0 -649
@@ -6,10 +6,11 @@ require_relative "gem_installer"
6
6
  module Bundler
7
7
  class ParallelInstaller
8
8
  class SpecInstallation
9
- attr_accessor :spec, :name, :post_install_message, :state, :error
9
+ attr_accessor :spec, :name, :full_name, :post_install_message, :state, :error
10
10
  def initialize(spec)
11
11
  @spec = spec
12
12
  @name = spec.name
13
+ @full_name = spec.full_name
13
14
  @state = :none
14
15
  @post_install_message = ""
15
16
  @error = nil
@@ -27,13 +28,8 @@ module Bundler
27
28
  state == :failed
28
29
  end
29
30
 
30
- def installation_attempted?
31
- installed? || failed?
32
- end
33
-
34
- # Only true when spec in neither installed nor already enqueued
35
31
  def ready_to_enqueue?
36
- !enqueued? && !installation_attempted?
32
+ state == :none
37
33
  end
38
34
 
39
35
  def has_post_install_message?
@@ -54,14 +50,11 @@ module Bundler
54
50
  # Represents only the non-development dependencies, the ones that are
55
51
  # itself and are in the total list.
56
52
  def dependencies
57
- @dependencies ||= begin
58
- all_dependencies.reject {|dep| ignorable_dependency? dep }
59
- end
53
+ @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }
60
54
  end
61
55
 
62
56
  def missing_lockfile_dependencies(all_spec_names)
63
- deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
64
- deps.reject {|dep| all_spec_names.include? dep.name }
57
+ dependencies.reject {|dep| all_spec_names.include? dep.name }
65
58
  end
66
59
 
67
60
  # Represents all dependencies
@@ -70,7 +63,7 @@ module Bundler
70
63
  end
71
64
 
72
65
  def to_s
73
- "#<#{self.class} #{@spec.full_name} (#{state})>"
66
+ "#<#{self.class} #{full_name} (#{state})>"
74
67
  end
75
68
  end
76
69
 
@@ -93,18 +86,48 @@ module Bundler
93
86
  def call
94
87
  check_for_corrupt_lockfile
95
88
 
89
+ if @rake
90
+ do_install(@rake, 0)
91
+ Gem::Specification.reset
92
+ end
93
+
96
94
  if @size > 1
97
95
  install_with_worker
98
96
  else
99
97
  install_serially
100
98
  end
101
99
 
102
- handle_error if @specs.any?(&:failed?)
100
+ check_for_unmet_dependencies
101
+
102
+ handle_error if failed_specs.any?
103
103
  @specs
104
104
  ensure
105
105
  worker_pool && worker_pool.stop
106
106
  end
107
107
 
108
+ def check_for_unmet_dependencies
109
+ unmet_dependencies = @specs.map do |s|
110
+ [
111
+ s,
112
+ s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
113
+ ]
114
+ end.reject {|a| a.last.empty? }
115
+ return if unmet_dependencies.empty?
116
+
117
+ warning = []
118
+ warning << "Your lockfile doesn't include a valid resolution."
119
+ warning << "You can fix this by regenerating your lockfile or trying to manually editing the bad locked gems to a version that satisfies all dependencies."
120
+ warning << "The unmet dependencies are:"
121
+
122
+ unmet_dependencies.each do |spec, unmet_spec_dependencies|
123
+ unmet_spec_dependencies.each do |unmet_spec_dependency|
124
+ warning << "* #{unmet_spec_dependency}, depended upon #{spec.full_name}, unsatisfied by #{@specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }.full_name}"
125
+ end
126
+ end
127
+
128
+ Bundler.ui.warn(warning.join("\n"))
129
+ end
130
+
108
131
  def check_for_corrupt_lockfile
109
132
  missing_dependencies = @specs.map do |s|
110
133
  [
@@ -130,7 +153,11 @@ module Bundler
130
153
  Bundler.ui.warn(warning.join("\n"))
131
154
  end
132
155
 
133
- private
156
+ private
157
+
158
+ def failed_specs
159
+ @specs.select(&:failed?)
160
+ end
134
161
 
135
162
  def install_with_worker
136
163
  enqueue_specs
@@ -156,17 +183,13 @@ module Bundler
156
183
  gem_installer = Bundler::GemInstaller.new(
157
184
  spec_install.spec, @installer, @standalone, worker_num, @force
158
185
  )
159
- success, message = begin
160
- gem_installer.install_from_spec
161
- rescue RuntimeError => e
162
- raise e, "#{e}\n\n#{require_tree_for_spec(spec_install.spec)}"
163
- end
186
+ success, message = gem_installer.install_from_spec
164
187
  if success
165
188
  spec_install.state = :installed
166
189
  spec_install.post_install_message = message unless message.nil?
167
190
  else
168
- spec_install.state = :failed
169
191
  spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
192
+ spec_install.state = :failed
170
193
  end
171
194
  Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
172
195
  spec_install
@@ -190,11 +213,11 @@ module Bundler
190
213
  end
191
214
 
192
215
  def handle_error
193
- errors = @specs.select(&:failed?).map(&:error)
216
+ errors = failed_specs.map(&:error)
194
217
  if exception = errors.find {|e| e.is_a?(Bundler::BundlerError) }
195
218
  raise exception
196
219
  end
197
- raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
220
+ raise Bundler::InstallError, errors.join("\n\n")
198
221
  end
199
222
 
200
223
  def require_tree_for_spec(spec)
@@ -217,8 +240,6 @@ module Bundler
217
240
  # are installed.
218
241
  def enqueue_specs
219
242
  @specs.select(&:ready_to_enqueue?).each do |spec|
220
- next if @rake && !@rake.installed? && spec.name != @rake.name
221
-
222
243
  if spec.dependencies_installed? @specs
223
244
  spec.state = :enqueued
224
245
  worker_pool.enq spec
@@ -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,29 +12,31 @@ 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 reverse_rubygems_kernel_mixin
18
16
  paths.each do |path|
19
- file.puts %($:.unshift "\#{path}/#{path}")
17
+ if Pathname.new(path).absolute?
18
+ file.puts %($:.unshift "#{path}")
19
+ else
20
+ file.puts %($:.unshift File.expand_path("\#{__dir__}/#{path}"))
21
+ end
20
22
  end
21
23
  end
22
24
  end
23
25
 
24
- private
26
+ private
25
27
 
26
28
  def paths
27
29
  @specs.map do |spec|
28
30
  next if spec.name == "bundler"
29
31
  Array(spec.require_paths).map do |path|
30
- gem_path(path, spec).sub(version_dir, '#{ruby_engine}/#{ruby_version}')
32
+ gem_path(path, spec).sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}')
31
33
  # This is a static string intentionally. It's interpolated at a later time.
32
34
  end
33
- end.flatten
35
+ end.flatten.compact
34
36
  end
35
37
 
36
38
  def version_dir
37
- "#{Bundler::RubyVersion.system.engine}/#{RbConfig::CONFIG["ruby_version"]}"
39
+ "#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}"
38
40
  end
39
41
 
40
42
  def bundler_path
@@ -43,10 +45,28 @@ module Bundler
43
45
 
44
46
  def gem_path(path, spec)
45
47
  full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
46
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
48
+ if spec.source.instance_of?(Source::Path)
49
+ full_path
50
+ else
51
+ Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
52
+ end
47
53
  rescue TypeError
48
54
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
49
55
  raise Gem::InvalidSpecificationException.new(error_message)
50
56
  end
57
+
58
+ def reverse_rubygems_kernel_mixin
59
+ <<~END
60
+ kernel = (class << ::Kernel; self; end)
61
+ [kernel, ::Kernel].each do |k|
62
+ if k.private_method_defined?(:gem_original_require)
63
+ private_require = k.private_method_defined?(:require)
64
+ k.send(:remove_method, :require)
65
+ k.send(:define_method, :require, k.instance_method(:gem_original_require))
66
+ k.send(:private, :require) if private_require
67
+ end
68
+ end
69
+ END
70
+ end
51
71
  end
52
72
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "erb"
4
- require "rubygems/dependency_installer"
5
3
  require_relative "worker"
6
4
  require_relative "installer/parallel_installer"
7
5
  require_relative "installer/standalone"
@@ -83,7 +81,6 @@ module Bundler
83
81
 
84
82
  if resolve_if_needed(options)
85
83
  ensure_specs_are_compatible!
86
- warn_on_incompatible_bundler_deps
87
84
  load_plugins
88
85
  options.delete(:jobs)
89
86
  else
@@ -91,6 +88,8 @@ module Bundler
91
88
  end
92
89
  install(options)
93
90
 
91
+ Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
92
+
94
93
  lock unless Bundler.frozen_bundle?
95
94
  Standalone.new(options[:standalone], @definition).generate if options[:standalone]
96
95
  end
@@ -135,12 +134,18 @@ module Bundler
135
134
  next
136
135
  end
137
136
 
138
- File.open(binstub_path, "w", 0o777 & ~File.umask) do |f|
139
- if RUBY_VERSION >= "2.6"
140
- f.puts ERB.new(template, :trim_mode => "-").result(binding)
141
- else
142
- f.puts ERB.new(template, nil, "-").result(binding)
143
- end
137
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
138
+ require "erb"
139
+ content = if RUBY_VERSION >= "2.6"
140
+ ERB.new(template, :trim_mode => "-").result(binding)
141
+ else
142
+ ERB.new(template, nil, "-").result(binding)
143
+ end
144
+
145
+ File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
146
+ if Gem.win_platform? || options[:all_platforms]
147
+ prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
148
+ File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
144
149
  end
145
150
  end
146
151
 
@@ -159,7 +164,7 @@ module Bundler
159
164
  end
160
165
  end
161
166
 
162
- def generate_standalone_bundler_executable_stubs(spec)
167
+ def generate_standalone_bundler_executable_stubs(spec, options = {})
163
168
  # double-assignment to avoid warnings about variables that will be used by ERB
164
169
  bin_path = Bundler.bin_path
165
170
  unless path = Bundler.settings[:path]
@@ -175,17 +180,24 @@ module Bundler
175
180
  next if executable == "bundle"
176
181
  executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
177
182
  executable_path = executable_path
178
- File.open "#{bin_path}/#{executable}", "w", 0o755 do |f|
179
- if RUBY_VERSION >= "2.6"
180
- f.puts ERB.new(template, :trim_mode => "-").result(binding)
181
- else
182
- f.puts ERB.new(template, nil, "-").result(binding)
183
- end
183
+
184
+ mode = Gem.win_platform? ? "wb:UTF-8" : "w"
185
+ require "erb"
186
+ content = if RUBY_VERSION >= "2.6"
187
+ ERB.new(template, :trim_mode => "-").result(binding)
188
+ else
189
+ ERB.new(template, nil, "-").result(binding)
190
+ end
191
+
192
+ File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
193
+ if Gem.win_platform? || options[:all_platforms]
194
+ prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
195
+ File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
184
196
  end
185
197
  end
186
198
  end
187
199
 
188
- private
200
+ private
189
201
 
190
202
  # the order that the resolver provides is significant, since
191
203
  # dependencies might affect the installation of a gem.
@@ -202,27 +214,14 @@ module Bundler
202
214
  return jobs
203
215
  end
204
216
 
205
- return 1 unless can_install_in_parallel?
206
-
207
- auto_config_jobs = Bundler.feature_flag.auto_config_jobs?
208
217
  if jobs = Bundler.settings[:jobs]
209
- if auto_config_jobs
210
- jobs
211
- else
212
- [jobs.pred, 1].max
213
- end
214
- elsif auto_config_jobs
215
- processor_count
216
- else
217
- 1
218
+ return jobs
218
219
  end
219
- end
220
220
 
221
- def processor_count
222
- require "etc"
223
- Etc.nprocessors
224
- rescue StandardError
225
- 1
221
+ # Parallelization has some issues on Windows, so it's not yet the default
222
+ return 1 if Gem.win_platform?
223
+
224
+ Bundler.settings.processor_count
226
225
  end
227
226
 
228
227
  def load_plugins
@@ -238,6 +237,7 @@ module Bundler
238
237
  end
239
238
  end.flatten
240
239
  Bundler.rubygems.load_plugin_files(path_plugin_files)
240
+ Bundler.rubygems.load_env_plugins
241
241
  end
242
242
 
243
243
  def ensure_specs_are_compatible!
@@ -258,26 +258,6 @@ module Bundler
258
258
  end
259
259
  end
260
260
 
261
- def warn_on_incompatible_bundler_deps
262
- bundler_version = Gem::Version.create(Bundler::VERSION)
263
- @definition.specs.each do |spec|
264
- spec.dependencies.each do |dep|
265
- next if dep.type == :development
266
- next unless dep.name == "bundler".freeze
267
- next if dep.requirement.satisfied_by?(bundler_version)
268
-
269
- Bundler.ui.warn "#{spec.name} (#{spec.version}) has dependency" \
270
- " #{SharedHelpers.pretty_dependency(dep)}" \
271
- ", which is unsatisfied by the current bundler version #{VERSION}" \
272
- ", so the dependency is being ignored"
273
- end
274
- end
275
- end
276
-
277
- def can_install_in_parallel?
278
- true
279
- end
280
-
281
261
  def install_in_parallel(size, standalone, force = false)
282
262
  spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
283
263
  spec_installations.each do |installation|
@@ -296,7 +276,7 @@ module Bundler
296
276
 
297
277
  # returns whether or not a re-resolve was needed
298
278
  def resolve_if_needed(options)
299
- if !@definition.unlocking? && !options["force"] && !options["all-platforms"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
279
+ if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
300
280
  return false if @definition.nothing_changed? && !@definition.missing_specs?
301
281
  end
302
282
 
@@ -4,22 +4,6 @@ require_relative "match_platform"
4
4
 
5
5
  module Bundler
6
6
  class LazySpecification
7
- Identifier = Struct.new(:name, :version, :source, :platform, :dependencies)
8
- class Identifier
9
- include Comparable
10
- def <=>(other)
11
- return unless other.is_a?(Identifier)
12
- [name, version, platform_string] <=> [other.name, other.version, other.platform_string]
13
- end
14
-
15
- protected
16
-
17
- def platform_string
18
- platform_string = platform.to_s
19
- platform_string == Index::RUBY ? Index::NULL : platform_string
20
- end
21
- end
22
-
23
7
  include MatchPlatform
24
8
 
25
9
  attr_reader :name, :version, :dependencies, :platform
@@ -46,8 +30,32 @@ module Bundler
46
30
  identifier == other.identifier
47
31
  end
48
32
 
33
+ def eql?(other)
34
+ identifier.eql?(other.identifier)
35
+ end
36
+
37
+ def hash
38
+ identifier.hash
39
+ end
40
+
41
+ ##
42
+ # Does this locked specification satisfy +dependency+?
43
+ #
44
+ # NOTE: Rubygems default requirement is ">= 0", which doesn't match
45
+ # prereleases of 0 versions, like "0.0.0.dev" or "0.0.0.SNAPSHOT". However,
46
+ # bundler users expect those to work. We need to make sure that Gemfile
47
+ # dependencies without explicit requirements (which use ">= 0" under the
48
+ # hood by default) are still valid for locked specs using this kind of
49
+ # versions. The method implements an ad-hoc fix for that. A better solution
50
+ # might be to change default rubygems requirement of dependencies to be ">=
51
+ # 0.A" but that's a major refactoring likely to break things. Hopefully we
52
+ # can attempt it in the future.
53
+ #
54
+
49
55
  def satisfies?(dependency)
50
- @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
56
+ effective_requirement = dependency.requirement == Gem::Requirement.default ? Gem::Requirement.new(">= 0.A") : dependency.requirement
57
+
58
+ @name == dependency.name && effective_requirement.satisfied_by?(Gem::Version.new(@version))
51
59
  end
52
60
 
53
61
  def to_lock
@@ -68,17 +76,25 @@ module Bundler
68
76
  end
69
77
 
70
78
  def __materialize__
71
- search_object = Bundler.feature_flag.specific_platform? || Bundler.settings[:force_ruby_platform] ? self : Dependency.new(name, version)
72
79
  @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
73
80
  source.gemspec.tap {|s| s.source = source }
74
81
  else
75
- search = source.specs.search(search_object).last
76
- if search && Gem::Platform.new(search.platform) != Gem::Platform.new(platform) && !search.runtime_dependencies.-(dependencies.reject {|d| d.type == :development }).empty?
77
- Bundler.ui.warn "Unable to use the platform-specific (#{search.platform}) version of #{name} (#{version}) " \
78
- "because it has different dependencies from the #{platform} version. " \
79
- "To use the platform-specific version of the gem, run `bundle config set specific_platform true` and install again."
80
- search = source.specs.search(self).last
82
+ search_object = if source.is_a?(Source::Path)
83
+ Dependency.new(name, version)
84
+ else
85
+ ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
86
+ end
87
+ platform_object = Gem::Platform.new(platform)
88
+ candidates = source.specs.search(search_object)
89
+ same_platform_candidates = candidates.select do |spec|
90
+ MatchPlatform.platforms_match?(spec.platform, platform_object)
81
91
  end
92
+ installable_candidates = same_platform_candidates.select do |spec|
93
+ !spec.is_a?(EndpointSpecification) ||
94
+ (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
95
+ spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
96
+ end
97
+ search = installable_candidates.last || same_platform_candidates.last
82
98
  search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
83
99
  search
84
100
  end
@@ -97,7 +113,7 @@ module Bundler
97
113
  end
98
114
 
99
115
  def identifier
100
- @__identifier ||= Identifier.new(name, version, source, platform, dependencies)
116
+ @__identifier ||= [name, version, platform_string]
101
117
  end
102
118
 
103
119
  def git_version
@@ -105,7 +121,14 @@ module Bundler
105
121
  " #{source.revision[0..6]}"
106
122
  end
107
123
 
108
- private
124
+ protected
125
+
126
+ def platform_string
127
+ platform_string = platform.to_s
128
+ platform_string == Index::RUBY ? Index::NULL : platform_string
129
+ end
130
+
131
+ private
109
132
 
110
133
  def to_ary
111
134
  nil
@@ -118,5 +141,18 @@ module Bundler
118
141
 
119
142
  @specification.send(method, *args, &blk)
120
143
  end
144
+
145
+ #
146
+ # For backwards compatibility with existing lockfiles, if the most specific
147
+ # locked platform is RUBY, we keep the previous behaviour of resolving the
148
+ # best platform variant at materiliazation time. For previous bundler
149
+ # versions (before 2.2.0) this was always the case (except when the lockfile
150
+ # only included non-ruby platforms), but we're also keeping this behaviour
151
+ # on newer bundlers unless users generate the lockfile from scratch or
152
+ # explicitly add a more specific platform.
153
+ #
154
+ def ruby_platform_materializes_to_ruby_platform?
155
+ !Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform]
156
+ end
121
157
  end
122
158
  end
@@ -25,7 +25,7 @@ module Bundler
25
25
  out
26
26
  end
27
27
 
28
- private
28
+ private
29
29
 
30
30
  def add_sources
31
31
  definition.send(:sources).lock_sources.each_with_index do |source, idx|
@@ -1,16 +1,5 @@
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
@@ -64,8 +53,6 @@ module Bundler
64
53
  @state = nil
65
54
  @specs = {}
66
55
 
67
- @rubygems_aggregate = Source::Rubygems.new
68
-
69
56
  if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
70
57
  raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
71
58
  "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
@@ -89,7 +76,6 @@ module Bundler
89
76
  send("parse_#{@state}", line)
90
77
  end
91
78
  end
92
- @sources << @rubygems_aggregate unless Bundler.feature_flag.disable_multisource?
93
79
  @specs = @specs.values.sort_by(&:identifier)
94
80
  warn_for_outdated_bundler_version
95
81
  rescue ArgumentError => e
@@ -100,6 +86,7 @@ module Bundler
100
86
 
101
87
  def warn_for_outdated_bundler_version
102
88
  return unless bundler_version
89
+ return if bundler_version.segments.last == "dev"
103
90
  prerelease_text = bundler_version.prerelease? ? " --pre" : ""
104
91
  current_version = Gem::Version.create(Bundler::VERSION)
105
92
  return unless current_version < bundler_version
@@ -109,7 +96,7 @@ module Bundler
109
96
  "bundler:#{bundler_version}#{prerelease_text}`.\n"
110
97
  end
111
98
 
112
- private
99
+ private
113
100
 
114
101
  TYPES = {
115
102
  GIT => Bundler::Source::Git,
@@ -127,23 +114,11 @@ module Bundler
127
114
  @sources << @current_source
128
115
  when GIT
129
116
  @current_source = TYPES[@type].from_lock(@opts)
130
- # Strip out duplicate GIT sections
131
- if @sources.include?(@current_source)
132
- @current_source = @sources.find {|s| s == @current_source }
133
- else
134
- @sources << @current_source
135
- end
117
+ @sources << @current_source
136
118
  when GEM
137
- if Bundler.feature_flag.disable_multisource?
138
- @opts["remotes"] = @opts.delete("remote")
139
- @current_source = TYPES[@type].from_lock(@opts)
140
- @sources << @current_source
141
- else
142
- Array(@opts["remote"]).each do |url|
143
- @rubygems_aggregate.add_remote(url)
144
- end
145
- @current_source = @rubygems_aggregate
146
- end
119
+ @opts["remotes"] = Array(@opts.delete("remote")).reverse
120
+ @current_source = TYPES[@type].from_lock(@opts)
121
+ @sources << @current_source
147
122
  when PLUGIN
148
123
  @current_source = Plugin.source_from_lock(@opts)
149
124
  @sources << @current_source
@@ -221,10 +196,9 @@ module Bundler
221
196
  platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
222
197
  @current_spec = LazySpecification.new(name, version, platform)
223
198
  @current_spec.source = @current_source
199
+ @current_source.add_dependency_names(name)
224
200
 
225
- # Avoid introducing multiple copies of the same spec (caused by
226
- # duplicate GIT sections)
227
- @specs[@current_spec.identifier] ||= @current_spec
201
+ @specs[@current_spec.identifier] = @current_spec
228
202
  elsif spaces.size == 6
229
203
  version = version.split(",").map(&:strip) if version
230
204
  dep = Gem::Dependency.new(name, version)
@@ -0,0 +1 @@
1
+ # Ignore all files in this directory
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-ADD" "1" "January 2020" "" ""
4
+ .TH "BUNDLE\-ADD" "1" "December 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-BINSTUBS" "1" "January 2020" "" ""
4
+ .TH "BUNDLE\-BINSTUBS" "1" "December 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
@@ -36,5 +36,7 @@ Makes binstubs that can work without depending on Rubygems or Bundler at runtime
36
36
  \fB\-\-shebang\fR
37
37
  Specify a different shebang executable name than the default (default \'ruby\')
38
38
  .
39
- .SH "BUNDLE INSTALL \-\-BINSTUBS"
40
- To create binstubs for all the gems in the bundle you can use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR\.
39
+ .TP
40
+ \fB\-\-all\fR
41
+ Create binstubs for all gems in the bundle\.
42
+
@@ -37,7 +37,5 @@ Calling binstubs with [GEM [GEM]] will create binstubs for all given gems.
37
37
  * `--shebang`:
38
38
  Specify a different shebang executable name than the default (default 'ruby')
39
39
 
40
- ## BUNDLE INSTALL --BINSTUBS
41
-
42
- To create binstubs for all the gems in the bundle you can use the `--binstubs`
43
- flag in [bundle install(1)](bundle-install.1.html).
40
+ * `--all`:
41
+ Create binstubs for all gems in the bundle.