bundler 2.5.22 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +83 -0
  3. data/bundler.gemspec +2 -2
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli/add.rb +2 -0
  6. data/lib/bundler/cli/check.rb +2 -2
  7. data/lib/bundler/cli/console.rb +0 -4
  8. data/lib/bundler/cli/doctor.rb +4 -4
  9. data/lib/bundler/cli/exec.rb +1 -0
  10. data/lib/bundler/cli/gem.rb +1 -1
  11. data/lib/bundler/cli/info.rb +2 -2
  12. data/lib/bundler/cli/inject.rb +1 -1
  13. data/lib/bundler/cli/install.rb +4 -0
  14. data/lib/bundler/cli/lock.rb +20 -1
  15. data/lib/bundler/cli/pristine.rb +1 -1
  16. data/lib/bundler/cli/show.rb +2 -2
  17. data/lib/bundler/cli.rb +23 -53
  18. data/lib/bundler/compact_index_client/cache_file.rb +0 -5
  19. data/lib/bundler/compact_index_client/updater.rb +0 -11
  20. data/lib/bundler/definition.rb +143 -76
  21. data/lib/bundler/dependency.rb +1 -1
  22. data/lib/bundler/dsl.rb +33 -28
  23. data/lib/bundler/endpoint_specification.rb +10 -1
  24. data/lib/bundler/errors.rb +10 -0
  25. data/lib/bundler/feature_flag.rb +1 -0
  26. data/lib/bundler/fetcher/compact_index.rb +1 -1
  27. data/lib/bundler/fetcher.rb +10 -3
  28. data/lib/bundler/gem_helpers.rb +21 -5
  29. data/lib/bundler/injector.rb +2 -2
  30. data/lib/bundler/inline.rb +12 -8
  31. data/lib/bundler/installer/standalone.rb +2 -2
  32. data/lib/bundler/installer.rb +4 -38
  33. data/lib/bundler/lazy_specification.rb +74 -26
  34. data/lib/bundler/lockfile_generator.rb +1 -1
  35. data/lib/bundler/lockfile_parser.rb +9 -1
  36. data/lib/bundler/man/bundle-add.1 +17 -11
  37. data/lib/bundler/man/bundle-add.1.ronn +16 -10
  38. data/lib/bundler/man/bundle-binstubs.1 +7 -4
  39. data/lib/bundler/man/bundle-binstubs.1.ronn +6 -3
  40. data/lib/bundler/man/bundle-cache.1 +30 -2
  41. data/lib/bundler/man/bundle-cache.1.ronn +31 -2
  42. data/lib/bundler/man/bundle-check.1 +3 -3
  43. data/lib/bundler/man/bundle-check.1.ronn +4 -2
  44. data/lib/bundler/man/bundle-clean.1 +1 -1
  45. data/lib/bundler/man/bundle-config.1 +3 -5
  46. data/lib/bundler/man/bundle-config.1.ronn +2 -7
  47. data/lib/bundler/man/bundle-console.1 +2 -4
  48. data/lib/bundler/man/bundle-console.1.ronn +2 -7
  49. data/lib/bundler/man/bundle-doctor.1 +2 -2
  50. data/lib/bundler/man/bundle-doctor.1.ronn +1 -1
  51. data/lib/bundler/man/bundle-env.1 +9 -0
  52. data/lib/bundler/man/bundle-env.1.ronn +10 -0
  53. data/lib/bundler/man/bundle-exec.1 +5 -2
  54. data/lib/bundler/man/bundle-exec.1.ronn +4 -1
  55. data/lib/bundler/man/bundle-fund.1 +22 -0
  56. data/lib/bundler/man/bundle-fund.1.ronn +25 -0
  57. data/lib/bundler/man/bundle-gem.1 +17 -5
  58. data/lib/bundler/man/bundle-gem.1.ronn +27 -6
  59. data/lib/bundler/man/bundle-help.1 +1 -1
  60. data/lib/bundler/man/bundle-info.1 +5 -2
  61. data/lib/bundler/man/bundle-info.1.ronn +6 -2
  62. data/lib/bundler/man/bundle-init.1 +3 -3
  63. data/lib/bundler/man/bundle-init.1.ronn +3 -2
  64. data/lib/bundler/man/bundle-inject.1 +10 -2
  65. data/lib/bundler/man/bundle-inject.1.ronn +9 -1
  66. data/lib/bundler/man/bundle-install.1 +15 -12
  67. data/lib/bundler/man/bundle-install.1.ronn +22 -18
  68. data/lib/bundler/man/bundle-issue.1 +45 -0
  69. data/lib/bundler/man/bundle-issue.1.ronn +37 -0
  70. data/lib/bundler/man/bundle-licenses.1 +9 -0
  71. data/lib/bundler/man/bundle-licenses.1.ronn +10 -0
  72. data/lib/bundler/man/bundle-list.1 +1 -1
  73. data/lib/bundler/man/bundle-list.1.ronn +4 -1
  74. data/lib/bundler/man/bundle-lock.1 +21 -6
  75. data/lib/bundler/man/bundle-lock.1.ronn +25 -4
  76. data/lib/bundler/man/bundle-open.1 +2 -2
  77. data/lib/bundler/man/bundle-open.1.ronn +2 -1
  78. data/lib/bundler/man/bundle-outdated.1 +8 -5
  79. data/lib/bundler/man/bundle-outdated.1.ronn +8 -4
  80. data/lib/bundler/man/bundle-platform.1 +1 -1
  81. data/lib/bundler/man/bundle-plugin.1 +1 -1
  82. data/lib/bundler/man/bundle-pristine.1 +1 -1
  83. data/lib/bundler/man/bundle-pristine.1.ronn +1 -1
  84. data/lib/bundler/man/bundle-remove.1 +1 -1
  85. data/lib/bundler/man/bundle-remove.1.ronn +1 -1
  86. data/lib/bundler/man/bundle-show.1 +5 -2
  87. data/lib/bundler/man/bundle-show.1.ronn +4 -0
  88. data/lib/bundler/man/bundle-update.1 +13 -7
  89. data/lib/bundler/man/bundle-update.1.ronn +14 -6
  90. data/lib/bundler/man/bundle-version.1 +1 -1
  91. data/lib/bundler/man/bundle-viz.1 +4 -4
  92. data/lib/bundler/man/bundle-viz.1.ronn +7 -3
  93. data/lib/bundler/man/bundle.1 +1 -1
  94. data/lib/bundler/man/gemfile.5 +1 -1
  95. data/lib/bundler/man/index.txt +4 -0
  96. data/lib/bundler/materialization.rb +59 -0
  97. data/lib/bundler/plugin/events.rb +24 -0
  98. data/lib/bundler/plugin/installer.rb +1 -1
  99. data/lib/bundler/plugin.rb +20 -1
  100. data/lib/bundler/process_lock.rb +10 -14
  101. data/lib/bundler/remote_specification.rb +6 -1
  102. data/lib/bundler/resolver/base.rb +6 -6
  103. data/lib/bundler/resolver/candidate.rb +2 -2
  104. data/lib/bundler/resolver/spec_group.rb +4 -3
  105. data/lib/bundler/resolver.rb +5 -5
  106. data/lib/bundler/rubygems_ext.rb +30 -27
  107. data/lib/bundler/rubygems_gem_installer.rb +3 -2
  108. data/lib/bundler/rubygems_integration.rb +23 -40
  109. data/lib/bundler/runtime.rb +27 -7
  110. data/lib/bundler/self_manager.rb +2 -3
  111. data/lib/bundler/settings.rb +6 -1
  112. data/lib/bundler/shared_helpers.rb +29 -17
  113. data/lib/bundler/source/git/git_proxy.rb +0 -6
  114. data/lib/bundler/source/git.rb +56 -31
  115. data/lib/bundler/source/metadata.rb +2 -3
  116. data/lib/bundler/source/path.rb +2 -2
  117. data/lib/bundler/source_list.rb +1 -1
  118. data/lib/bundler/spec_set.rb +81 -56
  119. data/lib/bundler/stub_specification.rb +8 -0
  120. data/lib/bundler/templates/newgem/Gemfile.tt +0 -3
  121. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  122. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +15 -15
  123. data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -4
  124. data/lib/bundler/uri_credentials_filter.rb +1 -1
  125. data/lib/bundler/vendor/fileutils/COPYING +56 -0
  126. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +15 -13
  127. data/lib/bundler/vendor/securerandom/COPYING +56 -0
  128. data/lib/bundler/vendor/securerandom/lib/securerandom.rb +5 -5
  129. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +3 -5
  130. data/lib/bundler/vendor/thor/lib/thor/group.rb +11 -0
  131. data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +1 -4
  132. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +2 -2
  133. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +2 -1
  134. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +9 -9
  135. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  136. data/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb +5 -21
  137. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  138. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  139. data/lib/bundler/vendor/thor/lib/thor.rb +11 -0
  140. data/lib/bundler/vendor/uri/COPYING +56 -0
  141. data/lib/bundler/vendor/uri/lib/uri/common.rb +37 -16
  142. data/lib/bundler/vendor/uri/lib/uri/file.rb +3 -3
  143. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +1 -1
  144. data/lib/bundler/vendor/uri/lib/uri/generic.rb +16 -26
  145. data/lib/bundler/vendor/uri/lib/uri/http.rb +2 -2
  146. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +10 -3
  147. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +26 -3
  148. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  149. data/lib/bundler/vendor/uri/lib/uri.rb +9 -9
  150. data/lib/bundler/vendored_securerandom.rb +0 -2
  151. data/lib/bundler/version.rb +1 -1
  152. data/lib/bundler.rb +38 -14
  153. metadata +18 -12
  154. data/lib/bundler/vendor/fileutils/LICENSE.txt +0 -22
  155. data/lib/bundler/vendor/securerandom/LICENSE.txt +0 -22
  156. data/lib/bundler/vendor/securerandom/lib/random/formatter.rb +0 -373
  157. data/lib/bundler/vendor/uri/LICENSE.txt +0 -22
@@ -46,7 +46,7 @@ module Bundler
46
46
  end
47
47
  module_function :platform_specificity_match
48
48
 
49
- def select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
49
+ def select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
50
50
  matching = if force_ruby
51
51
  specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! }
52
52
  else
@@ -58,24 +58,40 @@ module Bundler
58
58
  return locked_originally if locked_originally.any?
59
59
  end
60
60
 
61
- sort_best_platform_match(matching, platform)
61
+ matching
62
+ end
63
+ module_function :select_all_platform_match
64
+
65
+ def select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
66
+ matching = select_all_platform_match(specs, platform, force_ruby: force_ruby, prefer_locked: prefer_locked)
67
+
68
+ sort_and_filter_best_platform_match(matching, platform)
62
69
  end
63
70
  module_function :select_best_platform_match
64
71
 
65
72
  def select_best_local_platform_match(specs, force_ruby: false)
66
- select_best_platform_match(specs, local_platform, force_ruby: force_ruby).map(&:materialize_for_installation).compact
73
+ matching = select_all_platform_match(specs, local_platform, force_ruby: force_ruby).filter_map(&:materialized_for_installation)
74
+
75
+ sort_best_platform_match(matching, local_platform)
67
76
  end
68
77
  module_function :select_best_local_platform_match
69
78
 
70
- def sort_best_platform_match(matching, platform)
79
+ def sort_and_filter_best_platform_match(matching, platform)
80
+ return matching if matching.one?
81
+
71
82
  exact = matching.select {|spec| spec.platform == platform }
72
83
  return exact if exact.any?
73
84
 
74
- sorted_matching = matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
85
+ sorted_matching = sort_best_platform_match(matching, platform)
75
86
  exemplary_spec = sorted_matching.first
76
87
 
77
88
  sorted_matching.take_while {|spec| same_specificity(platform, spec, exemplary_spec) && same_deps(spec, exemplary_spec) }
78
89
  end
90
+ module_function :sort_and_filter_best_platform_match
91
+
92
+ def sort_best_platform_match(matching, platform)
93
+ matching.sort_by {|spec| platform_specificity_match(spec.platform, platform) }
94
+ end
79
95
  module_function :sort_best_platform_match
80
96
 
81
97
  class PlatformMatch
@@ -41,7 +41,7 @@ module Bundler
41
41
 
42
42
  # resolve to see if the new deps broke anything
43
43
  @definition = builder.to_definition(lockfile_path, {})
44
- @definition.resolve_remotely!
44
+ @definition.remotely!
45
45
 
46
46
  # since nothing broke, we can add those gems to the gemfile
47
47
  append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
@@ -184,7 +184,7 @@ module Bundler
184
184
  # @param [Array] gems Array of names of gems to be removed.
185
185
  # @param [Pathname] gemfile_path The Gemfile from which to remove dependencies.
186
186
  def remove_gems_from_gemfile(gems, gemfile_path)
187
- patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2\)/
187
+ patterns = /gem\s+(['"])#{Regexp.union(gems)}\1|gem\s*\((['"])#{Regexp.union(gems)}\2.*\)/
188
188
  new_gemfile = []
189
189
  multiline_removal = false
190
190
  File.readlines(gemfile_path).each do |line|
@@ -1,16 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Allows for declaring a Gemfile inline in a ruby script, optionally installing
4
- # any gems that aren't already installed on the user's system.
3
+ # Allows for declaring a Gemfile inline in a ruby script, installing any gems
4
+ # that aren't already installed on the user's system.
5
5
  #
6
6
  # @note Every gem that is specified in this 'Gemfile' will be `require`d, as if
7
7
  # the user had manually called `Bundler.require`. To avoid a requested gem
8
8
  # being automatically required, add the `:require => false` option to the
9
9
  # `gem` dependency declaration.
10
10
  #
11
- # @param install [Boolean] whether gems that aren't already installed on the
12
- # user's system should be installed.
13
- # Defaults to `false`.
11
+ # @param force_latest_compatible [Boolean] Force installing the *latest*
12
+ # compatible versions of the gems,
13
+ # even if compatible versions are
14
+ # already installed locally.
15
+ # This also logs output if the
16
+ # `:quiet` option is not set.
17
+ # Defaults to `false`.
14
18
  #
15
19
  # @param gemfile [Proc] a block that is evaluated as a `Gemfile`.
16
20
  #
@@ -29,13 +33,13 @@
29
33
  #
30
34
  # puts Pod::VERSION # => "0.34.4"
31
35
  #
32
- def gemfile(install = false, options = {}, &gemfile)
36
+ def gemfile(force_latest_compatible = false, options = {}, &gemfile)
33
37
  require_relative "../bundler"
34
38
  Bundler.reset!
35
39
 
36
40
  opts = options.dup
37
41
  ui = opts.delete(:ui) { Bundler::UI::Shell.new }
38
- ui.level = "silent" if opts.delete(:quiet) || !install
42
+ ui.level = "silent" if opts.delete(:quiet) || !force_latest_compatible
39
43
  Bundler.ui = ui
40
44
  raise ArgumentError, "Unknown options: #{opts.keys.join(", ")}" unless opts.empty?
41
45
 
@@ -55,7 +59,7 @@ def gemfile(install = false, options = {}, &gemfile)
55
59
  definition = builder.to_definition(nil, true)
56
60
  definition.validate_runtime!
57
61
 
58
- if install || definition.missing_specs?
62
+ if force_latest_compatible || definition.missing_specs?
59
63
  Bundler.settings.temporary(inline: true, no_install: false) do
60
64
  installer = Bundler::Installer.install(Bundler.root, definition, system: true)
61
65
  installer.post_install_messages.each do |name, message|
@@ -28,7 +28,7 @@ module Bundler
28
28
  private
29
29
 
30
30
  def paths
31
- @specs.map do |spec|
31
+ @specs.flat_map do |spec|
32
32
  next if spec.name == "bundler"
33
33
  Array(spec.require_paths).map do |path|
34
34
  gem_path(path, spec).
@@ -36,7 +36,7 @@ module Bundler
36
36
  sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
37
37
  # This is a static string intentionally. It's interpolated at a later time.
38
38
  end
39
- end.flatten.compact
39
+ end.compact
40
40
  end
41
41
 
42
42
  def version_dir
@@ -77,12 +77,9 @@ module Bundler
77
77
  return
78
78
  end
79
79
 
80
- if resolve_if_needed(options)
80
+ if @definition.setup_domain!(options)
81
81
  ensure_specs_are_compatible!
82
- load_plugins
83
- options.delete(:jobs)
84
- else
85
- options[:jobs] = 1 # to avoid the overhead of Bundler::Worker
82
+ Bundler.load_plugins(@definition)
86
83
  end
87
84
  install(options)
88
85
 
@@ -197,18 +194,14 @@ module Bundler
197
194
  standalone = options[:standalone]
198
195
  force = options[:force]
199
196
  local = options[:local]
200
- jobs = installation_parallelization(options)
197
+ jobs = installation_parallelization
201
198
  spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
202
199
  spec_installations.each do |installation|
203
200
  post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
204
201
  end
205
202
  end
206
203
 
207
- def installation_parallelization(options)
208
- if jobs = options.delete(:jobs)
209
- return jobs
210
- end
211
-
204
+ def installation_parallelization
212
205
  if jobs = Bundler.settings[:jobs]
213
206
  return jobs
214
207
  end
@@ -216,20 +209,6 @@ module Bundler
216
209
  Bundler.settings.processor_count
217
210
  end
218
211
 
219
- def load_plugins
220
- Gem.load_plugins
221
-
222
- requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
223
- path_plugin_files = requested_path_gems.map do |spec|
224
- spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}")
225
- rescue TypeError
226
- error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
227
- raise Gem::InvalidSpecificationException, error_message
228
- end.flatten
229
- Gem.load_plugin_files(path_plugin_files)
230
- Gem.load_env_plugins
231
- end
232
-
233
212
  def ensure_specs_are_compatible!
234
213
  @definition.specs.each do |spec|
235
214
  unless spec.matches_current_ruby?
@@ -243,19 +222,6 @@ module Bundler
243
222
  end
244
223
  end
245
224
 
246
- # returns whether or not a re-resolve was needed
247
- def resolve_if_needed(options)
248
- @definition.prefer_local! if options[:"prefer-local"]
249
-
250
- if options[:local] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
251
- @definition.resolve_with_cache!
252
- false
253
- else
254
- @definition.resolve_remotely!
255
- true
256
- end
257
- end
258
-
259
225
  def lock
260
226
  @definition.lock
261
227
  end
@@ -8,14 +8,26 @@ module Bundler
8
8
  include MatchPlatform
9
9
  include ForcePlatform
10
10
 
11
- attr_reader :name, :version, :platform
11
+ attr_reader :name, :version, :platform, :materialization
12
12
  attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version
13
13
 
14
+ #
15
+ # For backwards compatibility with existing lockfiles, if the most specific
16
+ # locked platform is not a specific platform like x86_64-linux or
17
+ # universal-java-11, then we keep the previous behaviour of resolving the
18
+ # best platform variant at materiliazation time. For previous bundler
19
+ # versions (before 2.2.0) this was always the case (except when the lockfile
20
+ # only included non-ruby platforms), but we're also keeping this behaviour
21
+ # on newer bundlers unless users generate the lockfile from scratch or
22
+ # explicitly add a more specific platform.
23
+ #
24
+ attr_accessor :most_specific_locked_platform
25
+
14
26
  alias_method :runtime_dependencies, :dependencies
15
27
 
16
28
  def self.from_spec(s)
17
29
  lazy_spec = new(s.name, s.version, s.platform, s.source)
18
- lazy_spec.dependencies = s.dependencies
30
+ lazy_spec.dependencies = s.runtime_dependencies
19
31
  lazy_spec.required_ruby_version = s.required_ruby_version
20
32
  lazy_spec.required_rubygems_version = s.required_rubygems_version
21
33
  lazy_spec
@@ -27,9 +39,26 @@ module Bundler
27
39
  @dependencies = []
28
40
  @required_ruby_version = Gem::Requirement.default
29
41
  @required_rubygems_version = Gem::Requirement.default
30
- @platform = platform || Gem::Platform::RUBY
31
- @source = source
42
+ @platform = platform || Gem::Platform::RUBY
43
+
44
+ @original_source = source
45
+ @source = source
46
+
32
47
  @force_ruby_platform = default_force_ruby_platform
48
+ @most_specific_locked_platform = nil
49
+ @materialization = nil
50
+ end
51
+
52
+ def missing?
53
+ @materialization == self
54
+ end
55
+
56
+ def incomplete?
57
+ @materialization.nil?
58
+ end
59
+
60
+ def source_changed?
61
+ @original_source != source
33
62
  end
34
63
 
35
64
  def full_name
@@ -92,16 +121,31 @@ module Bundler
92
121
  out
93
122
  end
94
123
 
95
- def materialize_for_installation
124
+ def materialize_strictly
96
125
  source.local!
97
126
 
98
- matching_specs = source.specs.search(use_exact_resolved_specifications? ? self : [name, version])
127
+ matching_specs = source.specs.search(self)
99
128
  return self if matching_specs.empty?
100
129
 
101
- candidates = if use_exact_resolved_specifications?
102
- matching_specs
130
+ __materialize__(matching_specs)
131
+ end
132
+
133
+ def materialized_for_installation
134
+ @materialization = materialize_for_installation
135
+
136
+ self unless incomplete?
137
+ end
138
+
139
+ def materialize_for_installation
140
+ source.local!
141
+
142
+ if use_exact_resolved_specifications?
143
+ materialize_strictly
103
144
  else
104
- target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
145
+ matching_specs = source.specs.search([name, version])
146
+ return self if matching_specs.empty?
147
+
148
+ target_platform = source.is_a?(Source::Path) ? platform : local_platform
105
149
 
106
150
  installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
107
151
 
@@ -112,10 +156,8 @@ module Bundler
112
156
  installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)
113
157
  end
114
158
 
115
- installable_candidates
159
+ __materialize__(installable_candidates)
116
160
  end
117
-
118
- __materialize__(candidates)
119
161
  end
120
162
 
121
163
  # If in frozen mode, we fallback to a non-installable candidate because by
@@ -129,12 +171,28 @@ module Bundler
129
171
  end
130
172
  if search.nil? && fallback_to_non_installable
131
173
  search = candidates.last
132
- else
133
- search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
174
+ elsif search && search.full_name == full_name
175
+ # We don't validate locally installed dependencies but accept what's in
176
+ # the lockfile instead for performance, since loading locally installed
177
+ # dependencies would mean evaluating all gemspecs, which would affect
178
+ # `bundler/setup` performance
179
+ if search.is_a?(StubSpecification)
180
+ search.dependencies = dependencies
181
+ else
182
+ if !source.is_a?(Source::Path) && search.runtime_dependencies.sort != dependencies.sort
183
+ raise IncorrectLockfileDependencies.new(self)
184
+ end
185
+
186
+ search.locked_platform = platform if search.instance_of?(RemoteSpecification) || search.instance_of?(EndpointSpecification)
187
+ end
134
188
  end
135
189
  search
136
190
  end
137
191
 
192
+ def inspect
193
+ "#<#{self.class} @name=\"#{name}\" (#{full_name.delete_prefix("#{name}-")})>"
194
+ end
195
+
138
196
  def to_s
139
197
  lock_name
140
198
  end
@@ -151,23 +209,13 @@ module Bundler
151
209
  private
152
210
 
153
211
  def use_exact_resolved_specifications?
154
- @use_exact_resolved_specifications ||= !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
212
+ !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?
155
213
  end
156
214
 
157
- #
158
- # For backwards compatibility with existing lockfiles, if the most specific
159
- # locked platform is not a specific platform like x86_64-linux or
160
- # universal-java-11, then we keep the previous behaviour of resolving the
161
- # best platform variant at materiliazation time. For previous bundler
162
- # versions (before 2.2.0) this was always the case (except when the lockfile
163
- # only included non-ruby platforms), but we're also keeping this behaviour
164
- # on newer bundlers unless users generate the lockfile from scratch or
165
- # explicitly add a more specific platform.
166
- #
167
215
  def ruby_platform_materializes_to_ruby_platform?
168
216
  generic_platform = generic_local_platform == Gem::Platform::JAVA ? Gem::Platform::JAVA : Gem::Platform::RUBY
169
217
 
170
- !Bundler.most_specific_locked_platform?(generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
218
+ (most_specific_locked_platform != generic_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
171
219
  end
172
220
  end
173
221
  end
@@ -29,7 +29,7 @@ module Bundler
29
29
  private
30
30
 
31
31
  def add_sources
32
- definition.send(:sources).lock_sources.each_with_index do |source, idx|
32
+ definition.sources.lock_sources.each_with_index do |source, idx|
33
33
  out << "\n" unless idx.zero?
34
34
 
35
35
  # Add the source header
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Bundler
4
4
  class LockfileParser
5
+ include GemHelpers
6
+
5
7
  class Position
6
8
  attr_reader :line, :column
7
9
  def initialize(line, column)
@@ -29,6 +31,7 @@ module Bundler
29
31
  :dependencies,
30
32
  :specs,
31
33
  :platforms,
34
+ :most_specific_locked_platform,
32
35
  :bundler_version,
33
36
  :ruby_version,
34
37
  :checksums,
@@ -136,7 +139,12 @@ module Bundler
136
139
  end
137
140
  @pos.advance!(line)
138
141
  end
139
- @specs = @specs.values.sort_by!(&:full_name)
142
+ @most_specific_locked_platform = @platforms.min_by do |bundle_platform|
143
+ platform_specificity_match(bundle_platform, local_platform)
144
+ end
145
+ @specs = @specs.values.sort_by!(&:full_name).each do |spec|
146
+ spec.most_specific_locked_platform = @most_specific_locked_platform
147
+ end
140
148
  rescue ArgumentError => e
141
149
  Bundler.ui.debug(e)
142
150
  raise LockfileError, "Your lockfile is unreadable. Run `rm #{@lockfile_path}` " \
@@ -1,41 +1,47 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-ADD" "1" "September 2024" ""
3
+ .TH "BUNDLE\-ADD" "1" "December 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
6
6
  .SH "SYNOPSIS"
7
- \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]
7
+ \fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT|\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-quiet] [\-\-skip\-install] [\-\-strict|\-\-optimistic]
8
8
  .SH "DESCRIPTION"
9
9
  Adds the named gem to the [\fBGemfile(5)\fR][Gemfile(5)] and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
10
10
  .SH "OPTIONS"
11
11
  .TP
12
- \fB\-\-version\fR, \fB\-v\fR
12
+ \fB\-\-version=VERSION\fR, \fB\-v=VERSION\fR
13
13
  Specify version requirements(s) for the added gem\.
14
14
  .TP
15
- \fB\-\-group\fR, \fB\-g\fR
15
+ \fB\-\-group=GROUP\fR, \fB\-g=GROUP\fR
16
16
  Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
17
17
  .TP
18
- \fB\-\-source\fR, \fB\-s\fR
18
+ \fB\-\-source=SOURCE\fR, \fB\-s=SOURCE\fR
19
19
  Specify the source for the added gem\.
20
20
  .TP
21
- \fB\-\-require\fR, \fB\-r\fR
21
+ \fB\-\-require=REQUIRE\fR, \fB\-r=REQUIRE\fR
22
22
  Adds require path to gem\. Provide false, or a path as a string\.
23
23
  .TP
24
- \fB\-\-path\fR
24
+ \fB\-\-path=PATH\fR
25
25
  Specify the file system path for the added gem\.
26
26
  .TP
27
- \fB\-\-git\fR
27
+ \fB\-\-git=GIT\fR
28
28
  Specify the git source for the added gem\.
29
29
  .TP
30
- \fB\-\-github\fR
30
+ \fB\-\-github=GITHUB\fR
31
31
  Specify the github source for the added gem\.
32
32
  .TP
33
- \fB\-\-branch\fR
33
+ \fB\-\-branch=BRANCH\fR
34
34
  Specify the git branch for the added gem\.
35
35
  .TP
36
- \fB\-\-ref\fR
36
+ \fB\-\-ref=REF\fR
37
37
  Specify the git ref for the added gem\.
38
38
  .TP
39
+ \fB\-\-glob=GLOB\fR
40
+ Specify the location of a dependency's \.gemspec, expanded within Ruby (single quotes recommended)\.
41
+ .TP
42
+ \fB\-\-quiet\fR
43
+ Do not print progress information to the standard output\.
44
+ .TP
39
45
  \fB\-\-skip\-install\fR
40
46
  Adds the gem to the Gemfile but does not install it\.
41
47
  .TP
@@ -5,7 +5,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install
5
5
 
6
6
  `bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE]
7
7
  [--path=PATH] [--git=GIT|--github=GITHUB] [--branch=BRANCH] [--ref=REF]
8
- [--skip-install] [--strict|--optimistic]
8
+ [--quiet] [--skip-install] [--strict|--optimistic]
9
9
 
10
10
  ## DESCRIPTION
11
11
 
@@ -14,33 +14,39 @@ Adds the named gem to the [`Gemfile(5)`][Gemfile(5)] and run `bundle install`.
14
14
 
15
15
  ## OPTIONS
16
16
 
17
- * `--version`, `-v`:
17
+ * `--version=VERSION`, `-v=VERSION`:
18
18
  Specify version requirements(s) for the added gem.
19
19
 
20
- * `--group`, `-g`:
20
+ * `--group=GROUP`, `-g=GROUP`:
21
21
  Specify the group(s) for the added gem. Multiple groups should be separated by commas.
22
22
 
23
- * `--source`, `-s`:
23
+ * `--source=SOURCE`, `-s=SOURCE`:
24
24
  Specify the source for the added gem.
25
25
 
26
- * `--require`, `-r`:
26
+ * `--require=REQUIRE`, `-r=REQUIRE`:
27
27
  Adds require path to gem. Provide false, or a path as a string.
28
28
 
29
- * `--path`:
29
+ * `--path=PATH`:
30
30
  Specify the file system path for the added gem.
31
31
 
32
- * `--git`:
32
+ * `--git=GIT`:
33
33
  Specify the git source for the added gem.
34
34
 
35
- * `--github`:
35
+ * `--github=GITHUB`:
36
36
  Specify the github source for the added gem.
37
37
 
38
- * `--branch`:
38
+ * `--branch=BRANCH`:
39
39
  Specify the git branch for the added gem.
40
40
 
41
- * `--ref`:
41
+ * `--ref=REF`:
42
42
  Specify the git ref for the added gem.
43
43
 
44
+ * `--glob=GLOB`:
45
+ Specify the location of a dependency's .gemspec, expanded within Ruby (single quotes recommended).
46
+
47
+ * `--quiet`:
48
+ Do not print progress information to the standard output.
49
+
44
50
  * `--skip-install`:
45
51
  Adds the gem to the Gemfile but does not install it.
46
52
 
@@ -1,10 +1,10 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-BINSTUBS" "1" "September 2024" ""
3
+ .TH "BUNDLE\-BINSTUBS" "1" "December 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
6
6
  .SH "SYNOPSIS"
7
- \fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone]
7
+ \fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone] [\-\-all\-platforms]
8
8
  .SH "DESCRIPTION"
9
9
  Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it into \fBbin/\fR\. Binstubs are a shortcut\-or alternative\- to always using \fBbundle exec\fR\. This gives you a file that can be run directly, and one that will always run the correct gem version used by the application\.
10
10
  .P
@@ -16,15 +16,18 @@ This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are
16
16
  \fB\-\-force\fR
17
17
  Overwrite existing binstubs if they exist\.
18
18
  .TP
19
- \fB\-\-path\fR
19
+ \fB\-\-path[=PATH]\fR
20
20
  The location to install the specified binstubs to\. This defaults to \fBbin\fR\.
21
21
  .TP
22
22
  \fB\-\-standalone\fR
23
23
  Makes binstubs that can work without depending on Rubygems or Bundler at runtime\.
24
24
  .TP
25
- \fB\-\-shebang\fR
25
+ \fB\-\-shebang=SHEBANG\fR
26
26
  Specify a different shebang executable name than the default (default 'ruby')
27
27
  .TP
28
28
  \fB\-\-all\fR
29
29
  Create binstubs for all gems in the bundle\.
30
+ .TP
31
+ \fB\-\-all\-platforms\fR
32
+ Install binstubs for all platforms\.
30
33
 
@@ -3,7 +3,7 @@ bundle-binstubs(1) -- Install the binstubs of the listed gems
3
3
 
4
4
  ## SYNOPSIS
5
5
 
6
- `bundle binstubs` <GEM_NAME> [--force] [--path PATH] [--standalone]
6
+ `bundle binstubs` <GEM_NAME> [--force] [--path PATH] [--standalone] [--all-platforms]
7
7
 
8
8
  ## DESCRIPTION
9
9
 
@@ -27,15 +27,18 @@ Calling binstubs with [GEM [GEM]] will create binstubs for all given gems.
27
27
  * `--force`:
28
28
  Overwrite existing binstubs if they exist.
29
29
 
30
- * `--path`:
30
+ * `--path[=PATH]`:
31
31
  The location to install the specified binstubs to. This defaults to `bin`.
32
32
 
33
33
  * `--standalone`:
34
34
  Makes binstubs that can work without depending on Rubygems or Bundler at
35
35
  runtime.
36
36
 
37
- * `--shebang`:
37
+ * `--shebang=SHEBANG`:
38
38
  Specify a different shebang executable name than the default (default 'ruby')
39
39
 
40
40
  * `--all`:
41
41
  Create binstubs for all gems in the bundle.
42
+
43
+ * `--all-platforms`:
44
+ Install binstubs for all platforms.
@@ -1,14 +1,42 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-CACHE" "1" "September 2024" ""
3
+ .TH "BUNDLE\-CACHE" "1" "December 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
6
6
  .SH "SYNOPSIS"
7
- \fBbundle cache\fR
7
+ \fBbundle cache\fR [\fIOPTIONS\fR]
8
8
  .P
9
9
  alias: \fBpackage\fR, \fBpack\fR
10
10
  .SH "DESCRIPTION"
11
11
  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\.
12
+ .SH "OPTIONS"
13
+ .TP
14
+ \fB\-\-all\fR
15
+ Include all sources (including path and git)\.
16
+ .TP
17
+ \fB\-\-all\-platforms\fR
18
+ Include gems for all platforms present in the lockfile, not only the current one\.
19
+ .TP
20
+ \fB\-\-cache\-path=CACHE\-PATH\fR
21
+ Specify a different cache path than the default (vendor/cache)\.
22
+ .TP
23
+ \fB\-\-gemfile=GEMFILE\fR
24
+ Use the specified gemfile instead of Gemfile\.
25
+ .TP
26
+ \fB\-\-no\-install\fR
27
+ Don't install the gems, only update the cache\.
28
+ .TP
29
+ \fB\-\-no\-prune\fR
30
+ Don't remove stale gems from the cache\.
31
+ .TP
32
+ \fB\-\-path=PATH\fR
33
+ Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME)\.
34
+ .TP
35
+ \fB\-\-quiet\fR
36
+ Only output warnings and errors\.
37
+ .TP
38
+ \fB\-\-frozen\fR
39
+ Do not allow the Gemfile\.lock to be updated after this bundle cache operation's install\.
12
40
  .SH "GIT AND PATH GEMS"
13
41
  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\.
14
42
  .SH "SUPPORT FOR MULTIPLE PLATFORMS"