bundler 2.3.12 → 2.4.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +535 -1
  3. data/README.md +3 -6
  4. data/bundler.gemspec +8 -10
  5. data/exe/bundle +5 -16
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +5 -1
  9. data/lib/bundler/cli/check.rb +1 -1
  10. data/lib/bundler/cli/common.rb +3 -1
  11. data/lib/bundler/cli/console.rb +2 -2
  12. data/lib/bundler/cli/doctor.rb +4 -6
  13. data/lib/bundler/cli/gem.rb +62 -40
  14. data/lib/bundler/cli/init.rb +6 -2
  15. data/lib/bundler/cli/install.rb +7 -5
  16. data/lib/bundler/cli/lock.rb +8 -5
  17. data/lib/bundler/cli/open.rb +6 -4
  18. data/lib/bundler/cli/outdated.rb +13 -6
  19. data/lib/bundler/cli/platform.rb +1 -1
  20. data/lib/bundler/cli/viz.rb +1 -1
  21. data/lib/bundler/cli.rb +53 -7
  22. data/lib/bundler/compact_index_client/cache.rb +1 -1
  23. data/lib/bundler/compact_index_client/updater.rb +53 -39
  24. data/lib/bundler/constants.rb +1 -1
  25. data/lib/bundler/current_ruby.rb +17 -6
  26. data/lib/bundler/definition.rb +277 -139
  27. data/lib/bundler/dependency.rb +21 -84
  28. data/lib/bundler/digest.rb +1 -1
  29. data/lib/bundler/dsl.rb +13 -18
  30. data/lib/bundler/endpoint_specification.rb +2 -10
  31. data/lib/bundler/env.rb +1 -1
  32. data/lib/bundler/environment_preserver.rb +3 -2
  33. data/lib/bundler/errors.rb +15 -15
  34. data/lib/bundler/feature_flag.rb +0 -2
  35. data/lib/bundler/fetcher/base.rb +6 -8
  36. data/lib/bundler/fetcher/compact_index.rb +9 -11
  37. data/lib/bundler/fetcher/dependency.rb +2 -6
  38. data/lib/bundler/fetcher/downloader.rb +2 -5
  39. data/lib/bundler/fetcher.rb +14 -14
  40. data/lib/bundler/force_platform.rb +18 -0
  41. data/lib/bundler/friendly_errors.rb +21 -7
  42. data/lib/bundler/gem_helpers.rb +9 -2
  43. data/lib/bundler/gem_version_promoter.rb +53 -98
  44. data/lib/bundler/graph.rb +3 -3
  45. data/lib/bundler/index.rb +13 -51
  46. data/lib/bundler/injector.rb +9 -4
  47. data/lib/bundler/inline.rb +9 -21
  48. data/lib/bundler/installer/gem_installer.rb +14 -1
  49. data/lib/bundler/installer/parallel_installer.rb +3 -33
  50. data/lib/bundler/installer/standalone.rb +42 -11
  51. data/lib/bundler/installer.rb +19 -40
  52. data/lib/bundler/lazy_specification.rb +55 -54
  53. data/lib/bundler/lockfile_generator.rb +3 -3
  54. data/lib/bundler/lockfile_parser.rb +21 -16
  55. data/lib/bundler/man/bundle-add.1 +13 -5
  56. data/lib/bundler/man/bundle-add.1.ronn +10 -4
  57. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  58. data/lib/bundler/man/bundle-cache.1 +9 -3
  59. data/lib/bundler/man/bundle-cache.1.ronn +9 -2
  60. data/lib/bundler/man/bundle-check.1 +1 -1
  61. data/lib/bundler/man/bundle-clean.1 +2 -2
  62. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  63. data/lib/bundler/man/bundle-config.1 +26 -10
  64. data/lib/bundler/man/bundle-config.1.ronn +17 -10
  65. data/lib/bundler/man/bundle-console.1 +53 -0
  66. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  67. data/lib/bundler/man/bundle-doctor.1 +1 -1
  68. data/lib/bundler/man/bundle-exec.1 +6 -6
  69. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  70. data/lib/bundler/man/bundle-gem.1 +27 -37
  71. data/lib/bundler/man/bundle-gem.1.ronn +5 -5
  72. data/lib/bundler/man/bundle-help.1 +13 -0
  73. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  74. data/lib/bundler/man/bundle-info.1 +1 -1
  75. data/lib/bundler/man/bundle-init.1 +5 -1
  76. data/lib/bundler/man/bundle-init.1.ronn +2 -0
  77. data/lib/bundler/man/bundle-inject.1 +5 -2
  78. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  79. data/lib/bundler/man/bundle-install.1 +5 -30
  80. data/lib/bundler/man/bundle-install.1.ronn +6 -29
  81. data/lib/bundler/man/bundle-list.1 +1 -1
  82. data/lib/bundler/man/bundle-lock.1 +1 -1
  83. data/lib/bundler/man/bundle-open.1 +22 -2
  84. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  85. data/lib/bundler/man/bundle-outdated.1 +13 -9
  86. data/lib/bundler/man/bundle-outdated.1.ronn +12 -9
  87. data/lib/bundler/man/bundle-platform.1 +16 -6
  88. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  89. data/lib/bundler/man/bundle-plugin.1 +81 -0
  90. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  91. data/lib/bundler/man/bundle-pristine.1 +1 -1
  92. data/lib/bundler/man/bundle-remove.1 +1 -1
  93. data/lib/bundler/man/bundle-show.1 +1 -1
  94. data/lib/bundler/man/bundle-update.1 +1 -1
  95. data/lib/bundler/man/bundle-version.1 +35 -0
  96. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  97. data/lib/bundler/man/bundle-viz.1 +4 -1
  98. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  99. data/lib/bundler/man/bundle.1 +15 -10
  100. data/lib/bundler/man/bundle.1.ronn +12 -7
  101. data/lib/bundler/man/gemfile.5 +93 -82
  102. data/lib/bundler/man/gemfile.5.ronn +99 -86
  103. data/lib/bundler/man/index.txt +4 -0
  104. data/lib/bundler/match_metadata.rb +13 -0
  105. data/lib/bundler/match_platform.rb +0 -1
  106. data/lib/bundler/match_remote_metadata.rb +29 -0
  107. data/lib/bundler/mirror.rb +5 -7
  108. data/lib/bundler/plugin/api/source.rb +3 -3
  109. data/lib/bundler/plugin/index.rb +4 -4
  110. data/lib/bundler/plugin/installer/git.rb +0 -4
  111. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  112. data/lib/bundler/plugin/installer.rb +5 -2
  113. data/lib/bundler/plugin.rb +3 -1
  114. data/lib/bundler/process_lock.rb +1 -1
  115. data/lib/bundler/remote_specification.rb +7 -12
  116. data/lib/bundler/resolver/base.rb +107 -0
  117. data/lib/bundler/resolver/candidate.rb +94 -0
  118. data/lib/bundler/resolver/incompatibility.rb +15 -0
  119. data/lib/bundler/resolver/package.rb +72 -0
  120. data/lib/bundler/resolver/root.rb +25 -0
  121. data/lib/bundler/resolver/spec_group.rb +42 -70
  122. data/lib/bundler/resolver.rb +333 -326
  123. data/lib/bundler/ruby_dsl.rb +1 -1
  124. data/lib/bundler/ruby_version.rb +6 -6
  125. data/lib/bundler/rubygems_ext.rb +107 -15
  126. data/lib/bundler/rubygems_gem_installer.rb +32 -20
  127. data/lib/bundler/rubygems_integration.rb +13 -35
  128. data/lib/bundler/runtime.rb +2 -7
  129. data/lib/bundler/safe_marshal.rb +31 -0
  130. data/lib/bundler/settings.rb +6 -12
  131. data/lib/bundler/setup.rb +4 -1
  132. data/lib/bundler/shared_helpers.rb +8 -8
  133. data/lib/bundler/source/git/git_proxy.rb +237 -74
  134. data/lib/bundler/source/git.rb +54 -38
  135. data/lib/bundler/source/metadata.rb +1 -2
  136. data/lib/bundler/source/path/installer.rb +1 -22
  137. data/lib/bundler/source/path.rb +7 -7
  138. data/lib/bundler/source/rubygems.rb +85 -128
  139. data/lib/bundler/source.rb +4 -5
  140. data/lib/bundler/source_list.rb +12 -2
  141. data/lib/bundler/spec_set.rb +62 -34
  142. data/lib/bundler/stub_specification.rb +5 -3
  143. data/lib/bundler/templates/Executable +1 -1
  144. data/lib/bundler/templates/Executable.bundler +5 -10
  145. data/lib/bundler/templates/Executable.standalone +2 -0
  146. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  147. data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  148. data/lib/bundler/templates/newgem/README.md.tt +6 -4
  149. data/lib/bundler/templates/newgem/Rakefile.tt +12 -1
  150. data/lib/bundler/templates/newgem/bin/console.tt +0 -4
  151. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  152. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  153. data/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt +10 -0
  154. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  155. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +1 -1
  156. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  157. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +10 -0
  158. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  159. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  160. data/lib/bundler/templates/newgem/newgem.gemspec.tt +9 -2
  161. data/lib/bundler/ui/shell.rb +35 -12
  162. data/lib/bundler/ui/silent.rb +21 -5
  163. data/lib/bundler/uri_normalizer.rb +23 -0
  164. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  165. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  166. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  167. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1351 -409
  168. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  169. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  170. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  171. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  172. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  173. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  174. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +150 -0
  175. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  176. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  177. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  178. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  179. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +60 -0
  180. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  181. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  182. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +129 -0
  183. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +411 -0
  184. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +248 -0
  185. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  186. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  187. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +1 -1
  188. data/lib/bundler/vendor/uri/lib/uri/common.rb +64 -16
  189. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  190. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -1
  191. data/lib/bundler/vendor/uri/lib/uri/generic.rb +27 -7
  192. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -2
  193. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -1
  194. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  195. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  196. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -2
  197. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +15 -9
  198. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +11 -6
  199. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  200. data/lib/bundler/vendor/uri/lib/uri/ws.rb +1 -2
  201. data/lib/bundler/vendor/uri/lib/uri/wss.rb +2 -1
  202. data/lib/bundler/vendor/uri/lib/uri.rb +3 -2
  203. data/lib/bundler/vendored_persistent.rb +1 -33
  204. data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  205. data/lib/bundler/version.rb +5 -1
  206. data/lib/bundler/worker.rb +5 -7
  207. data/lib/bundler.rb +36 -77
  208. metadata +47 -35
  209. data/lib/bundler/dep_proxy.rb +0 -55
  210. data/lib/bundler/templates/gems.rb +0 -5
  211. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +0 -5
  212. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  213. data/lib/bundler/vendor/molinillo/LICENSE +0 -9
  214. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  215. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  216. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  217. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  218. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  219. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  220. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  221. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  222. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  223. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  224. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  225. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  226. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -149
  227. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  228. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  229. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  230. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  231. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  232. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  233. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  234. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  235. data/lib/bundler/vendored_molinillo.rb +0 -4
  236. data/lib/bundler/version_ranges.rb +0 -122
@@ -13,7 +13,7 @@ module Bundler
13
13
  Installer.ambiguous_gems = []
14
14
  end
15
15
 
16
- attr_reader :post_install_messages
16
+ attr_reader :post_install_messages, :definition
17
17
 
18
18
  # Begins the installation process for Bundler.
19
19
  # For more information see the #run method on this class.
@@ -66,7 +66,7 @@ module Bundler
66
66
  # require paths and save them in a `setup.rb` file. See `bundle standalone --help` for more
67
67
  # information.
68
68
  def run(options)
69
- create_bundle_path
69
+ Bundler.create_bundle_path
70
70
 
71
71
  ProcessLock.lock do
72
72
  if Bundler.frozen_bundle?
@@ -90,7 +90,7 @@ module Bundler
90
90
 
91
91
  Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
92
92
 
93
- lock unless Bundler.frozen_bundle?
93
+ lock
94
94
  Standalone.new(options[:standalone], @definition).generate if options[:standalone]
95
95
  end
96
96
  end
@@ -136,11 +136,7 @@ module Bundler
136
136
 
137
137
  mode = Gem.win_platform? ? "wb:UTF-8" : "w"
138
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
139
+ content = ERB.new(template, :trim_mode => "-").result(binding)
144
140
 
145
141
  File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
146
142
  if Gem.win_platform? || options[:all_platforms]
@@ -183,11 +179,7 @@ module Bundler
183
179
 
184
180
  mode = Gem.win_platform? ? "wb:UTF-8" : "w"
185
181
  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
182
+ content = ERB.new(template, :trim_mode => "-").result(binding)
191
183
 
192
184
  File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
193
185
  if Gem.win_platform? || options[:all_platforms]
@@ -226,31 +218,24 @@ module Bundler
226
218
 
227
219
  requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
228
220
  path_plugin_files = requested_path_gems.map do |spec|
229
- begin
230
- Bundler.rubygems.spec_matches_for_glob(spec, "rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
231
- rescue TypeError
232
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
233
- raise Gem::InvalidSpecificationException, error_message
234
- 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
235
225
  end.flatten
236
226
  Bundler.rubygems.load_plugin_files(path_plugin_files)
237
227
  Bundler.rubygems.load_env_plugins
238
228
  end
239
229
 
240
230
  def ensure_specs_are_compatible!
241
- system_ruby = Bundler::RubyVersion.system
242
- rubygems_version = Bundler.rubygems.version
243
231
  @definition.specs.each do |spec|
244
- if required_ruby_version = spec.required_ruby_version
245
- unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
246
- raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
247
- "which is incompatible with the current version, #{system_ruby}"
248
- 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}"
249
235
  end
250
- next unless required_rubygems_version = spec.required_rubygems_version
251
- unless required_rubygems_version.satisfied_by?(rubygems_version)
252
- raise InstallError, "#{spec.full_name} requires rubygems version #{required_rubygems_version}, " \
253
- "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}"
254
239
  end
255
240
  end
256
241
  end
@@ -262,22 +247,16 @@ module Bundler
262
247
  end
263
248
  end
264
249
 
265
- def create_bundle_path
266
- SharedHelpers.filesystem_access(Bundler.bundle_path.to_s) do |p|
267
- Bundler.mkdir_p(p)
268
- end unless Bundler.bundle_path.exist?
269
- rescue Errno::EEXIST
270
- raise PathError, "Could not install to path `#{Bundler.bundle_path}` " \
271
- "because a file already exists at that path. Either remove or rename the file so the directory can be created."
272
- end
273
-
274
250
  # returns whether or not a re-resolve was needed
275
251
  def resolve_if_needed(options)
252
+ @definition.resolution_mode = options
253
+
276
254
  if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
277
255
  return false if @definition.nothing_changed? && !@definition.missing_specs?
278
256
  end
279
257
 
280
- options["local"] ? @definition.resolve_with_cache! : @definition.resolve_remotely!
258
+ @definition.setup_sources_for_resolve
259
+
281
260
  true
282
261
  end
283
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,15 +28,15 @@ 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
 
41
42
  ##
@@ -61,7 +62,7 @@ module Bundler
61
62
  def to_lock
62
63
  out = String.new
63
64
 
64
- if platform == Gem::Platform::RUBY || platform.nil?
65
+ if platform == Gem::Platform::RUBY
65
66
  out << " #{name} (#{version})\n"
66
67
  else
67
68
  out << " #{name} (#{version}-#{platform})\n"
@@ -75,76 +76,74 @@ module Bundler
75
76
  out
76
77
  end
77
78
 
78
- def __materialize__
79
- @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
80
- 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
81
87
  else
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)
91
- end
92
- installable_candidates = same_platform_candidates.select do |spec|
93
- spec.is_a?(StubSpecification) ||
94
- (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
95
- 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)
96
97
  end
97
- search = installable_candidates.last
98
- search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
99
- search
98
+
99
+ installable_candidates
100
100
  end
101
+
102
+ __materialize__(candidates)
101
103
  end
102
104
 
103
- def respond_to?(*args)
104
- 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
105
122
  end
106
123
 
107
124
  def to_s
108
- @__to_s ||= if platform == Gem::Platform::RUBY || platform.nil?
125
+ @to_s ||= if platform == Gem::Platform::RUBY
109
126
  "#{name} (#{version})"
110
127
  else
111
128
  "#{name} (#{version}-#{platform})"
112
129
  end
113
130
  end
114
131
 
115
- def identifier
116
- @__identifier ||= [name, version, platform_string]
117
- end
118
-
119
132
  def git_version
120
133
  return unless source.is_a?(Bundler::Source::Git)
121
134
  " #{source.revision[0..6]}"
122
135
  end
123
136
 
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
137
  private
132
138
 
133
- def to_ary
134
- nil
135
- end
136
-
137
- def method_missing(method, *args, &blk)
138
- raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
139
-
140
- return super unless respond_to?(method)
141
-
142
- @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?
143
141
  end
144
142
 
145
143
  #
146
144
  # For backwards compatibility with existing lockfiles, if the most specific
147
- # 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
148
147
  # best platform variant at materiliazation time. For previous bundler
149
148
  # versions (before 2.2.0) this was always the case (except when the lockfile
150
149
  # only included non-ruby platforms), but we're also keeping this behaviour
@@ -152,7 +151,9 @@ module Bundler
152
151
  # explicitly add a more specific platform.
153
152
  #
154
153
  def ruby_platform_materializes_to_ruby_platform?
155
- !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]
156
157
  end
157
158
  end
158
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", Bundler::VERSION)
74
+ add_section("BUNDLED WITH", definition.bundler_version_to_lock.to_s)
75
75
  end
76
76
 
77
77
  def add_section(name, value)
@@ -4,15 +4,15 @@ module Bundler
4
4
  class LockfileParser
5
5
  attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
6
6
 
7
- BUNDLED = "BUNDLED WITH".freeze
8
- DEPENDENCIES = "DEPENDENCIES".freeze
9
- PLATFORMS = "PLATFORMS".freeze
10
- RUBY = "RUBY VERSION".freeze
11
- GIT = "GIT".freeze
12
- GEM = "GEM".freeze
13
- PATH = "PATH".freeze
14
- PLUGIN = "PLUGIN SOURCE".freeze
15
- 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:"
16
16
  OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
17
17
  SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
18
18
 
@@ -26,6 +26,7 @@ module Bundler
26
26
  KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
27
27
 
28
28
  ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
29
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
29
30
 
30
31
  def self.sections_in_lockfile(lockfile_contents)
31
32
  lockfile_contents.scan(/^\w[\w ]*$/).uniq
@@ -63,7 +64,7 @@ module Bundler
63
64
  @state = nil
64
65
  @specs = {}
65
66
 
66
- if lockfile.match(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
67
+ if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
67
68
  raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
68
69
  "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
69
70
  end
@@ -80,25 +81,29 @@ module Bundler
80
81
  @state = :ruby
81
82
  elsif line == BUNDLED
82
83
  @state = :bundled_with
83
- elsif line =~ /^[^\s]/
84
+ elsif /^[^\s]/.match?(line)
84
85
  @state = nil
85
86
  elsif @state
86
87
  send("parse_#{@state}", line)
87
88
  end
88
89
  end
89
- @specs = @specs.values.sort_by(&:identifier)
90
+ @specs = @specs.values.sort_by(&:full_name)
90
91
  rescue ArgumentError => e
91
92
  Bundler.ui.debug(e)
92
93
  raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
93
94
  "and then `bundle install` to generate a new lockfile."
94
95
  end
95
96
 
97
+ def may_include_redundant_platform_specific_gems?
98
+ bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
99
+ end
100
+
96
101
  private
97
102
 
98
103
  TYPES = {
99
- GIT => Bundler::Source::Git,
100
- GEM => Bundler::Source::Rubygems,
101
- PATH => Bundler::Source::Path,
104
+ GIT => Bundler::Source::Git,
105
+ GEM => Bundler::Source::Rubygems,
106
+ PATH => Bundler::Source::Path,
102
107
  PLUGIN => Bundler::Plugin,
103
108
  }.freeze
104
109
 
@@ -195,7 +200,7 @@ module Bundler
195
200
  @current_spec.source = @current_source
196
201
  @current_source.add_dependency_names(name)
197
202
 
198
- @specs[@current_spec.identifier] = @current_spec
203
+ @specs[@current_spec.full_name] = @current_spec
199
204
  elsif spaces.size == 6
200
205
  version = version.split(",").map(&:strip) if version
201
206
  dep = Gem::Dependency.new(name, version)
@@ -1,13 +1,13 @@
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" "March 2022" "" ""
4
+ .TH "BUNDLE\-ADD" "1" "July 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
8
8
  .
9
9
  .SH "SYNOPSIS"
10
- \fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
10
+ \fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
11
11
  .
12
12
  .SH "DESCRIPTION"
13
13
  Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
@@ -41,10 +41,18 @@ Specify version requirements(s) for the added gem\.
41
41
  Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
42
42
  .
43
43
  .TP
44
- \fB\-\-source\fR, , \fB\-s\fR
44
+ \fB\-\-source\fR, \fB\-s\fR
45
45
  Specify the source for the added gem\.
46
46
  .
47
47
  .TP
48
+ \fB\-\-require\fR, \fB\-r\fR
49
+ Adds require path to gem\. Provide false, or a path as a string\.
50
+ .
51
+ .TP
52
+ \fB\-\-path\fR
53
+ Specify the file system path for the added gem\.
54
+ .
55
+ .TP
48
56
  \fB\-\-git\fR
49
57
  Specify the git source for the added gem\.
50
58
  .
@@ -66,9 +74,9 @@ Adds the gem to the Gemfile but does not install it\.
66
74
  .
67
75
  .TP
68
76
  \fB\-\-optimistic\fR
69
- Adds optimistic declaration of version
77
+ Adds optimistic declaration of version\.
70
78
  .
71
79
  .TP
72
80
  \fB\-\-strict\fR
73
- Adds strict declaration of version
81
+ Adds strict declaration of version\.
74
82
 
@@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
6
+ `bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--path=PATH] [--git=GIT] [--github=GITHUB] [--branch=BRANCH] [--ref=REF] [--skip-install] [--strict] [--optimistic]
7
7
 
8
8
  ## DESCRIPTION
9
9
  Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.
@@ -27,9 +27,15 @@ bundle add rails --group "development, test"
27
27
  * `--group`, `-g`:
28
28
  Specify the group(s) for the added gem. Multiple groups should be separated by commas.
29
29
 
30
- * `--source`, , `-s`:
30
+ * `--source`, `-s`:
31
31
  Specify the source for the added gem.
32
32
 
33
+ * `--require`, `-r`:
34
+ Adds require path to gem. Provide false, or a path as a string.
35
+
36
+ * `--path`:
37
+ Specify the file system path for the added gem.
38
+
33
39
  * `--git`:
34
40
  Specify the git source for the added gem.
35
41
 
@@ -46,7 +52,7 @@ bundle add rails --group "development, test"
46
52
  Adds the gem to the Gemfile but does not install it.
47
53
 
48
54
  * `--optimistic`:
49
- Adds optimistic declaration of version
55
+ Adds optimistic declaration of version.
50
56
 
51
57
  * `--strict`:
52
- Adds strict declaration of version
58
+ Adds strict declaration of version.
@@ -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" "March 2022" "" ""
4
+ .TH "BUNDLE\-BINSTUBS" "1" "July 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
@@ -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\-CACHE" "1" "March 2022" "" ""
4
+ .TH "BUNDLE\-CACHE" "1" "July 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
@@ -9,8 +9,11 @@
9
9
  .SH "SYNOPSIS"
10
10
  \fBbundle cache\fR
11
11
  .
12
+ .P
13
+ alias: \fBpackage\fR, \fBpack\fR
14
+ .
12
15
  .SH "DESCRIPTION"
13
- Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
16
+ Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR, use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
14
17
  .
15
18
  .SH "GIT AND PATH GEMS"
16
19
  The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
@@ -19,7 +22,7 @@ The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR depen
19
22
  When using gems that have different packages for different platforms, Bundler supports caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
20
23
  .
21
24
  .SH "REMOTE FETCHING"
22
- By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
25
+ By default, if you run \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
23
26
  .
24
27
  .P
25
28
  For instance, consider this Gemfile(5):
@@ -53,3 +56,6 @@ One way to be sure that you have the right platformed versions of all your gems
53
56
  .
54
57
  .P
55
58
  By default, bundle cache(1) \fIbundle\-cache\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle cache \-\-no\-install\fR\.
59
+ .
60
+ .SH "HISTORY"
61
+ In Bundler 2\.1, \fBcache\fR took in the functionalities of \fBpackage\fR and now \fBpackage\fR and \fBpack\fR are aliases of \fBcache\fR\.
@@ -5,10 +5,12 @@ bundle-cache(1) -- Package your needed `.gem` files into your application
5
5
 
6
6
  `bundle cache`
7
7
 
8
+ alias: `package`, `pack`
9
+
8
10
  ## DESCRIPTION
9
11
 
10
12
  Copy all of the `.gem` files needed to run the application into the
11
- `vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
13
+ `vendor/cache` directory. In the future, when running [`bundle install(1)`](bundle-install.1.html),
12
14
  use the gems in the cache in preference to the ones on `rubygems.org`.
13
15
 
14
16
  ## GIT AND PATH GEMS
@@ -27,7 +29,7 @@ bundler configuration.
27
29
 
28
30
  ## REMOTE FETCHING
29
31
 
30
- By default, if you run `bundle install(1)`](bundle-install.1.html) after running
32
+ By default, if you run [`bundle install(1)`](bundle-install.1.html) after running
31
33
  [bundle cache(1)](bundle-cache.1.html), bundler will still connect to `rubygems.org`
32
34
  to check whether a platform-specific gem exists for any of the gems
33
35
  in `vendor/cache`.
@@ -70,3 +72,8 @@ By default, [bundle cache(1)](bundle-cache.1.html) fetches and also
70
72
  installs the gems to the default location. To package the
71
73
  dependencies to `vendor/cache` without installing them to the
72
74
  local install location, you can run `bundle cache --no-install`.
75
+
76
+ ## HISTORY
77
+
78
+ In Bundler 2.1, `cache` took in the functionalities of `package` and now
79
+ `package` and `pack` are aliases of `cache`.
@@ -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\-CHECK" "1" "March 2022" "" ""
4
+ .TH "BUNDLE\-CHECK" "1" "July 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
@@ -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\-CLEAN" "1" "March 2022" "" ""
4
+ .TH "BUNDLE\-CLEAN" "1" "July 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
@@ -20,5 +20,5 @@ Print the changes, but do not clean the unused gems\.
20
20
  .
21
21
  .TP
22
22
  \fB\-\-force\fR
23
- Force a clean even if \fB\-\-path\fR is not set\.
23
+ Forces cleaning up unused gems even if Bundler is configured to use globally installed gems\. As a consequence, removes all system gems except for the ones in the current application\.
24
24
 
@@ -15,4 +15,4 @@ useful when you have made many changes to your gem dependencies.
15
15
  * `--dry-run`:
16
16
  Print the changes, but do not clean the unused gems.
17
17
  * `--force`:
18
- Force a clean even if `--path` is not set.
18
+ Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application.