bundler 2.5.9 → 2.5.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/install.rb +1 -1
  5. data/lib/bundler/cli.rb +5 -22
  6. data/lib/bundler/compact_index_client/cache.rb +16 -7
  7. data/lib/bundler/constants.rb +8 -1
  8. data/lib/bundler/definition.rb +70 -50
  9. data/lib/bundler/dependency.rb +2 -1
  10. data/lib/bundler/environment_preserver.rb +2 -20
  11. data/lib/bundler/errors.rb +14 -0
  12. data/lib/bundler/gem_helper.rb +1 -1
  13. data/lib/bundler/injector.rb +2 -1
  14. data/lib/bundler/installer.rb +8 -8
  15. data/lib/bundler/man/bundle-add.1 +1 -1
  16. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  17. data/lib/bundler/man/bundle-cache.1 +1 -1
  18. data/lib/bundler/man/bundle-check.1 +3 -1
  19. data/lib/bundler/man/bundle-check.1.ronn +3 -0
  20. data/lib/bundler/man/bundle-clean.1 +1 -1
  21. data/lib/bundler/man/bundle-config.1 +1 -3
  22. data/lib/bundler/man/bundle-config.1.ronn +0 -3
  23. data/lib/bundler/man/bundle-console.1 +1 -1
  24. data/lib/bundler/man/bundle-doctor.1 +1 -1
  25. data/lib/bundler/man/bundle-exec.1 +1 -1
  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 +1 -1
  38. data/lib/bundler/man/bundle-pristine.1 +1 -1
  39. data/lib/bundler/man/bundle-remove.1 +1 -1
  40. data/lib/bundler/man/bundle-show.1 +1 -1
  41. data/lib/bundler/man/bundle-update.1 +1 -1
  42. data/lib/bundler/man/bundle-version.1 +1 -1
  43. data/lib/bundler/man/bundle-viz.1 +1 -1
  44. data/lib/bundler/man/bundle.1 +1 -1
  45. data/lib/bundler/man/gemfile.5 +1 -1
  46. data/lib/bundler/rubygems_ext.rb +29 -9
  47. data/lib/bundler/self_manager.rb +1 -1
  48. data/lib/bundler/settings.rb +0 -1
  49. data/lib/bundler/setup.rb +3 -0
  50. data/lib/bundler/shared_helpers.rb +6 -4
  51. data/lib/bundler/source/git/git_proxy.rb +8 -0
  52. data/lib/bundler/source/metadata.rb +2 -0
  53. data/lib/bundler/source/rubygems.rb +6 -18
  54. data/lib/bundler/source_list.rb +28 -4
  55. data/lib/bundler/spec_set.rb +1 -1
  56. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +77 -29
  57. data/lib/bundler/version.rb +1 -1
  58. data/lib/bundler.rb +20 -0
  59. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b343f681293b03c25fbc82c8d4c323154aec1af8dc5f34e619779c7f4d4c634b
4
- data.tar.gz: 0566537e3cc941f3160e5060c806f0418907cca56e8d0e56a5b79dbb7d9bd94f
3
+ metadata.gz: e07468635327ec2b436d1015aadd6b09377511e9793dbd614e4d528104f6cf95
4
+ data.tar.gz: 6fd4b37515fe7854b32c7cfa0a48568a36a5f2a81f0ca93be86c263fec92eabe
5
5
  SHA512:
6
- metadata.gz: 2effd5a50b198e6113853e8d695bcc98d396f6bc0d036e55756a7615755fa8f7498fbab09f7b51d13aef5fe0c2acd1de807c16f7446c5a188de18f7793ebab4b
7
- data.tar.gz: 8cdafdd6dbe2da1aa03e44717211fc88440974c03c2057f57ecf514c5b9253d1aa7f1e9994758bcfb5ba614435b0853d070dfe32bfd25a7a033f45b03db86ca2
6
+ metadata.gz: 52cc1652e43f2568c0979188ce7a78f13e92a217fc67aa5063ce9d882739e288afc0ed43db43c18de8522e7b1460d9946a9ded85f3dd4195b9e411d6e2ef1c3f
7
+ data.tar.gz: '0581fccb9f4fb784b135bd5ffd84bd9b25e05597b9194d8d01844b243c85e899477b93204ea49298d72282d0bb38692b3aefebb78e24329853ac9e85d3effa2a'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,55 @@
1
+ # 2.5.11 (May 28, 2024)
2
+
3
+ ## Deprecations:
4
+
5
+ - Deprecate Bundler constants [#7653](https://github.com/rubygems/rubygems/pull/7653)
6
+
7
+ ## Enhancements:
8
+
9
+ - Bump `bundle gem` generated COC to Contributor Covenant 2.1 [#7692](https://github.com/rubygems/rubygems/pull/7692)
10
+ - Retry a full clone when git server does not support shallow capabilities [#7649](https://github.com/rubygems/rubygems/pull/7649)
11
+
12
+ ## Bug fixes:
13
+
14
+ - Fix regression when caching gems from secondary sources [#7659](https://github.com/rubygems/rubygems/pull/7659)
15
+ - Fix error when Bundler installation is corrupted [#7642](https://github.com/rubygems/rubygems/pull/7642)
16
+ - Fix crash caused by RubyGems `require` gem activation logic running before Bundler can properly register its own monkeypatches [#7647](https://github.com/rubygems/rubygems/pull/7647)
17
+
18
+ ## Performance:
19
+
20
+ - Update cache checksums to decrease string allocations [#7637](https://github.com/rubygems/rubygems/pull/7637)
21
+ - Fix performance regression in applications with a local cache [#7680](https://github.com/rubygems/rubygems/pull/7680)
22
+
23
+ ## Documentation:
24
+
25
+ - Recommend `bin/rake` over `rake` in contributing docs [#7648](https://github.com/rubygems/rubygems/pull/7648)
26
+ - Monthly man update for May 2024 [#7640](https://github.com/rubygems/rubygems/pull/7640)
27
+ - Clarify Bundler support policy [#7633](https://github.com/rubygems/rubygems/pull/7633)
28
+
29
+ # 2.5.10 (May 3, 2024)
30
+
31
+ ## Security:
32
+
33
+ - Never write credentials to lockfiles [#7560](https://github.com/rubygems/rubygems/pull/7560)
34
+
35
+ ## Enhancements:
36
+
37
+ - Add auto_install support to require "bundler/setup" [#6561](https://github.com/rubygems/rubygems/pull/6561)
38
+ - Add `--glob` flag to `bundle add` [#7557](https://github.com/rubygems/rubygems/pull/7557)
39
+
40
+ ## Bug fixes:
41
+
42
+ - Make sure `bundle update <specific_gems>` can always update to the latest resolvable version of each requested gem [#7558](https://github.com/rubygems/rubygems/pull/7558)
43
+ - Show better error when installed gemspecs are unreadable [#7603](https://github.com/rubygems/rubygems/pull/7603)
44
+ - Fix `bundle update` not working on an out of sync lockfile [#7607](https://github.com/rubygems/rubygems/pull/7607)
45
+ - Don't upcase Windows ENV before backing it up [#7574](https://github.com/rubygems/rubygems/pull/7574)
46
+ - Properly resolve aliases when `bundle help` is run [#7601](https://github.com/rubygems/rubygems/pull/7601)
47
+ - Fix issue installing gems with linux-musl variant on non musl linux [#7583](https://github.com/rubygems/rubygems/pull/7583)
48
+
49
+ ## Documentation:
50
+
51
+ - Clarify `bundle check` behaviour in docs [#7613](https://github.com/rubygems/rubygems/pull/7613)
52
+
1
53
  # 2.5.9 (April 12, 2024)
2
54
 
3
55
  ## Bug fixes:
@@ -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 = "2024-04-12".freeze
8
- @git_commit_sha = "4304697e0c".freeze
7
+ @built_at = "2024-05-28".freeze
8
+ @git_commit_sha = "4afb2d450a".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -14,7 +14,7 @@ module Bundler
14
14
 
15
15
  Bundler.self_manager.install_locked_bundler_and_restart_with_it_if_needed
16
16
 
17
- Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Bundler::FREEBSD
17
+ Bundler::SharedHelpers.set_env "RB_USER_INSTALL", "1" if Gem.freebsd_platform?
18
18
 
19
19
  # Disable color in deployment mode
20
20
  Bundler.ui.shell = Thor::Shell::Basic.new if options[:deployment]
data/lib/bundler/cli.rb CHANGED
@@ -5,6 +5,7 @@ require_relative "vendored_thor"
5
5
  module Bundler
6
6
  class CLI < Thor
7
7
  require_relative "cli/common"
8
+ require_relative "cli/install"
8
9
 
9
10
  package_name "Bundler"
10
11
 
@@ -69,7 +70,7 @@ module Bundler
69
70
  Bundler.settings.set_command_option_if_given :retry, options[:retry]
70
71
 
71
72
  current_cmd = args.last[:current_command].name
72
- auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
+ Bundler.auto_install if AUTO_INSTALL_CMDS.include?(current_cmd)
73
74
  rescue UnknownArgumentError => e
74
75
  raise InvalidOption, e.message
75
76
  ensure
@@ -114,6 +115,8 @@ module Bundler
114
115
  class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
115
116
 
116
117
  def help(cli = nil)
118
+ cli = self.class.all_aliases[cli] if self.class.all_aliases[cli]
119
+
117
120
  case cli
118
121
  when "gemfile" then command = "gemfile"
119
122
  when nil then command = "bundle"
@@ -347,6 +350,7 @@ module Bundler
347
350
  method_option "github", type: :string
348
351
  method_option "branch", type: :string
349
352
  method_option "ref", type: :string
353
+ method_option "glob", type: :string, banner: "The location of a dependency's .gemspec, expanded within Ruby (single quotes recommended)"
350
354
  method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it"
351
355
  method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem"
352
356
  method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem"
@@ -682,7 +686,6 @@ module Bundler
682
686
  exec_used = args.index {|a| exec_commands.include? a }
683
687
 
684
688
  command = args.find {|a| bundler_commands.include? a }
685
- command = all_aliases[command] if all_aliases[command]
686
689
 
687
690
  if exec_used && help_used
688
691
  if exec_used + help_used == 1
@@ -735,26 +738,6 @@ module Bundler
735
738
 
736
739
  private
737
740
 
738
- # Automatically invoke `bundle install` and resume if
739
- # Bundler.settings[:auto_install] exists. This is set through config cmd
740
- # `bundle config set --global auto_install 1`.
741
- #
742
- # Note that this method `nil`s out the global Definition object, so it
743
- # should be called first, before you instantiate anything like an
744
- # `Installer` that'll keep a reference to the old one instead.
745
- def auto_install
746
- return unless Bundler.settings[:auto_install]
747
-
748
- begin
749
- Bundler.definition.specs
750
- rescue GemNotFound, GitError
751
- Bundler.ui.info "Automatically installing missing gems."
752
- Bundler.reset!
753
- invoke :install, []
754
- Bundler.reset!
755
- end
756
- end
757
-
758
741
  def current_command
759
742
  _, _, config = @_initializer
760
743
  config[:current_command]
@@ -55,14 +55,9 @@ module Bundler
55
55
  end
56
56
 
57
57
  def checksums
58
- checksums = {}
59
-
60
- lines(versions_path).each do |line|
61
- name, _, checksum = line.split(" ", 3)
62
- checksums[name] = checksum
58
+ lines(versions_path).each_with_object({}) do |line, checksums|
59
+ parse_version_checksum(line, checksums)
63
60
  end
64
-
65
- checksums
66
61
  end
67
62
 
68
63
  def dependencies(name)
@@ -106,6 +101,20 @@ module Bundler
106
101
  @dependency_parser.parse(line)
107
102
  end
108
103
 
104
+ # This is mostly the same as `split(" ", 3)` but it avoids allocating extra objects.
105
+ # This method gets called at least once for every gem when parsing versions.
106
+ def parse_version_checksum(line, checksums)
107
+ line.freeze # allows slicing into the string to not allocate a copy of the line
108
+ name_end = line.index(" ")
109
+ checksum_start = line.index(" ", name_end + 1) + 1
110
+ checksum_end = line.size - checksum_start
111
+ # freeze name since it is used as a hash key
112
+ # pre-freezing means a frozen copy isn't created
113
+ name = line[0, name_end].freeze
114
+ checksum = line[checksum_start, checksum_end]
115
+ checksums[name] = checksum
116
+ end
117
+
109
118
  def info_roots
110
119
  [
111
120
  directory.join("info"),
@@ -1,7 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rbconfig"
4
+
3
5
  module Bundler
4
6
  WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
7
+ deprecate_constant :WINDOWS
8
+
5
9
  FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd")
6
- NULL = File::NULL
10
+ deprecate_constant :FREEBSD
11
+
12
+ NULL = File::NULL
13
+ deprecate_constant :NULL
7
14
  end
@@ -69,7 +69,6 @@ module Bundler
69
69
  @sources = sources
70
70
  @unlock = unlock
71
71
  @optional_groups = optional_groups
72
- @remote = false
73
72
  @prefer_local = false
74
73
  @specs = nil
75
74
  @ruby_version = ruby_version
@@ -92,11 +91,12 @@ module Bundler
92
91
  @platforms = @locked_platforms.dup
93
92
  @locked_bundler_version = @locked_gems.bundler_version
94
93
  @locked_ruby_version = @locked_gems.ruby_version
94
+ @originally_locked_deps = @locked_gems.dependencies
95
95
  @originally_locked_specs = SpecSet.new(@locked_gems.specs)
96
96
  @locked_checksums = @locked_gems.checksums
97
97
 
98
98
  if unlock != true
99
- @locked_deps = @locked_gems.dependencies
99
+ @locked_deps = @originally_locked_deps
100
100
  @locked_specs = @originally_locked_specs
101
101
  @locked_sources = @locked_gems.sources
102
102
  else
@@ -111,6 +111,7 @@ module Bundler
111
111
  @locked_gems = nil
112
112
  @locked_deps = {}
113
113
  @locked_specs = SpecSet.new([])
114
+ @originally_locked_deps = {}
114
115
  @originally_locked_specs = @locked_specs
115
116
  @locked_sources = []
116
117
  @locked_platforms = []
@@ -130,7 +131,7 @@ module Bundler
130
131
  @sources.merged_gem_lockfile_sections!(locked_gem_sources.first)
131
132
  end
132
133
 
133
- @unlock[:sources] ||= []
134
+ @sources_to_unlock = @unlock.delete(:sources) || []
134
135
  @unlock[:ruby] ||= if @ruby_version && locked_ruby_version_object
135
136
  @ruby_version.diff(locked_ruby_version_object)
136
137
  end
@@ -142,11 +143,13 @@ module Bundler
142
143
  @path_changes = converge_paths
143
144
  @source_changes = converge_sources
144
145
 
146
+ @explicit_unlocks = @unlock.delete(:gems) || []
147
+
145
148
  if @unlock[:conservative]
146
- @unlock[:gems] ||= @dependencies.map(&:name)
149
+ @gems_to_unlock = @explicit_unlocks.any? ? @explicit_unlocks : @dependencies.map(&:name)
147
150
  else
148
- eager_unlock = (@unlock[:gems] || []).map {|name| Dependency.new(name, ">= 0") }
149
- @unlock[:gems] = @locked_specs.for(eager_unlock, false, platforms).map(&:name).uniq
151
+ eager_unlock = @explicit_unlocks.map {|name| Dependency.new(name, ">= 0") }
152
+ @gems_to_unlock = @locked_specs.for(eager_unlock, false, platforms).map(&:name).uniq
150
153
  end
151
154
 
152
155
  @dependency_changes = converge_dependencies
@@ -160,37 +163,24 @@ module Bundler
160
163
  end
161
164
 
162
165
  def resolve_only_locally!
163
- @remote = false
164
166
  sources.local_only!
165
167
  resolve
166
168
  end
167
169
 
168
170
  def resolve_with_cache!
171
+ sources.local!
169
172
  sources.cached!
170
173
  resolve
171
174
  end
172
175
 
173
176
  def resolve_remotely!
174
- @remote = true
177
+ sources.cached!
175
178
  sources.remote!
176
179
  resolve
177
180
  end
178
181
 
179
- def resolution_mode=(options)
180
- if options["local"]
181
- @remote = false
182
- else
183
- @remote = true
184
- @prefer_local = options["prefer-local"]
185
- end
186
- end
187
-
188
- def setup_sources_for_resolve
189
- if @remote == false
190
- sources.cached!
191
- else
192
- sources.remote!
193
- end
182
+ def prefer_local!
183
+ @prefer_local = true
194
184
  end
195
185
 
196
186
  # For given dependency list returns a SpecSet with Gemspec of all the required
@@ -225,7 +215,6 @@ module Bundler
225
215
  @resolver = nil
226
216
  @resolution_packages = nil
227
217
  @specs = nil
228
- @gem_version_promoter = nil
229
218
 
230
219
  Bundler.ui.debug "The definition is missing dependencies, failed to resolve & materialize locally (#{e})"
231
220
  true
@@ -307,7 +296,12 @@ module Bundler
307
296
  end
308
297
  end
309
298
  else
310
- Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
299
+ if lockfile_exists?
300
+ Bundler.ui.debug "Found changes from the lockfile, re-resolving dependencies because #{change_reason}"
301
+ else
302
+ Bundler.ui.debug "Resolving dependencies because there's no lockfile"
303
+ end
304
+
311
305
  start_resolution
312
306
  end
313
307
  end
@@ -480,6 +474,8 @@ module Bundler
480
474
  private :sources
481
475
 
482
476
  def nothing_changed?
477
+ return false unless lockfile_exists?
478
+
483
479
  !@source_changes &&
484
480
  !@dependency_changes &&
485
481
  !@new_platform &&
@@ -566,8 +562,10 @@ module Bundler
566
562
  @resolution_packages ||= begin
567
563
  last_resolve = converge_locked_specs
568
564
  remove_invalid_platforms!(current_dependencies)
569
- packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @unlock[:gems], prerelease: gem_version_promoter.pre?)
570
- additional_base_requirements_for_resolve(packages, last_resolve)
565
+ packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @gems_to_unlock, prerelease: gem_version_promoter.pre?)
566
+ packages = additional_base_requirements_to_prevent_downgrades(packages, last_resolve)
567
+ packages = additional_base_requirements_to_force_updates(packages)
568
+ packages
571
569
  end
572
570
  end
573
571
 
@@ -582,7 +580,7 @@ module Bundler
582
580
  if missing_specs.any?
583
581
  missing_specs.each do |s|
584
582
  locked_gem = @locked_specs[s.name].last
585
- next if locked_gem.nil? || locked_gem.version != s.version || !@remote
583
+ next if locked_gem.nil? || locked_gem.version != s.version || sources.local_mode?
586
584
  raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \
587
585
  "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \
588
586
  "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \
@@ -601,7 +599,7 @@ module Bundler
601
599
  break if incomplete_specs.empty?
602
600
 
603
601
  Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
604
- setup_sources_for_resolve
602
+ sources.remote!
605
603
  resolution_packages.delete(incomplete_specs)
606
604
  @resolve = start_resolution
607
605
  specs = resolve.materialize(dependencies)
@@ -671,14 +669,18 @@ module Bundler
671
669
 
672
670
  def change_reason
673
671
  if unlocking?
674
- unlock_reason = @unlock.reject {|_k, v| Array(v).empty? }.map do |k, v|
675
- if v == true
676
- k.to_s
677
- else
678
- v = Array(v)
679
- "#{k}: (#{v.join(", ")})"
680
- end
681
- end.join(", ")
672
+ unlock_targets = if @gems_to_unlock.any?
673
+ ["gems", @gems_to_unlock]
674
+ elsif @sources_to_unlock.any?
675
+ ["sources", @sources_to_unlock]
676
+ end
677
+
678
+ unlock_reason = if unlock_targets
679
+ "#{unlock_targets.first}: (#{unlock_targets.last.join(", ")})"
680
+ else
681
+ @unlock[:ruby] ? "ruby" : ""
682
+ end
683
+
682
684
  return "bundler is unlocking #{unlock_reason}"
683
685
  end
684
686
  [
@@ -733,7 +735,7 @@ module Bundler
733
735
  spec = @dependencies.find {|s| s.name == k }
734
736
  source = spec&.source
735
737
  if source&.respond_to?(:local_override!)
736
- source.unlock! if @unlock[:gems].include?(spec.name)
738
+ source.unlock! if @gems_to_unlock.include?(spec.name)
737
739
  locals << [source, source.local_override!(v)]
738
740
  end
739
741
  end
@@ -741,7 +743,7 @@ module Bundler
741
743
  sources_with_changes = locals.select do |source, changed|
742
744
  changed || specs_changed?(source)
743
745
  end.map(&:first)
744
- !sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
746
+ !sources_with_changes.each {|source| @sources_to_unlock << source.name }.empty?
745
747
  end
746
748
 
747
749
  def check_lockfile
@@ -818,7 +820,7 @@ module Bundler
818
820
  # gem), unlock it. For git sources, this means to unlock the revision, which
819
821
  # will cause the `ref` used to be the most recent for the branch (or master) if
820
822
  # an explicit `ref` is not used.
821
- if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
823
+ if source.respond_to?(:unlock!) && @sources_to_unlock.include?(source.name)
822
824
  source.unlock!
823
825
  changes = true
824
826
  end
@@ -835,9 +837,7 @@ module Bundler
835
837
  dep.source = sources.get(dep.source)
836
838
  end
837
839
 
838
- next if unlocking?
839
-
840
- unless locked_dep = @locked_deps[dep.name]
840
+ unless locked_dep = @originally_locked_deps[dep.name]
841
841
  changes = true
842
842
  next
843
843
  end
@@ -864,7 +864,7 @@ module Bundler
864
864
  def converge_locked_specs
865
865
  converged = converge_specs(@locked_specs)
866
866
 
867
- resolve = SpecSet.new(converged.reject {|s| @unlock[:gems].include?(s.name) })
867
+ resolve = SpecSet.new(converged.reject {|s| @gems_to_unlock.include?(s.name) })
868
868
 
869
869
  diff = nil
870
870
 
@@ -897,7 +897,7 @@ module Bundler
897
897
 
898
898
  @specs_that_changed_sources << s if gemfile_source != lockfile_source
899
899
  deps << dep if !dep.source || lockfile_source.include?(dep.source)
900
- @unlock[:gems] << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
900
+ @gems_to_unlock << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
901
901
 
902
902
  # Replace the locked dependency's source with the equivalent source from the Gemfile
903
903
  s.source = gemfile_source
@@ -906,7 +906,7 @@ module Bundler
906
906
  s.source = default_source unless sources.get(lockfile_source)
907
907
  end
908
908
 
909
- next if @unlock[:sources].include?(s.source.name)
909
+ next if @sources_to_unlock.include?(s.source.name)
910
910
 
911
911
  # Path sources have special logic
912
912
  if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
@@ -928,12 +928,12 @@ module Bundler
928
928
  else
929
929
  # If the spec is no longer in the path source, unlock it. This
930
930
  # commonly happens if the version changed in the gemspec
931
- @unlock[:gems] << name
931
+ @gems_to_unlock << name
932
932
  end
933
933
  end
934
934
 
935
935
  if dep.nil? && requested_dependencies.find {|d| name == d.name }
936
- @unlock[:gems] << s.name
936
+ @gems_to_unlock << s.name
937
937
  else
938
938
  converged << s
939
939
  end
@@ -960,7 +960,7 @@ module Bundler
960
960
  else
961
961
  { default: Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
962
962
  end
963
- source_requirements.merge!(source_map.locked_requirements) unless @remote
963
+ source_requirements.merge!(source_map.locked_requirements) if nothing_changed?
964
964
  metadata_dependencies.each do |dep|
965
965
  source_requirements[dep.name] = sources.metadata_source
966
966
  end
@@ -1010,7 +1010,7 @@ module Bundler
1010
1010
  current == proposed
1011
1011
  end
1012
1012
 
1013
- def additional_base_requirements_for_resolve(resolution_packages, last_resolve)
1013
+ def additional_base_requirements_to_prevent_downgrades(resolution_packages, last_resolve)
1014
1014
  return resolution_packages unless @locked_gems && !sources.expired_sources?(@locked_gems.sources)
1015
1015
  converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
1016
1016
  next if locked_spec.source.is_a?(Source::Path)
@@ -1019,6 +1019,26 @@ module Bundler
1019
1019
  resolution_packages
1020
1020
  end
1021
1021
 
1022
+ def additional_base_requirements_to_force_updates(resolution_packages)
1023
+ return resolution_packages if @explicit_unlocks.empty?
1024
+ full_update = dup_for_full_unlock.resolve
1025
+ @explicit_unlocks.each do |name|
1026
+ version = full_update[name].first&.version
1027
+ resolution_packages.base_requirements[name] = Gem::Requirement.new("= #{version}") if version
1028
+ end
1029
+ resolution_packages
1030
+ end
1031
+
1032
+ def dup_for_full_unlock
1033
+ unlocked_definition = self.class.new(@lockfile, @dependencies, @sources, true, @ruby_version, @optional_groups, @gemfiles)
1034
+ unlocked_definition.gem_version_promoter.tap do |gvp|
1035
+ gvp.level = gem_version_promoter.level
1036
+ gvp.strict = gem_version_promoter.strict
1037
+ gvp.pre = gem_version_promoter.pre
1038
+ end
1039
+ unlocked_definition
1040
+ end
1041
+
1022
1042
  def remove_invalid_platforms!(dependencies)
1023
1043
  return if Bundler.frozen_bundle?
1024
1044
 
@@ -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, :path, :git, :github, :branch, :ref
10
+ attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref, :glob
11
11
 
12
12
  ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..34).to_a).freeze
13
13
  PLATFORM_MAP = {
@@ -39,6 +39,7 @@ module Bundler
39
39
  @github = options["github"]
40
40
  @branch = options["branch"]
41
41
  @ref = options["ref"]
42
+ @glob = options["glob"]
42
43
  @platforms = Array(options["platforms"])
43
44
  @env = options["env"]
44
45
  @should_include = options.fetch("should_include", true)
@@ -19,14 +19,7 @@ module Bundler
19
19
  BUNDLER_PREFIX = "BUNDLER_ORIG_"
20
20
 
21
21
  def self.from_env
22
- new(env_to_hash(ENV), BUNDLER_KEYS)
23
- end
24
-
25
- def self.env_to_hash(env)
26
- to_hash = env.to_hash
27
- return to_hash unless Gem.win_platform?
28
-
29
- to_hash.each_with_object({}) {|(k,v), a| a[k.upcase] = v }
22
+ new(ENV.to_hash, BUNDLER_KEYS)
30
23
  end
31
24
 
32
25
  # @param env [Hash]
@@ -39,18 +32,7 @@ module Bundler
39
32
 
40
33
  # Replaces `ENV` with the bundler environment variables backed up
41
34
  def replace_with_backup
42
- unless Gem.win_platform?
43
- ENV.replace(backup)
44
- return
45
- end
46
-
47
- # Fallback logic for Windows below to workaround
48
- # https://bugs.ruby-lang.org/issues/16798. Can be dropped once all
49
- # supported rubies include the fix for that.
50
-
51
- ENV.clear
52
-
53
- backup.each {|k, v| ENV[k] = v }
35
+ ENV.replace(backup)
54
36
  end
55
37
 
56
38
  # @return [Hash]
@@ -230,4 +230,18 @@ module Bundler
230
230
 
231
231
  status_code(38)
232
232
  end
233
+
234
+ class CorruptBundlerInstallError < BundlerError
235
+ def initialize(loaded_spec)
236
+ @loaded_spec = loaded_spec
237
+ end
238
+
239
+ def message
240
+ "The running version of Bundler (#{Bundler::VERSION}) does not match the version of the specification installed for it (#{@loaded_spec.version}). " \
241
+ "This can be caused by reinstalling Ruby without removing previous installation, leaving around an upgraded default version of Bundler. " \
242
+ "Reinstalling Ruby from scratch should fix the problem."
243
+ end
244
+
245
+ status_code(39)
246
+ end
233
247
  end
@@ -47,7 +47,7 @@ module Bundler
47
47
  built_gem_path = build_gem
48
48
  end
49
49
 
50
- desc "Generate SHA512 checksum if #{name}-#{version}.gem into the checksums directory."
50
+ desc "Generate SHA512 checksum of #{name}-#{version}.gem into the checksums directory."
51
51
  task "build:checksum" => "build" do
52
52
  build_checksum(built_gem_path)
53
53
  end
@@ -120,9 +120,10 @@ module Bundler
120
120
  github = ", :github => \"#{d.github}\"" unless d.github.nil?
121
121
  branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil?
122
122
  ref = ", :ref => \"#{d.ref}\"" unless d.ref.nil?
123
+ glob = ", :glob => \"#{d.glob}\"" unless d.glob.nil?
123
124
  require_path = ", :require => #{convert_autorequire(d.autorequire)}" unless d.autorequire.nil?
124
125
 
125
- %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{require_path})
126
+ %(gem #{name}#{requirement}#{group}#{source}#{path}#{git}#{github}#{branch}#{ref}#{glob}#{require_path})
126
127
  end.join("\n")
127
128
  end
128
129
 
@@ -249,15 +249,15 @@ module Bundler
249
249
 
250
250
  # returns whether or not a re-resolve was needed
251
251
  def resolve_if_needed(options)
252
- @definition.resolution_mode = options
253
-
254
- if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
255
- return false if @definition.nothing_changed? && !@definition.missing_specs?
252
+ @definition.prefer_local! if options["prefer-local"]
253
+
254
+ if options["local"] || (@definition.no_resolve_needed? && !@definition.missing_specs?)
255
+ @definition.resolve_with_cache!
256
+ false
257
+ else
258
+ @definition.resolve_remotely!
259
+ true
256
260
  end
257
-
258
- @definition.setup_sources_for_resolve
259
-
260
- true
261
261
  end
262
262
 
263
263
  def lock
@@ -1,6 +1,6 @@
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" "March 2024" ""
3
+ .TH "BUNDLE\-ADD" "1" "May 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
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" "March 2024" ""
3
+ .TH "BUNDLE\-BINSTUBS" "1" "May 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
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" "March 2024" ""
3
+ .TH "BUNDLE\-CACHE" "1" "May 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
6
6
  .SH "SYNOPSIS"