bundler 2.4.20 → 2.4.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -3
  3. data/lib/bundler/build_metadata.rb +3 -3
  4. data/lib/bundler/cli/check.rb +1 -1
  5. data/lib/bundler/cli/gem.rb +1 -3
  6. data/lib/bundler/cli/install.rb +2 -2
  7. data/lib/bundler/cli/lock.rb +26 -23
  8. data/lib/bundler/cli/open.rb +5 -7
  9. data/lib/bundler/definition.rb +42 -25
  10. data/lib/bundler/env.rb +2 -2
  11. data/lib/bundler/gem_version_promoter.rb +2 -2
  12. data/lib/bundler/injector.rb +1 -1
  13. data/lib/bundler/installer/parallel_installer.rb +0 -26
  14. data/lib/bundler/installer/standalone.rb +13 -6
  15. data/lib/bundler/lockfile_parser.rb +29 -24
  16. data/lib/bundler/man/bundle-add.1 +1 -1
  17. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  18. data/lib/bundler/man/bundle-cache.1 +1 -1
  19. data/lib/bundler/man/bundle-check.1 +1 -1
  20. data/lib/bundler/man/bundle-clean.1 +1 -1
  21. data/lib/bundler/man/bundle-config.1 +1 -1
  22. data/lib/bundler/man/bundle-console.1 +1 -1
  23. data/lib/bundler/man/bundle-doctor.1 +1 -1
  24. data/lib/bundler/man/bundle-exec.1 +2 -2
  25. data/lib/bundler/man/bundle-exec.1.ronn +2 -3
  26. data/lib/bundler/man/bundle-gem.1 +1 -1
  27. data/lib/bundler/man/bundle-help.1 +1 -1
  28. data/lib/bundler/man/bundle-info.1 +1 -1
  29. data/lib/bundler/man/bundle-init.1 +1 -1
  30. data/lib/bundler/man/bundle-inject.1 +1 -1
  31. data/lib/bundler/man/bundle-install.1 +1 -1
  32. data/lib/bundler/man/bundle-list.1 +1 -1
  33. data/lib/bundler/man/bundle-lock.1 +1 -1
  34. data/lib/bundler/man/bundle-open.1 +1 -1
  35. data/lib/bundler/man/bundle-outdated.1 +1 -1
  36. data/lib/bundler/man/bundle-platform.1 +1 -1
  37. data/lib/bundler/man/bundle-plugin.1 +17 -17
  38. data/lib/bundler/man/bundle-plugin.1.ronn +5 -5
  39. data/lib/bundler/man/bundle-pristine.1 +1 -1
  40. data/lib/bundler/man/bundle-remove.1 +1 -1
  41. data/lib/bundler/man/bundle-show.1 +1 -1
  42. data/lib/bundler/man/bundle-update.1 +1 -1
  43. data/lib/bundler/man/bundle-version.1 +1 -1
  44. data/lib/bundler/man/bundle-viz.1 +1 -1
  45. data/lib/bundler/man/bundle.1 +1 -1
  46. data/lib/bundler/man/gemfile.5 +1 -1
  47. data/lib/bundler/resolver/package.rb +5 -0
  48. data/lib/bundler/resolver.rb +27 -7
  49. data/lib/bundler/ruby_version.rb +8 -1
  50. data/lib/bundler/settings.rb +53 -16
  51. data/lib/bundler/shared_helpers.rb +16 -1
  52. data/lib/bundler/source/git/git_proxy.rb +13 -4
  53. data/lib/bundler/spec_set.rb +2 -2
  54. data/lib/bundler/stub_specification.rb +4 -2
  55. data/lib/bundler/templates/newgem/Rakefile.tt +6 -2
  56. data/lib/bundler/version.rb +1 -1
  57. data/lib/bundler/yaml_serializer.rb +6 -7
  58. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6276990d50143a594e7e8625034add1d1168df511587dd82c74f7b93a7e66bdc
4
- data.tar.gz: cca71ac6a7840814e8a7178ca795ed379684658b25c320e8bb67f2c022d3f2e8
3
+ metadata.gz: ce1668ecfd79ea439de5e81a89f9b06eed35f3b7d7309638071cb3b34f990d8c
4
+ data.tar.gz: 24ef07902dda9ac445473bbe06f89fc5fcee012660198060978bc651bfd081bc
5
5
  SHA512:
6
- metadata.gz: 5162fc140937170d6c3a58e7f9097cbffbcda5fa8edc96a22a14fa5c1ed548cebb8d45fc9ae9901078f4dd1ff99e6f9892f832c2b6a1f598cd34f5163e80b282
7
- data.tar.gz: 0aea59def565fa9dc8172659891fe2e6ce7b20a033f5197e1679536c91d1102a170a3784d7a05da0255662d6d342b2d1972a437fcad919756f50321b0a6801df
6
+ metadata.gz: 14bca6c7a079404d2cb21e0f26a96277cc34df150e9c5b1696ffe819af944d1b1a079bd5a01292a9b0e0a35f0eb45be89298ccf2f18532acfba88adb80f413f6
7
+ data.tar.gz: 3fc94ae1c36cec40fe55422e81db35d9b95e0bfcb103e8960bb80b38ad4aad569d8c626892ce62f8747491c68b560bc2bda851259f55a1293069bd888380376c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,35 @@
1
+ # 2.4.21 (October 17, 2023)
2
+
3
+ ## Enhancements:
4
+
5
+ - Avoid duplicates -rbundler/setup in RUBYOPT with Ruby preview [#7002](https://github.com/rubygems/rubygems/pull/7002)
6
+ - Prevent gem activation in standalone mode [#6925](https://github.com/rubygems/rubygems/pull/6925)
7
+ - Support Ruby's preview version format (Ex: 3.3.0-preview2) in Gemfile [#7016](https://github.com/rubygems/rubygems/pull/7016)
8
+ - Fix `bundle install` when older revisions of git source [#6980](https://github.com/rubygems/rubygems/pull/6980)
9
+ - Remove usage of Dir.chdir that only execute a subprocess [#6930](https://github.com/rubygems/rubygems/pull/6930)
10
+
11
+ ## Bug fixes:
12
+
13
+ - Don't delete the release version from pre-release string more than once [#7054](https://github.com/rubygems/rubygems/pull/7054)
14
+ - Make the `lock` command not be affected by the `frozen` setting [#7034](https://github.com/rubygems/rubygems/pull/7034)
15
+ - Raise an error when adding a gem incompatible with some locked platform [#7035](https://github.com/rubygems/rubygems/pull/7035)
16
+ - Re-resolve when lockfile is invalid [#7020](https://github.com/rubygems/rubygems/pull/7020)
17
+ - Don't re-resolve with prereleases if unlocked gem has no prereleases [#7021](https://github.com/rubygems/rubygems/pull/7021)
18
+ - Include gemspec in ExtensionTask for native gem tasks [#7015](https://github.com/rubygems/rubygems/pull/7015)
19
+ - Avoid error reporting relative path when validating frozen [#5128](https://github.com/rubygems/rubygems/pull/5128)
20
+ - Fix `bundle lock --minor --update <dep>` edge case [#6992](https://github.com/rubygems/rubygems/pull/6992)
21
+ - Stop bundler eagerly loading all specs with exts [#6945](https://github.com/rubygems/rubygems/pull/6945)
22
+
23
+ ## Performance:
24
+
25
+ - Reduce allocations when parsing lockfile [#6976](https://github.com/rubygems/rubygems/pull/6976)
26
+ - Stop allocating the same settings keys repeatedly [#6963](https://github.com/rubygems/rubygems/pull/6963)
27
+
28
+ ## Documentation:
29
+
30
+ - Improve formatting and global source information in `bundle plugin` man page [#7045](https://github.com/rubygems/rubygems/pull/7045)
31
+ - Update man page of `bundle exec` to reflect default true of flag `--keep-file-descriptors` [#7033](https://github.com/rubygems/rubygems/pull/7033)
32
+
1
33
  # 2.4.20 (September 27, 2023)
2
34
 
3
35
  ## Enhancements:
@@ -21,7 +53,6 @@
21
53
 
22
54
  - Lazily construct fetcher debug messages [#6973](https://github.com/rubygems/rubygems/pull/6973)
23
55
  - Avoid allocating empty hashes in Index [#6962](https://github.com/rubygems/rubygems/pull/6962)
24
- - Stop allocating the same settings keys repeatedly [#6963](https://github.com/rubygems/rubygems/pull/6963)
25
56
  - Improve `Bundler::Index` efficiency by removing unnecessary creation and dups [#6931](https://github.com/rubygems/rubygems/pull/6931)
26
57
  - (Further) Improve Bundler::Settings#[] performance and memory usage [#6923](https://github.com/rubygems/rubygems/pull/6923)
27
58
  - Don't use full indexes unnecessarily on legacy Gemfiles [#6916](https://github.com/rubygems/rubygems/pull/6916)
@@ -2182,7 +2213,7 @@ Changes
2182
2213
 
2183
2214
  - retry gem downloads ([#4846](https://github.com/rubygems/bundler/issues/4846), @jkeiser)
2184
2215
  - improve the CompactIndex to handle capitalized legacy gems ([#4867](https://github.com/rubygems/bundler/issues/4867), @segiddins)
2185
- - re-use persistent HTTP connections for CompactIndex (@NickLaMuro)
2216
+ - reuse persistent HTTP connections for CompactIndex (@NickLaMuro)
2186
2217
  - respect `required_ruby_version` when Gemfile contains `ruby` version (@indirect)
2187
2218
  - allow `rake release` to sign git tags ([#4743](https://github.com/rubygems/bundler/issues/4743), @eagletmt)
2188
2219
  - set process titles when using `#load` during `exec` (@yob)
@@ -3378,7 +3409,7 @@ Changes
3378
3409
  - `gem` option --test can generate rspec stubs (@MafcoCinco)
3379
3410
  - `gem` option --test can generate minitest stubs (@kcurtin)
3380
3411
  - `gem` command generates MIT license (@BrentWheeldon)
3381
- - gem rake task 'release' resuses existing tags (@shtirlic)
3412
+ - gem rake task 'release' reuses existing tags (@shtirlic)
3382
3413
 
3383
3414
  ## Bug fixes:
3384
3415
 
@@ -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 = "2023-09-27".freeze
8
- @git_commit_sha = "de20c7e7b".freeze
7
+ @built_at = "2023-10-17".freeze
8
+ @git_commit_sha = "d10b46bd15".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -31,7 +31,7 @@ module Bundler
31
31
  # commit instance variable then we can't determine its commits SHA.
32
32
  git_dir = File.expand_path("../../../.git", __dir__)
33
33
  if File.directory?(git_dir)
34
- return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
34
+ return @git_commit_sha = IO.popen(%w[git rev-parse --short HEAD], { :chdir => git_dir }, &:read).strip.freeze
35
35
  end
36
36
 
37
37
  @git_commit_sha ||= "unknown"
@@ -29,7 +29,7 @@ module Bundler
29
29
  Bundler.ui.warn "Install missing gems with `bundle install`"
30
30
  exit 1
31
31
  elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle?
32
- Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
32
+ Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present"
33
33
  exit 1
34
34
  else
35
35
  Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
@@ -233,9 +233,7 @@ module Bundler
233
233
  end
234
234
 
235
235
  if use_git
236
- Dir.chdir(target) do
237
- `git add .`
238
- end
236
+ IO.popen(%w[git add .], { :chdir => target }, &:read)
239
237
  end
240
238
 
241
239
  # Open gemspec in editor
@@ -28,8 +28,8 @@ module Bundler
28
28
  flag = "--deployment flag" if options[:deployment]
29
29
  flag ||= "--frozen flag" if options[:frozen]
30
30
  flag ||= "deployment setting"
31
- raise ProductionError, "The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \
32
- "sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control " \
31
+ raise ProductionError, "The #{flag} requires a lockfile. Please make " \
32
+ "sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
33
33
  "before deploying."
34
34
  end
35
35
 
@@ -32,36 +32,39 @@ module Bundler
32
32
  elsif update && bundler
33
33
  update = { :bundler => bundler }
34
34
  end
35
- definition = Bundler.definition(update)
36
35
 
37
- Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
36
+ Bundler.settings.temporary(:frozen => false) do
37
+ definition = Bundler.definition(update)
38
38
 
39
- options["remove-platform"].each do |platform|
40
- definition.remove_platform(platform)
41
- end
39
+ Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
42
40
 
43
- options["add-platform"].each do |platform_string|
44
- platform = Gem::Platform.new(platform_string)
45
- if platform.to_s == "unknown"
46
- Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
47
- "and adding it will likely lead to resolution errors"
41
+ options["remove-platform"].each do |platform|
42
+ definition.remove_platform(platform)
48
43
  end
49
- definition.add_platform(platform)
50
- end
51
44
 
52
- if definition.platforms.empty?
53
- raise InvalidOption, "Removing all platforms from the bundle is not allowed"
54
- end
45
+ options["add-platform"].each do |platform_string|
46
+ platform = Gem::Platform.new(platform_string)
47
+ if platform.to_s == "unknown"
48
+ Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
49
+ "and adding it will likely lead to resolution errors"
50
+ end
51
+ definition.add_platform(platform)
52
+ end
55
53
 
56
- definition.resolve_remotely! unless options[:local]
54
+ if definition.platforms.empty?
55
+ raise InvalidOption, "Removing all platforms from the bundle is not allowed"
56
+ end
57
+
58
+ definition.resolve_remotely! unless options[:local]
57
59
 
58
- if print
59
- puts definition.to_lock
60
- else
61
- file = options[:lockfile]
62
- file = file ? File.expand_path(file) : Bundler.default_lockfile
63
- puts "Writing lockfile to #{file}"
64
- definition.lock(file)
60
+ if print
61
+ puts definition.to_lock
62
+ else
63
+ file = options[:lockfile]
64
+ file = file ? File.expand_path(file) : Bundler.default_lockfile
65
+ puts "Writing lockfile to #{file}"
66
+ definition.lock(file)
67
+ end
65
68
  end
66
69
 
67
70
  Bundler.ui.level = previous_ui_level
@@ -18,13 +18,11 @@ module Bundler
18
18
  Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist."
19
19
  else
20
20
  root_path = spec.full_gem_path
21
- Dir.chdir(root_path) do
22
- require "shellwords"
23
- command = Shellwords.split(editor) << File.join([root_path, path].compact)
24
- Bundler.with_original_env do
25
- system(*command)
26
- end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
27
- end
21
+ require "shellwords"
22
+ command = Shellwords.split(editor) << File.join([root_path, path].compact)
23
+ Bundler.with_original_env do
24
+ system(*command, { :chdir => root_path })
25
+ end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
28
26
  end
29
27
  end
30
28
  end
@@ -149,7 +149,7 @@ module Bundler
149
149
  @dependency_changes = converge_dependencies
150
150
  @local_changes = converge_locals
151
151
 
152
- @missing_lockfile_dep = check_missing_lockfile_dep
152
+ check_lockfile
153
153
  end
154
154
 
155
155
  def gem_version_promoter
@@ -405,13 +405,13 @@ module Bundler
405
405
  msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
406
406
  msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
407
407
  msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
408
- msg << "\n\nRun `bundle install` elsewhere and add the updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control.\n"
408
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_gemfile_path} to version control.\n"
409
409
 
410
410
  unless explicit_flag
411
411
  suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
412
412
  "bundle config set frozen false"
413
413
  end
414
- msg << "If this is a development machine, remove the #{Bundler.default_gemfile.relative_path_from(SharedHelpers.pwd)} " \
414
+ msg << "If this is a development machine, remove the #{SharedHelpers.relative_lockfile_path} " \
415
415
  "freeze by running `#{suggested_command}`." if suggested_command
416
416
  end
417
417
 
@@ -452,8 +452,8 @@ module Bundler
452
452
  return if current_platform_locked?
453
453
 
454
454
  raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
455
- "but your local platform is #{Bundler.local_platform}. " \
456
- "Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
455
+ "but your local platform is #{local_platform}. " \
456
+ "Add the current platform to the lockfile with\n`bundle lock --add-platform #{local_platform}` and try again."
457
457
  end
458
458
 
459
459
  def add_platform(platform)
@@ -478,7 +478,7 @@ module Bundler
478
478
  private :sources
479
479
 
480
480
  def nothing_changed?
481
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@missing_lockfile_dep && !@unlocking_bundler
481
+ !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@missing_lockfile_dep && !@unlocking_bundler && !@invalid_lockfile_dep
482
482
  end
483
483
 
484
484
  def no_resolve_needed?
@@ -509,7 +509,7 @@ module Bundler
509
509
  def resolution_packages
510
510
  @resolution_packages ||= begin
511
511
  last_resolve = converge_locked_specs
512
- remove_ruby_from_platforms_if_necessary!(current_dependencies)
512
+ remove_invalid_platforms!(current_dependencies)
513
513
  packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, :locked_specs => @originally_locked_specs, :unlock => @unlock[:gems], :prerelease => gem_version_promoter.pre?)
514
514
  additional_base_requirements_for_resolve(packages, last_resolve)
515
515
  end
@@ -600,7 +600,7 @@ module Bundler
600
600
 
601
601
  def current_platform_locked?
602
602
  @platforms.any? do |bundle_platform|
603
- MatchPlatform.platforms_match?(bundle_platform, Bundler.local_platform)
603
+ MatchPlatform.platforms_match?(bundle_platform, local_platform)
604
604
  end
605
605
  end
606
606
 
@@ -630,6 +630,7 @@ module Bundler
630
630
  [@local_changes, "the gemspecs for git local gems changed"],
631
631
  [@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],
632
632
  [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
633
+ [@invalid_lockfile_dep, "your lock file has an invalid dependency \"#{@invalid_lockfile_dep}\""],
633
634
  ].select(&:first).map(&:last).join(", ")
634
635
  end
635
636
 
@@ -684,24 +685,38 @@ module Bundler
684
685
  !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
685
686
  end
686
687
 
687
- def check_missing_lockfile_dep
688
- all_locked_specs = @locked_specs.map(&:name) << "bundler"
688
+ def check_lockfile
689
+ @invalid_lockfile_dep = nil
690
+ @missing_lockfile_dep = nil
689
691
 
690
- missing = @locked_specs.select do |s|
691
- s.dependencies.any? {|dep| !all_locked_specs.include?(dep.name) }
692
+ locked_names = @locked_specs.map(&:name)
693
+ missing = []
694
+ invalid = []
695
+
696
+ @locked_specs.each do |s|
697
+ s.dependencies.each do |dep|
698
+ next if dep.name == "bundler"
699
+
700
+ missing << s unless locked_names.include?(dep.name)
701
+ invalid << s if @locked_specs.none? {|spec| dep.matches_spec?(spec) }
702
+ end
692
703
  end
693
704
 
694
705
  if missing.any?
695
706
  @locked_specs.delete(missing)
696
707
 
697
- return missing.first.name
708
+ @missing_lockfile_dep = missing.first.name
709
+ elsif !@dependency_changes
710
+ @missing_lockfile_dep = current_dependencies.find do |d|
711
+ @locked_specs[d.name].empty? && d.name != "bundler"
712
+ end&.name
698
713
  end
699
714
 
700
- return if @dependency_changes
715
+ if invalid.any?
716
+ @locked_specs.delete(invalid)
701
717
 
702
- current_dependencies.find do |d|
703
- @locked_specs[d.name].empty? && d.name != "bundler"
704
- end&.name
718
+ @invalid_lockfile_dep = invalid.first.name
719
+ end
705
720
  end
706
721
 
707
722
  def converge_paths
@@ -941,17 +956,19 @@ module Bundler
941
956
  resolution_packages
942
957
  end
943
958
 
944
- def remove_ruby_from_platforms_if_necessary!(dependencies)
945
- return if Bundler.frozen_bundle? ||
946
- Bundler.local_platform == Gem::Platform::RUBY ||
947
- !platforms.include?(Gem::Platform::RUBY) ||
948
- (@new_platform && platforms.last == Gem::Platform::RUBY) ||
959
+ def remove_invalid_platforms!(dependencies)
960
+ return if Bundler.frozen_bundle?
961
+
962
+ platforms.each do |platform|
963
+ next if local_platform == platform ||
964
+ (@new_platform && platforms.last == platform) ||
949
965
  @path_changes ||
950
966
  @dependency_changes ||
951
- !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
967
+ !@originally_locked_specs.incomplete_for_platform?(dependencies, platform)
952
968
 
953
- remove_platform(Gem::Platform::RUBY)
954
- add_current_platform
969
+ remove_platform(platform)
970
+ add_current_platform if platform == Gem::Platform::RUBY
971
+ end
955
972
  end
956
973
 
957
974
  def source_map
data/lib/bundler/env.rb CHANGED
@@ -40,11 +40,11 @@ module Bundler
40
40
 
41
41
  out << "\n## Gemfile\n"
42
42
  gemfiles.each do |gemfile|
43
- out << "\n### #{Pathname.new(gemfile).relative_path_from(SharedHelpers.pwd)}\n\n"
43
+ out << "\n### #{SharedHelpers.relative_path_to(gemfile)}\n\n"
44
44
  out << "```ruby\n" << read_file(gemfile).chomp << "\n```\n"
45
45
  end
46
46
 
47
- out << "\n### #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n"
47
+ out << "\n### #{SharedHelpers.relative_path_to(Bundler.default_lockfile)}\n\n"
48
48
  out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n"
49
49
  end
50
50
 
@@ -101,7 +101,7 @@ module Bundler
101
101
  next 1 if b_pre && !a_pre
102
102
  end
103
103
 
104
- if major?
104
+ if major? || locked_version.nil?
105
105
  a <=> b
106
106
  elsif either_version_older_than_locked?(a, b, locked_version)
107
107
  a <=> b
@@ -117,7 +117,7 @@ module Bundler
117
117
  end
118
118
 
119
119
  def either_version_older_than_locked?(a, b, locked_version)
120
- locked_version && (a.version < locked_version || b.version < locked_version)
120
+ a.version < locked_version || b.version < locked_version
121
121
  end
122
122
 
123
123
  def segments_do_not_match?(a, b, level)
@@ -86,7 +86,7 @@ module Bundler
86
86
  segments = version.segments
87
87
  seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
88
88
 
89
- prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
89
+ prerelease_suffix = version.to_s.delete_prefix(version.release.to_s) if version.prerelease?
90
90
  "#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
91
91
  end
92
92
 
@@ -91,38 +91,12 @@ module Bundler
91
91
  install_serially
92
92
  end
93
93
 
94
- check_for_unmet_dependencies
95
-
96
94
  handle_error if failed_specs.any?
97
95
  @specs
98
96
  ensure
99
97
  worker_pool&.stop
100
98
  end
101
99
 
102
- def check_for_unmet_dependencies
103
- unmet_dependencies = @specs.map do |s|
104
- [
105
- s,
106
- s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
107
- ]
108
- end.reject {|a| a.last.empty? }
109
- return if unmet_dependencies.empty?
110
-
111
- warning = []
112
- warning << "Your lockfile doesn't include a valid resolution."
113
- warning << "You can fix this by regenerating your lockfile or manually editing the bad locked gems to a version that satisfies all dependencies."
114
- warning << "The unmet dependencies are:"
115
-
116
- unmet_dependencies.each do |spec, unmet_spec_dependencies|
117
- unmet_spec_dependencies.each do |unmet_spec_dependency|
118
- found = @specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }
119
- warning << "* #{unmet_spec_dependency}, dependency of #{spec.full_name}, unsatisfied by #{found.full_name}"
120
- end
121
- end
122
-
123
- Bundler.ui.warn(warning.join("\n"))
124
- end
125
-
126
100
  private
127
101
 
128
102
  def failed_specs
@@ -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 prevent_gem_activation
15
16
  file.puts define_path_helpers
16
17
  file.puts reverse_rubygems_kernel_mixin
17
18
  paths.each do |path|
@@ -55,18 +56,24 @@ module Bundler
55
56
  if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
56
57
  full_path
57
58
  else
58
- relative_path_from(Bundler.root.join(bundler_path), :to => full_path) || full_path
59
+ SharedHelpers.relative_path_to(full_path, :from => Bundler.root.join(bundler_path))
59
60
  end
60
61
  rescue TypeError
61
62
  error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
62
63
  raise Gem::InvalidSpecificationException.new(error_message)
63
64
  end
64
65
 
65
- def relative_path_from(source, to:)
66
- Pathname.new(to).relative_path_from(source).to_s
67
- rescue ArgumentError
68
- # on Windows, if source and destination are on different drivers, there's no relative path from one to the other
69
- nil
66
+ def prevent_gem_activation
67
+ <<~'END'
68
+ module Kernel
69
+ remove_method(:gem) if private_method_defined?(:gem)
70
+
71
+ def gem(*)
72
+ end
73
+
74
+ private :gem
75
+ end
76
+ END
70
77
  end
71
78
 
72
79
  def define_path_helpers
@@ -23,13 +23,15 @@ module Bundler
23
23
  Gem::Version.create("1.13") => [PLUGIN].freeze,
24
24
  }.freeze
25
25
 
26
- KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
26
+ KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten!.freeze
27
27
 
28
28
  ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
29
29
  deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
30
30
 
31
31
  def self.sections_in_lockfile(lockfile_contents)
32
- lockfile_contents.scan(/^\w[\w ]*$/).uniq
32
+ sections = lockfile_contents.scan(/^\w[\w ]*$/)
33
+ sections.uniq!
34
+ sections
33
35
  end
34
36
 
35
37
  def self.unknown_sections_in_lockfile(lockfile_contents)
@@ -38,7 +40,7 @@ module Bundler
38
40
 
39
41
  def self.sections_to_ignore(base_version = nil)
40
42
  base_version &&= base_version.release
41
- base_version ||= Gem::Version.create("1.0".dup)
43
+ base_version ||= Gem::Version.create("1.0")
42
44
  attributes = []
43
45
  SECTIONS_BY_VERSION_INTRODUCED.each do |version, introduced|
44
46
  next if version <= base_version
@@ -61,36 +63,36 @@ module Bundler
61
63
  @platforms = []
62
64
  @sources = []
63
65
  @dependencies = {}
64
- @state = nil
66
+ @parse_method = nil
65
67
  @specs = {}
66
68
 
67
69
  if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
68
- raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
69
- "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
70
+ raise LockfileError, "Your lockfile contains merge conflicts.\n" \
71
+ "Run `git checkout HEAD -- #{SharedHelpers.relative_lockfile_path}` first to get a clean lock."
70
72
  end
71
73
 
72
- lockfile.split(/(?:\r?\n)+/).each do |line|
74
+ lockfile.split(/(?:\r?\n)+/) do |line|
73
75
  if SOURCE.include?(line)
74
- @state = :source
76
+ @parse_method = :parse_source
75
77
  parse_source(line)
76
78
  elsif line == DEPENDENCIES
77
- @state = :dependency
79
+ @parse_method = :parse_dependency
78
80
  elsif line == PLATFORMS
79
- @state = :platform
81
+ @parse_method = :parse_platform
80
82
  elsif line == RUBY
81
- @state = :ruby
83
+ @parse_method = :parse_ruby
82
84
  elsif line == BUNDLED
83
- @state = :bundled_with
85
+ @parse_method = :parse_bundled_with
84
86
  elsif /^[^\s]/.match?(line)
85
- @state = nil
86
- elsif @state
87
- send("parse_#{@state}", line)
87
+ @parse_method = nil
88
+ elsif @parse_method
89
+ send(@parse_method, line)
88
90
  end
89
91
  end
90
- @specs = @specs.values.sort_by(&:full_name)
92
+ @specs = @specs.values.sort_by!(&:full_name)
91
93
  rescue ArgumentError => e
92
94
  Bundler.ui.debug(e)
93
- raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
95
+ raise LockfileError, "Your lockfile is unreadable. Run `rm #{SharedHelpers.relative_lockfile_path}` " \
94
96
  "and then `bundle install` to generate a new lockfile."
95
97
  end
96
98
 
@@ -149,11 +151,11 @@ module Bundler
149
151
  return unless line =~ NAME_VERSION
150
152
  spaces = $1
151
153
  return unless spaces.size == 2
152
- name = $2
154
+ name = -$2
153
155
  version = $3
154
156
  pinned = $5
155
157
 
156
- version = version.split(",").map(&:strip) if version
158
+ version = version.split(",").each(&:strip!) if version
157
159
 
158
160
  dep = Bundler::Dependency.new(name, version)
159
161
 
@@ -177,11 +179,13 @@ module Bundler
177
179
  def parse_spec(line)
178
180
  return unless line =~ NAME_VERSION
179
181
  spaces = $1
180
- name = $2
182
+ name = -$2
181
183
  version = $3
182
- platform = $4
183
184
 
184
185
  if spaces.size == 4
186
+ # only load platform for non-dependency (spec) line
187
+ platform = $4
188
+
185
189
  version = Gem::Version.new(version)
186
190
  platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
187
191
  @current_spec = LazySpecification.new(name, version, platform)
@@ -190,7 +194,7 @@ module Bundler
190
194
 
191
195
  @specs[@current_spec.full_name] = @current_spec
192
196
  elsif spaces.size == 6
193
- version = version.split(",").map(&:strip) if version
197
+ version = version.split(",").each(&:strip!) if version
194
198
  dep = Gem::Dependency.new(name, version)
195
199
  @current_spec.dependencies << dep
196
200
  end
@@ -201,13 +205,14 @@ module Bundler
201
205
  end
202
206
 
203
207
  def parse_bundled_with(line)
204
- line = line.strip
208
+ line.strip!
205
209
  return unless Gem::Version.correct?(line)
206
210
  @bundler_version = Gem::Version.create(line)
207
211
  end
208
212
 
209
213
  def parse_ruby(line)
210
- @ruby_version = line.strip
214
+ line.strip!
215
+ @ruby_version = line
211
216
  end
212
217
  end
213
218
  end
@@ -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" "August 2023" "" ""
4
+ .TH "BUNDLE\-ADD" "1" "October 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-BINSTUBS" "1" "August 2023" "" ""
4
+ .TH "BUNDLE\-BINSTUBS" "1" "October 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" "August 2023" "" ""
4
+ .TH "BUNDLE\-CACHE" "1" "October 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
@@ -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" "August 2023" "" ""
4
+ .TH "BUNDLE\-CHECK" "1" "October 2023" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems