bundler 2.3.16 → 2.3.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/cache.rb +1 -1
  5. data/lib/bundler/cli/common.rb +1 -0
  6. data/lib/bundler/cli/install.rb +2 -0
  7. data/lib/bundler/cli.rb +6 -2
  8. data/lib/bundler/compact_index_client/updater.rb +16 -3
  9. data/lib/bundler/current_ruby.rb +1 -1
  10. data/lib/bundler/definition.rb +51 -18
  11. data/lib/bundler/dependency.rb +3 -2
  12. data/lib/bundler/dsl.rb +3 -3
  13. data/lib/bundler/friendly_errors.rb +5 -2
  14. data/lib/bundler/gem_helpers.rb +2 -0
  15. data/lib/bundler/incomplete_specification.rb +12 -0
  16. data/lib/bundler/index.rb +11 -17
  17. data/lib/bundler/installer/standalone.rb +29 -2
  18. data/lib/bundler/lazy_specification.rb +17 -8
  19. data/lib/bundler/lockfile_parser.rb +4 -0
  20. data/lib/bundler/man/bundle-add.1 +2 -2
  21. data/lib/bundler/man/bundle-add.1.ronn +1 -1
  22. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  23. data/lib/bundler/man/bundle-cache.1 +1 -1
  24. data/lib/bundler/man/bundle-check.1 +1 -1
  25. data/lib/bundler/man/bundle-clean.1 +1 -1
  26. data/lib/bundler/man/bundle-config.1 +13 -3
  27. data/lib/bundler/man/bundle-config.1.ronn +9 -2
  28. data/lib/bundler/man/bundle-doctor.1 +1 -1
  29. data/lib/bundler/man/bundle-exec.1 +2 -2
  30. data/lib/bundler/man/bundle-exec.1.ronn +1 -1
  31. data/lib/bundler/man/bundle-gem.1 +1 -1
  32. data/lib/bundler/man/bundle-info.1 +1 -1
  33. data/lib/bundler/man/bundle-init.1 +1 -1
  34. data/lib/bundler/man/bundle-inject.1 +5 -2
  35. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  36. data/lib/bundler/man/bundle-install.1 +1 -1
  37. data/lib/bundler/man/bundle-list.1 +1 -1
  38. data/lib/bundler/man/bundle-lock.1 +1 -1
  39. data/lib/bundler/man/bundle-open.1 +1 -1
  40. data/lib/bundler/man/bundle-outdated.1 +1 -1
  41. data/lib/bundler/man/bundle-platform.1 +1 -1
  42. data/lib/bundler/man/bundle-pristine.1 +1 -1
  43. data/lib/bundler/man/bundle-remove.1 +1 -1
  44. data/lib/bundler/man/bundle-show.1 +1 -1
  45. data/lib/bundler/man/bundle-update.1 +1 -1
  46. data/lib/bundler/man/bundle-viz.1 +4 -1
  47. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  48. data/lib/bundler/man/bundle.1 +3 -3
  49. data/lib/bundler/man/bundle.1.ronn +2 -2
  50. data/lib/bundler/man/gemfile.5 +77 -47
  51. data/lib/bundler/man/gemfile.5.ronn +75 -54
  52. data/lib/bundler/match_platform.rb +0 -1
  53. data/lib/bundler/remote_specification.rb +5 -4
  54. data/lib/bundler/resolver/spec_group.rb +5 -4
  55. data/lib/bundler/resolver.rb +11 -9
  56. data/lib/bundler/rubygems_ext.rb +6 -5
  57. data/lib/bundler/rubygems_gem_installer.rb +19 -12
  58. data/lib/bundler/runtime.rb +0 -1
  59. data/lib/bundler/settings.rb +1 -0
  60. data/lib/bundler/source/rubygems.rb +14 -6
  61. data/lib/bundler/spec_set.rb +31 -20
  62. data/lib/bundler/version.rb +1 -1
  63. data/lib/bundler.rb +1 -0
  64. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0194bb060d38ce7786c704aca693890461b4866ee647d6931a8e3e8f738f4ad6'
4
- data.tar.gz: d6e46c6028248ad29a24bfccd9df89facbcd57186e84be8499ec903f4989b88e
3
+ metadata.gz: 3a381dcda0446bc5d93d2a6c1b16dcb28c53b151df2a3e9a9ed656f9e35bea2e
4
+ data.tar.gz: dd05bd4717edec09127afc27ff6f62473353a17b51df25feb3a7e637e86eb6a7
5
5
  SHA512:
6
- metadata.gz: 9bbc74e0583c0117895f09cc1da2ae5dc9592b09b52f70f70c8efba2743bec7449230b9fc8d7210725c804bb761f98bd9a0ec8a8e417bfc2b0573154ffaacab7
7
- data.tar.gz: a27eea8f0ebceb3d0e9e8b413d2c50da519c36e565e08c26f0d22f6298f75515f0d11094da6c510b74805ceae2e18e25cd61eacd40e328b565878f4ad2c66a41
6
+ metadata.gz: 8dd22b1e85f5d0b785467676913165987430edced38c5683a6bc4c782180e74f383807fc784b4db8fcfbb28d0e9b685312395319776fb1db3a873420dbad17ee
7
+ data.tar.gz: dbf44b39dbafd1699ece2f9a0d656bc6a5ddd3070ca8884db61548701afa3ee57c1ef3ab639f724f721ee195e1ede80e9323c6d52fe3041457faca89aed682b0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,74 @@
1
+ # 2.3.19 (July 27, 2022)
2
+
3
+ ## Enhancements:
4
+
5
+ - Add `Bundler.settings[:only]` to install gems of the specified groups [#5759](https://github.com/rubygems/rubygems/pull/5759)
6
+ - Add `ignore_funding_requests` config flag [#5767](https://github.com/rubygems/rubygems/pull/5767)
7
+ - Prevent random crash when autoloading `Pathname` [#5769](https://github.com/rubygems/rubygems/pull/5769)
8
+ - Don't corrupt lockfile when user moves a gem that's already in the lockfile to an incorrect source by mistake [#5070](https://github.com/rubygems/rubygems/pull/5070)
9
+ - Reconcile error/warning message for multiple global sources with documentation [#5741](https://github.com/rubygems/rubygems/pull/5741)
10
+ - Improve error message when gems cannot be found to include the source for each gem [#5729](https://github.com/rubygems/rubygems/pull/5729)
11
+
12
+ ## Bug fixes:
13
+
14
+ - Fix yet another TruffleRuby platform selection regression [#5746](https://github.com/rubygems/rubygems/pull/5746)
15
+ - Show a proper error if extension dir is not writable [#5726](https://github.com/rubygems/rubygems/pull/5726)
16
+
17
+ ## Performance:
18
+
19
+ - Lazily check incomplete lockfile to improve performance [#5546](https://github.com/rubygems/rubygems/pull/5546)
20
+
21
+ ## Documentation:
22
+
23
+ - Add deprecation notice of bundle inject [#5776](https://github.com/rubygems/rubygems/pull/5776)
24
+ - Add deprecation notice of `bundle viz` to man pages [#5765](https://github.com/rubygems/rubygems/pull/5765)
25
+ - Update command example in `bundle exec` man page [#5754](https://github.com/rubygems/rubygems/pull/5754)
26
+ - Remove bundle show from obsolete commands [#5753](https://github.com/rubygems/rubygems/pull/5753)
27
+ - Improve global source(s) documentation [#5732](https://github.com/rubygems/rubygems/pull/5732)
28
+ - Use https protocol for URLs for config mirror in bundler man [#5722](https://github.com/rubygems/rubygems/pull/5722)
29
+
30
+ # 2.3.18 (July 14, 2022)
31
+
32
+ ## Enhancements:
33
+
34
+ - Extend `gem` DSL with a `force_ruby_platform` option [#4049](https://github.com/rubygems/rubygems/pull/4049)
35
+
36
+ ## Bug fixes:
37
+
38
+ - Fix misleading error if compact index cannot be copied [#5709](https://github.com/rubygems/rubygems/pull/5709)
39
+ - Fix TruffleRuby no longer able to install lockfiles generated with other implementations [#5711](https://github.com/rubygems/rubygems/pull/5711)
40
+ - Fix TruffleRuby no longer installing lockfiles using "ruby" platform correctly [#5694](https://github.com/rubygems/rubygems/pull/5694)
41
+ - Fix crash when updating vendor cache of default gems [#5679](https://github.com/rubygems/rubygems/pull/5679)
42
+
43
+ ## Performance:
44
+
45
+ - Speed up `bundler/setup` by using the raw `Gemfile.lock` information without extra processing whenever possible [#5695](https://github.com/rubygems/rubygems/pull/5695)
46
+
47
+ ## Documentation:
48
+
49
+ - Use modern style hashes in Gemfile DSL docs [#5674](https://github.com/rubygems/rubygems/pull/5674)
50
+
51
+ # 2.3.17 (June 29, 2022)
52
+
53
+ ## Enhancements:
54
+
55
+ - Add support for platform `:x64_mingw` to correctly lookup "x64-mingw-ucrt" [#5649](https://github.com/rubygems/rubygems/pull/5649)
56
+ - Fix some errors being printed twice in `--verbose` mode [#5654](https://github.com/rubygems/rubygems/pull/5654)
57
+ - Fix extension paths in generated standalone script [#5632](https://github.com/rubygems/rubygems/pull/5632)
58
+
59
+ ## Bug fixes:
60
+
61
+ - Raise if ruby platform is forced and there are no ruby variants [#5495](https://github.com/rubygems/rubygems/pull/5495)
62
+ - Fix `bundle package --no-install` no longer skipping install [#5639](https://github.com/rubygems/rubygems/pull/5639)
63
+
64
+ ## Performance:
65
+
66
+ - Improve performance of `Bundler::SpecSet#for` by using hash lookup of handled deps [#5537](https://github.com/rubygems/rubygems/pull/5537)
67
+
68
+ ## Documentation:
69
+
70
+ - Fix formatting issue in `bundle add` man page [#5642](https://github.com/rubygems/rubygems/pull/5642)
71
+
1
72
  # 2.3.16 (June 15, 2022)
2
73
 
3
74
  ## Performance:
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2022-06-15".freeze
8
- @git_commit_sha = "324ee6e542".freeze
7
+ @built_at = "2022-07-27".freeze
8
+ @git_commit_sha = "4f496f93e6".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -14,7 +14,7 @@ module Bundler
14
14
  Bundler.settings.set_command_option_if_given :cache_path, options["cache-path"]
15
15
 
16
16
  setup_cache_all
17
- install unless Bundler.settings[:no_install]
17
+ install
18
18
 
19
19
  # TODO: move cache contents here now that all bundles are locked
20
20
  custom_path = Bundler.settings[:path] if options[:path]
@@ -15,6 +15,7 @@ module Bundler
15
15
  end
16
16
 
17
17
  def self.output_fund_metadata_summary
18
+ return if Bundler.settings["ignore_funding_requests"]
18
19
  definition = Bundler.definition
19
20
  current_dependencies = definition.requested_dependencies
20
21
  current_specs = definition.specs
@@ -161,6 +161,8 @@ module Bundler
161
161
 
162
162
  Bundler.settings.set_command_option_if_given :no_prune, options["no-prune"]
163
163
 
164
+ Bundler.settings.set_command_option_if_given :no_install, options["no-install"]
165
+
164
166
  Bundler.settings.set_command_option_if_given :clean, options["clean"]
165
167
 
166
168
  normalize_groups if options[:without] || options[:with]
data/lib/bundler/cli.rb CHANGED
@@ -251,7 +251,9 @@ module Bundler
251
251
  remembered_negative_flag_deprecation("no-deployment")
252
252
 
253
253
  require_relative "cli/install"
254
- Install.new(options.dup).run
254
+ Bundler.settings.temporary(:no_install => false) do
255
+ Install.new(options.dup).run
256
+ end
255
257
  end
256
258
 
257
259
  map aliases_for("install")
@@ -297,7 +299,9 @@ module Bundler
297
299
  def update(*gems)
298
300
  SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
299
301
  require_relative "cli/update"
300
- Update.new(options, gems).run
302
+ Bundler.settings.temporary(:no_install => false) do
303
+ Update.new(options, gems).run
304
+ end
301
305
  end
302
306
 
303
307
  desc "show GEM [OPTIONS]", "Shows all gems that are part of the bundle, or the path to a given gem"
@@ -31,9 +31,8 @@ module Bundler
31
31
 
32
32
  # first try to fetch any new bytes on the existing file
33
33
  if retrying.nil? && local_path.file?
34
- SharedHelpers.filesystem_access(local_temp_path) do
35
- FileUtils.cp local_path, local_temp_path
36
- end
34
+ copy_file local_path, local_temp_path
35
+
37
36
  headers["If-None-Match"] = etag_for(local_temp_path)
38
37
  headers["Range"] =
39
38
  if local_temp_path.size.nonzero?
@@ -98,6 +97,20 @@ module Bundler
98
97
  SharedHelpers.digest(:MD5).hexdigest(File.read(path))
99
98
  end
100
99
  end
100
+
101
+ private
102
+
103
+ def copy_file(source, dest)
104
+ SharedHelpers.filesystem_access(source, :read) do
105
+ File.open(source, "r") do |s|
106
+ SharedHelpers.filesystem_access(dest, :write) do
107
+ File.open(dest, "wb", s.stat.mode) do |f|
108
+ IO.copy_stream(s, f)
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
101
114
  end
102
115
  end
103
116
  end
@@ -78,7 +78,7 @@ module Bundler
78
78
  end
79
79
 
80
80
  def x64_mingw?
81
- Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu == "x64"
81
+ Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64"
82
82
  end
83
83
 
84
84
  (KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
@@ -138,13 +138,13 @@ module Bundler
138
138
  @unlock[:gems] ||= @dependencies.map(&:name)
139
139
  else
140
140
  eager_unlock = expand_dependencies(@unlock[:gems] || [], true)
141
- @unlock[:gems] = @locked_specs.for(eager_unlock, false, false).map(&:name)
141
+ @unlock[:gems] = @locked_specs.for(eager_unlock, false, platforms).map(&:name)
142
142
  end
143
143
 
144
144
  @dependency_changes = converge_dependencies
145
145
  @local_changes = converge_locals
146
146
 
147
- @locked_specs_incomplete_for_platform = !@locked_specs.for(requested_dependencies & expand_dependencies(locked_dependencies), true, true)
147
+ @reresolve = nil
148
148
 
149
149
  @requires = compute_requires
150
150
  end
@@ -235,6 +235,14 @@ module Bundler
235
235
  @locked_deps.values
236
236
  end
237
237
 
238
+ def new_deps
239
+ @new_deps ||= @dependencies - locked_dependencies
240
+ end
241
+
242
+ def deleted_deps
243
+ @deleted_deps ||= locked_dependencies - @dependencies
244
+ end
245
+
238
246
  def specs_for(groups)
239
247
  return specs if groups.empty?
240
248
  deps = dependencies_for(groups)
@@ -259,14 +267,20 @@ module Bundler
259
267
  Bundler.ui.debug "Frozen, using resolution from the lockfile"
260
268
  @locked_specs
261
269
  elsif !unlocking? && nothing_changed?
262
- Bundler.ui.debug("Found no changes, using resolution from the lockfile")
263
- SpecSet.new(filter_specs(@locked_specs, @dependencies.select {|dep| @locked_specs[dep].any? }))
270
+ if deleted_deps.any?
271
+ Bundler.ui.debug("Some dependencies were deleted, using a subset of the resolution from the lockfile")
272
+ SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
273
+ else
274
+ Bundler.ui.debug("Found no changes, using resolution from the lockfile")
275
+ if @locked_gems.may_include_redundant_platform_specific_gems?
276
+ SpecSet.new(filter_specs(@locked_specs, @dependencies))
277
+ else
278
+ @locked_specs
279
+ end
280
+ end
264
281
  else
265
- last_resolve = converge_locked_specs
266
- # Run a resolve against the locally available gems
267
282
  Bundler.ui.debug("Found changes from the lockfile, re-resolving dependencies because #{change_reason}")
268
- expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
269
- Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
283
+ @reresolve = reresolve
270
284
  end
271
285
  end
272
286
 
@@ -359,9 +373,6 @@ module Bundler
359
373
  added.concat new_platforms.map {|p| "* platform: #{p}" }
360
374
  deleted.concat deleted_platforms.map {|p| "* platform: #{p}" }
361
375
 
362
- new_deps = @dependencies - locked_dependencies
363
- deleted_deps = locked_dependencies - @dependencies
364
-
365
376
  added.concat new_deps.map {|d| "* #{pretty_dep(d)}" } if new_deps.any?
366
377
  deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
367
378
 
@@ -454,7 +465,7 @@ module Bundler
454
465
  private :sources
455
466
 
456
467
  def nothing_changed?
457
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@locked_specs_incomplete_for_platform
468
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
458
469
  end
459
470
 
460
471
  def unlocking?
@@ -463,8 +474,14 @@ module Bundler
463
474
 
464
475
  private
465
476
 
477
+ def reresolve
478
+ last_resolve = converge_locked_specs
479
+ expanded_dependencies = expand_dependencies(dependencies + metadata_dependencies, true)
480
+ Resolver.resolve(expanded_dependencies, source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve, platforms)
481
+ end
482
+
466
483
  def filter_specs(specs, deps)
467
- SpecSet.new(specs).for(expand_dependencies(deps, true), false, false)
484
+ SpecSet.new(specs).for(expand_dependencies(deps, true), false, platforms)
468
485
  end
469
486
 
470
487
  def materialize(dependencies)
@@ -481,7 +498,22 @@ module Bundler
481
498
  "removed in order to install."
482
499
  end
483
500
 
484
- raise GemNotFound, "Could not find #{missing_specs.map(&:full_name).join(", ")} in any of the sources"
501
+ missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source|
502
+ "#{missing_specs_for_source.map(&:full_name).join(", ")} in #{source}"
503
+ end
504
+
505
+ raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}"
506
+ end
507
+
508
+ if @reresolve.nil?
509
+ incomplete_specs = specs.incomplete_specs
510
+
511
+ if incomplete_specs.any?
512
+ Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
513
+ @unlock[:gems].concat(incomplete_specs.map(&:name))
514
+ @resolve = reresolve
515
+ specs = resolve.materialize(dependencies)
516
+ end
485
517
  end
486
518
 
487
519
  unless specs["bundler"].any?
@@ -531,7 +563,6 @@ module Bundler
531
563
  [@new_platform, "you added a new platform to your gemfile"],
532
564
  [@path_changes, "the gemspecs for path gems changed"],
533
565
  [@local_changes, "the gemspecs for git local gems changed"],
534
- [@locked_specs_incomplete_for_platform, "the lockfile does not have all gems needed for the current platform"],
535
566
  ].select(&:first).map(&:last).join(", ")
536
567
  end
537
568
 
@@ -707,7 +738,7 @@ module Bundler
707
738
  # if we won't need the source (according to the lockfile),
708
739
  # don't error if the path/git source isn't available
709
740
  next if specs.
710
- for(requested_dependencies, false, true).
741
+ for(requested_dependencies, false).
711
742
  none? {|locked_spec| locked_spec.source == s.source }
712
743
 
713
744
  raise
@@ -775,7 +806,9 @@ module Bundler
775
806
  end
776
807
 
777
808
  def requested_groups
778
- groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
809
+ values = groups - Bundler.settings[:without] - @optional_groups + Bundler.settings[:with]
810
+ values &= Bundler.settings[:only] unless Bundler.settings[:only].empty?
811
+ values
779
812
  end
780
813
 
781
814
  def lockfiles_equal?(current, proposed, preserve_unknown_sections)
@@ -806,7 +839,7 @@ module Bundler
806
839
  return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
807
840
  converge_specs(@originally_locked_specs).map do |locked_spec|
808
841
  name = locked_spec.name
809
- dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
842
+ dep = Dependency.new(name, ">= #{locked_spec.version}")
810
843
  DepProxy.get_proxy(dep, locked_spec.platform)
811
844
  end
812
845
  end
@@ -7,7 +7,7 @@ require_relative "rubygems_ext"
7
7
  module Bundler
8
8
  class Dependency < Gem::Dependency
9
9
  attr_reader :autorequire
10
- attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref
10
+ attr_reader :groups, :platforms, :gemfile, :git, :github, :branch, :ref, :force_ruby_platform
11
11
 
12
12
  # rubocop:disable Naming/VariableNumber
13
13
  PLATFORM_MAP = {
@@ -109,6 +109,7 @@ module Bundler
109
109
  @env = options["env"]
110
110
  @should_include = options.fetch("should_include", true)
111
111
  @gemfile = options["gemfile"]
112
+ @force_ruby_platform = options["force_ruby_platform"]
112
113
 
113
114
  @autorequire = Array(options["require"] || []) if options.key?("require")
114
115
  end
@@ -122,7 +123,7 @@ module Bundler
122
123
  end
123
124
 
124
125
  def expanded_platforms
125
- @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.uniq
126
+ @expanded_platforms ||= @platforms.map {|pl| PLATFORM_MAP[pl] }.compact.flatten.uniq
126
127
  end
127
128
 
128
129
  def should_include?
data/lib/bundler/dsl.rb CHANGED
@@ -16,7 +16,7 @@ module Bundler
16
16
  VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
17
17
 
18
18
  VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
19
- platform platforms type source install_if gemfile].freeze
19
+ platform platforms type source install_if gemfile force_ruby_platform].freeze
20
20
 
21
21
  GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
22
22
 
@@ -465,12 +465,12 @@ module Bundler
465
465
 
466
466
  def multiple_global_source_warning
467
467
  if Bundler.feature_flag.bundler_3_mode?
468
- msg = "This Gemfile contains multiple primary sources. " \
468
+ msg = "This Gemfile contains multiple global sources. " \
469
469
  "Each source after the first must include a block to indicate which gems " \
470
470
  "should come from that source"
471
471
  raise GemfileEvalError, msg
472
472
  else
473
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \
473
+ Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
474
474
  "Using `source` more than once without a block is a security risk, and " \
475
475
  "may result in installing unexpected gems. To resolve this warning, use " \
476
476
  "a block to indicate which gems should come from the secondary source."
@@ -29,8 +29,11 @@ module Bundler
29
29
  Bundler.ui.error error.message
30
30
  Bundler.ui.trace error.orig_exception
31
31
  when BundlerError
32
- Bundler.ui.error error.message, :wrap => true
33
- Bundler.ui.trace error
32
+ if Bundler.ui.debug?
33
+ Bundler.ui.trace error
34
+ else
35
+ Bundler.ui.error error.message, :wrap => true
36
+ end
34
37
  when Thor::Error
35
38
  Bundler.ui.error error.message
36
39
  when LoadError
@@ -5,11 +5,13 @@ module Bundler
5
5
  GENERIC_CACHE = { Gem::Platform::RUBY => Gem::Platform::RUBY } # rubocop:disable Style/MutableConstant
6
6
  GENERICS = [
7
7
  [Gem::Platform.new("java"), Gem::Platform.new("java")],
8
+ [Gem::Platform.new("universal-java"), Gem::Platform.new("java")],
8
9
  [Gem::Platform.new("mswin32"), Gem::Platform.new("mswin32")],
9
10
  [Gem::Platform.new("mswin64"), Gem::Platform.new("mswin64")],
10
11
  [Gem::Platform.new("universal-mingw32"), Gem::Platform.new("universal-mingw32")],
11
12
  [Gem::Platform.new("x64-mingw32"), Gem::Platform.new("x64-mingw32")],
12
13
  [Gem::Platform.new("x86_64-mingw32"), Gem::Platform.new("x64-mingw32")],
14
+ [Gem::Platform.new("x64-mingw-ucrt"), Gem::Platform.new("x64-mingw-ucrt")],
13
15
  [Gem::Platform.new("mingw32"), Gem::Platform.new("x86-mingw32")],
14
16
  ].freeze
15
17
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class IncompleteSpecification
5
+ attr_reader :name, :platform
6
+
7
+ def initialize(name, platform)
8
+ @name = name
9
+ @platform = platform
10
+ end
11
+ end
12
+ end
data/lib/bundler/index.rb CHANGED
@@ -56,17 +56,17 @@ module Bundler
56
56
 
57
57
  # Search this index's specs, and any source indexes that this index knows
58
58
  # about, returning all of the results.
59
- def search(query, base = nil)
60
- sort_specs(unsorted_search(query, base))
59
+ def search(query)
60
+ sort_specs(unsorted_search(query))
61
61
  end
62
62
 
63
- def unsorted_search(query, base)
64
- results = local_search(query, base)
63
+ def unsorted_search(query)
64
+ results = local_search(query)
65
65
 
66
66
  seen = results.map(&:full_name).uniq unless @sources.empty?
67
67
 
68
68
  @sources.each do |source|
69
- source.unsorted_search(query, base).each do |spec|
69
+ source.unsorted_search(query).each do |spec|
70
70
  next if seen.include?(spec.full_name)
71
71
 
72
72
  seen << spec.full_name
@@ -89,12 +89,12 @@ module Bundler
89
89
  self.class.sort_specs(specs)
90
90
  end
91
91
 
92
- def local_search(query, base = nil)
92
+ def local_search(query)
93
93
  case query
94
94
  when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
95
95
  when String then specs_by_name(query)
96
- when Gem::Dependency then search_by_dependency(query, base)
97
- when DepProxy then search_by_dependency(query.dep, base)
96
+ when Gem::Dependency then search_by_dependency(query)
97
+ when DepProxy then search_by_dependency(query.dep)
98
98
  else
99
99
  raise "You can't search for a #{query.inspect}."
100
100
  end
@@ -185,18 +185,12 @@ module Bundler
185
185
  @specs[name].values
186
186
  end
187
187
 
188
- def search_by_dependency(dependency, base = nil)
189
- @cache[base || false] ||= {}
190
- @cache[base || false][dependency] ||= begin
188
+ def search_by_dependency(dependency)
189
+ @cache[dependency] ||= begin
191
190
  specs = specs_by_name(dependency.name)
192
- specs += base if base
193
191
  found = specs.select do |spec|
194
192
  next true if spec.source.is_a?(Source::Gemspec)
195
- if base # allow all platforms when searching from a lockfile
196
- dependency.matches_spec?(spec)
197
- else
198
- dependency.matches_spec?(spec) && Gem::Platform.match_spec?(spec)
199
- end
193
+ dependency.matches_spec?(spec)
200
194
  end
201
195
 
202
196
  found
@@ -12,6 +12,7 @@ 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 define_path_helpers
15
16
  file.puts reverse_rubygems_kernel_mixin
16
17
  paths.each do |path|
17
18
  if Pathname.new(path).absolute?
@@ -29,14 +30,20 @@ module Bundler
29
30
  @specs.map do |spec|
30
31
  next if spec.name == "bundler"
31
32
  Array(spec.require_paths).map do |path|
32
- gem_path(path, spec).sub(version_dir, '#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}')
33
+ gem_path(path, spec).
34
+ sub(version_dir, '#{RUBY_ENGINE}/#{Gem.ruby_api_version}').
35
+ sub(extensions_dir, 'extensions/\k<platform>/#{Gem.extension_api_version}')
33
36
  # This is a static string intentionally. It's interpolated at a later time.
34
37
  end
35
38
  end.flatten.compact
36
39
  end
37
40
 
38
41
  def version_dir
39
- "#{RUBY_ENGINE}/#{RbConfig::CONFIG["ruby_version"]}"
42
+ "#{RUBY_ENGINE}/#{Gem.ruby_api_version}"
43
+ end
44
+
45
+ def extensions_dir
46
+ %r{extensions/(?<platform>[^/]+)/#{Regexp.escape(Gem.extension_api_version)}}
40
47
  end
41
48
 
42
49
  def bundler_path
@@ -55,6 +62,26 @@ module Bundler
55
62
  raise Gem::InvalidSpecificationException.new(error_message)
56
63
  end
57
64
 
65
+ def define_path_helpers
66
+ <<~'END'
67
+ unless defined?(Gem)
68
+ module Gem
69
+ def self.ruby_api_version
70
+ RbConfig::CONFIG["ruby_version"]
71
+ end
72
+
73
+ def self.extension_api_version
74
+ if 'no' == RbConfig::CONFIG['ENABLE_SHARED']
75
+ "#{ruby_api_version}-static"
76
+ else
77
+ ruby_api_version
78
+ end
79
+ end
80
+ end
81
+ end
82
+ END
83
+ end
84
+
58
85
  def reverse_rubygems_kernel_mixin
59
86
  <<~END
60
87
  kernel = (class << ::Kernel; self; end)
@@ -7,7 +7,7 @@ module Bundler
7
7
  include MatchPlatform
8
8
 
9
9
  attr_reader :name, :version, :dependencies, :platform
10
- attr_accessor :source, :remote
10
+ attr_accessor :source, :remote, :force_ruby_platform
11
11
 
12
12
  def initialize(name, version, platform, source = nil)
13
13
  @name = name
@@ -19,7 +19,7 @@ module Bundler
19
19
  end
20
20
 
21
21
  def full_name
22
- if platform == Gem::Platform::RUBY || platform.nil?
22
+ if platform == Gem::Platform::RUBY
23
23
  "#{@name}-#{@version}"
24
24
  else
25
25
  "#{@name}-#{@version}-#{platform}"
@@ -61,7 +61,7 @@ module Bundler
61
61
  def to_lock
62
62
  out = String.new
63
63
 
64
- if platform == Gem::Platform::RUBY || platform.nil?
64
+ if platform == Gem::Platform::RUBY
65
65
  out << " #{name} (#{version})\n"
66
66
  else
67
67
  out << " #{name} (#{version}-#{platform})\n"
@@ -75,7 +75,17 @@ module Bundler
75
75
  out
76
76
  end
77
77
 
78
- def __materialize__
78
+ def materialize_for_installation
79
+ __materialize__(ruby_platform_materializes_to_ruby_platform? ? platform : Bundler.local_platform)
80
+ end
81
+
82
+ def materialize_for_resolution
83
+ return self unless Gem::Platform.match_spec?(self)
84
+
85
+ __materialize__(platform)
86
+ end
87
+
88
+ def __materialize__(platform)
79
89
  @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
80
90
  source.gemspec.tap {|s| s.source = source }
81
91
  else
@@ -84,10 +94,9 @@ module Bundler
84
94
  else
85
95
  ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
86
96
  end
87
- platform_object = Gem::Platform.new(platform)
88
97
  candidates = source.specs.search(search_object)
89
98
  same_platform_candidates = candidates.select do |spec|
90
- MatchPlatform.platforms_match?(spec.platform, platform_object)
99
+ MatchPlatform.platforms_match?(spec.platform, platform)
91
100
  end
92
101
  installable_candidates = same_platform_candidates.select do |spec|
93
102
  spec.is_a?(StubSpecification) ||
@@ -105,7 +114,7 @@ module Bundler
105
114
  end
106
115
 
107
116
  def to_s
108
- @__to_s ||= if platform == Gem::Platform::RUBY || platform.nil?
117
+ @__to_s ||= if platform == Gem::Platform::RUBY
109
118
  "#{name} (#{version})"
110
119
  else
111
120
  "#{name} (#{version}-#{platform})"
@@ -152,7 +161,7 @@ module Bundler
152
161
  # explicitly add a more specific platform.
153
162
  #
154
163
  def ruby_platform_materializes_to_ruby_platform?
155
- !Bundler.most_specific_locked_platform?(Gem::Platform::RUBY) || Bundler.settings[:force_ruby_platform]
164
+ !Bundler.most_specific_locked_platform?(generic_local_platform) || force_ruby_platform || Bundler.settings[:force_ruby_platform]
156
165
  end
157
166
  end
158
167
  end
@@ -93,6 +93,10 @@ module Bundler
93
93
  "and then `bundle install` to generate a new lockfile."
94
94
  end
95
95
 
96
+ def may_include_redundant_platform_specific_gems?
97
+ bundler_version.nil? || bundler_version < Gem::Version.new("1.16.2")
98
+ end
99
+
96
100
  private
97
101
 
98
102
  TYPES = {
@@ -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" "May 2022" "" ""
4
+ .TH "BUNDLE\-ADD" "1" "July 2022" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
@@ -41,7 +41,7 @@ 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