bundler 4.0.19 → 4.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b226f9f760a2d66f3b95d374178f56adb909e5cf3ffd2dc11c7605b2e87dba70
4
- data.tar.gz: 86e4c8a419331c322df10fa720ad136270b195de3550bd98760aae42d825f6c2
3
+ metadata.gz: b47ebbcd326a80d96d63eb16bc6743f1869f9ad1f37d83fac4dc9e1ea805c82c
4
+ data.tar.gz: c4903d7995ee2fa13381891ea105a1960ed5fb2ed69255f9fab09b4a7457f89e
5
5
  SHA512:
6
- metadata.gz: 27f08e16ceebc01eb1d884c5307b55d993c5048184c4eb2cc3df91596f384b1f23cf038f3b95119bbf0b89aee8f2cad2b380ddf5f8bd0500470fc1a04f882e70
7
- data.tar.gz: 4aaac6eb994de8d3fe9d3305168cea18e2eecd31802681bb548f70cd4ebebcf996d5edb85a61f090cdb05447f57dd074c113872da11831072c07a0c9cc4341e6
6
+ metadata.gz: 2bdee0e45396bc93bf1837856a137f30ac3fa2a6bd4cc805ada1c0326e25309da64571d048edcd230f4f2143e1878ca4628d525fadea65e89333255946d2ead8
7
+ data.tar.gz: a8f333636a584612db1e4ae36ad93265e22873c38b3ff6cab66bb0e935a84126eeeaef21626fa429fe3229a4f194881be7d8bfed25ebc7675719644d538f0d2e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.20 / 2026-09-02
4
+
5
+ ### Enhancements:
6
+
7
+ * Avoid duplicate relative path prefix in bundle exec. Pull request [#9596](https://github.com/ruby/rubygems/pull/9596) by samuel-williams-shopify
8
+ * Follow renamed default branch in git sources. Pull request [#9813](https://github.com/ruby/rubygems/pull/9813) by hsbt
9
+ * Bundler::Source::Git: avoid re-fetching the repo. Pull request [#9806](https://github.com/ruby/rubygems/pull/9806) by byroot
10
+ * Show the newest out-of-cooldown version in bundle outdated. Pull request [#9803](https://github.com/ruby/rubygems/pull/9803) by hsbt
11
+
12
+ ### Bug fixes:
13
+
14
+ * Error out when `bundle init --gemspec` gets no specification. Pull request [#9818](https://github.com/ruby/rubygems/pull/9818) by hsbt
15
+ * Fix relative gemspec paths being expanded twice. Pull request [#9814](https://github.com/ruby/rubygems/pull/9814) by hsbt
16
+ * Fix gemspec evaluation under Ruby::Box. Pull request [#9809](https://github.com/ruby/rubygems/pull/9809) by hsbt
17
+ * Fix release date extraction for the current changelog header format. Pull request [#9767](https://github.com/ruby/rubygems/pull/9767) by meganemura
18
+ * Resolve globbed entries literally in Gem::Util.glob_files_in_dir. Pull request [#9802](https://github.com/ruby/rubygems/pull/9802) by hsbt
19
+ * Preserve native extensions during implicit clean. Pull request [#9800](https://github.com/ruby/rubygems/pull/9800) by sjh9714
20
+
21
+ ### Documentation:
22
+
23
+ * Clarify :path expectations and cross-link platform docs in man pages. Pull request [#9724](https://github.com/ruby/rubygems/pull/9724) by hsbt
24
+
3
25
  ## 4.0.19 / 2026-08-20
4
26
 
5
27
  ### Enhancements:
@@ -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 = nil
8
- @git_commit_sha = "2d0e3df43a".freeze
7
+ @built_at = "2026-09-02".freeze
8
+ @git_commit_sha = "7f2502dc32b".freeze
9
9
  # end ivars
10
10
 
11
11
  # A hash representation of the build metadata.
@@ -53,7 +53,7 @@ module Bundler
53
53
  end
54
54
 
55
55
  def bundles_for_gem(spec)
56
- Dir.glob("#{spec.full_gem_path}/**/*.bundle")
56
+ SharedHelpers.glob_files_in_dir("**/*.bundle", spec.full_gem_path)
57
57
  end
58
58
 
59
59
  def lookup_with_fiddle(path)
@@ -23,7 +23,7 @@ module Bundler
23
23
  bin_path.delete_suffix!(".bat") if Gem.win_platform?
24
24
  kernel_load(bin_path, *args)
25
25
  else
26
- bin_path = "./" + bin_path unless File.absolute_path?(bin_path)
26
+ bin_path = explicit_path(bin_path)
27
27
  kernel_exec(bin_path, *args)
28
28
  end
29
29
  else
@@ -71,6 +71,20 @@ module Bundler
71
71
  "#{file} #{args.join(" ")}".strip
72
72
  end
73
73
 
74
+ def explicit_path(path)
75
+ if File.absolute_path?(path) || explicit_relative_path?(path)
76
+ path
77
+ else
78
+ ".#{File::SEPARATOR}#{path}"
79
+ end
80
+ end
81
+
82
+ def explicit_relative_path?(path)
83
+ [File::SEPARATOR, File::ALT_SEPARATOR].compact.any? do |separator|
84
+ path.start_with?(".#{separator}", "..#{separator}")
85
+ end
86
+ end
87
+
74
88
  def directly_loadable?(file)
75
89
  if Gem.win_platform?
76
90
  script_wrapper?(file)
@@ -26,6 +26,10 @@ module Bundler
26
26
  end
27
27
 
28
28
  spec = Bundler.load_gemspec_uncached(gemspec)
29
+ unless spec
30
+ Bundler.ui.error "Gem specification #{gemspec} did not produce a specification"
31
+ exit 1
32
+ end
29
33
 
30
34
  File.open(gemfile, "wb") do |file|
31
35
  file << "# Generated from #{gemspec}\n"
@@ -158,11 +158,29 @@ module Bundler
158
158
 
159
159
  return active_spec if strict
160
160
 
161
- active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.installable_on_platform?(current_spec.platform) }.sort_by(&:version)
162
- if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
163
- active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
161
+ matching_specs(active_spec, current_spec).last
162
+ end
163
+
164
+ def matching_specs(active_spec, current_spec)
165
+ @matching_specs ||= {}
166
+ @matching_specs[[active_spec.source, current_spec.name, current_spec.platform]] ||= begin
167
+ active_specs = active_spec.source.specs.search(current_spec.name).select {|spec| spec.installable_on_platform?(current_spec.platform) }.sort_by(&:version)
168
+ if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
169
+ active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
170
+ end
171
+ active_specs
164
172
  end
165
- active_specs.last
173
+ end
174
+
175
+ # The newest version the cooldown setting would let bundler adopt right
176
+ # now, when the newest overall version is still inside the window. Only a
177
+ # version strictly between the installed one and the newest one is an
178
+ # adoptable update worth showing.
179
+ def newest_out_of_cooldown(active_spec, current_spec)
180
+ newest = matching_specs(active_spec, current_spec).reverse_each.find {|spec| cooldown_days_remaining(spec).nil? }
181
+ return unless newest
182
+ return if newest.version >= active_spec.version || newest.version <= current_spec.version
183
+ newest
166
184
  end
167
185
 
168
186
  def print_gems(gems_list)
@@ -208,7 +226,11 @@ module Bundler
208
226
  spec_outdated_info += ", released #{release_date}" unless release_date.empty?
209
227
 
210
228
  remaining = cooldown_days_remaining(active_spec)
211
- spec_outdated_info += ", in cooldown for #{remaining} more day#{"s" if remaining > 1}" if remaining
229
+ if remaining
230
+ spec_outdated_info += ", in cooldown for #{remaining} more day#{"s" if remaining > 1}"
231
+ adoptable = newest_out_of_cooldown(active_spec, current_spec)
232
+ spec_outdated_info += ", newest out of cooldown #{adoptable.version}" if adoptable
233
+ end
212
234
 
213
235
  spec_outdated_info += ")"
214
236
 
@@ -227,7 +249,11 @@ module Bundler
227
249
  current_version = "#{current_spec.version}#{current_spec.git_version}"
228
250
  spec_version = "#{active_spec.version}#{active_spec.git_version}"
229
251
  remaining = cooldown_days_remaining(active_spec)
230
- spec_version += " (cooldown #{remaining}d)" if remaining
252
+ if remaining
253
+ adoptable = newest_out_of_cooldown(active_spec, current_spec)
254
+ adoptable_note = adoptable ? ", #{adoptable.version} out of cooldown" : ""
255
+ spec_version += " (cooldown #{remaining}d#{adoptable_note})"
256
+ end
231
257
  dependency = dependency.requirement if dependency
232
258
 
233
259
  ret_val = [active_spec.name, current_version, spec_version, dependency.to_s, groups.to_s]
@@ -236,7 +262,7 @@ module Bundler
236
262
  ret_val
237
263
  end
238
264
 
239
- def cooldown_days_remaining(spec, now = Time.now)
265
+ def cooldown_days_remaining(spec, now = cooldown_now)
240
266
  return nil unless spec.respond_to?(:created_at) && spec.created_at
241
267
  return nil unless spec.respond_to?(:remote) && spec.remote
242
268
  days = spec.remote.effective_cooldown
@@ -245,6 +271,10 @@ module Bundler
245
271
  remaining > 0 ? remaining.ceil : nil
246
272
  end
247
273
 
274
+ def cooldown_now
275
+ @cooldown_now ||= Time.now
276
+ end
277
+
248
278
  def check_for_deployment_mode!
249
279
  return unless Bundler.frozen_bundle?
250
280
  suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
data/lib/bundler/dsl.rb CHANGED
@@ -68,7 +68,7 @@ module Bundler
68
68
  development_group = opts[:development_group] || :development
69
69
  expanded_path = gemfile_root.join(path)
70
70
 
71
- gemspecs = Gem::Util.glob_files_in_dir("{,*}.gemspec", expanded_path).filter_map {|g| Bundler.load_gemspec(g) }
71
+ gemspecs = SharedHelpers.glob_files_in_dir("{,*}.gemspec", expanded_path).filter_map {|g| Bundler.load_gemspec(g) }
72
72
  gemspecs.reject! {|s| s.name != name } if name
73
73
  specs_by_name_and_version = gemspecs.group_by {|s| [s.name, s.version] }
74
74
 
@@ -32,7 +32,7 @@ module Bundler
32
32
 
33
33
  def initialize(base = nil, name = nil)
34
34
  @base = File.expand_path(base || SharedHelpers.pwd)
35
- gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : Gem::Util.glob_files_in_dir("{,*}.gemspec", @base)
35
+ gemspecs = name ? [File.join(@base, "#{name}.gemspec")] : SharedHelpers.glob_files_in_dir("{,*}.gemspec", @base)
36
36
  raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
37
37
  @spec_path = gemspecs.first
38
38
  @gemspec = Bundler.load_gemspec(@spec_path)
@@ -124,7 +124,7 @@ module Bundler
124
124
  end
125
125
 
126
126
  def built_gem_path
127
- Gem::Util.glob_files_in_dir("#{name}-*.gem", base).sort_by {|f| File.mtime(f) }.last
127
+ SharedHelpers.glob_files_in_dir("#{name}-*.gem", base).sort_by {|f| File.mtime(f) }.last
128
128
  end
129
129
 
130
130
  def git_push(remote = nil)
@@ -55,7 +55,7 @@ Only list patch newer versions\.
55
55
  Only list gems specified in your Gemfile, not their dependencies\.
56
56
  .TP
57
57
  \fB\-\-cooldown=<number>\fR
58
- Annotate (rather than hide) versions that are still inside the cooldown window of \fInumber\fR days\. The prose output appends "in cooldown for Nd more days" and the table form adds "(cooldown Nd)" to the Latest column\. See \fBcooldown\fR in bundle\-config(1)\.
58
+ Annotate (rather than hide) versions that are still inside the cooldown window of \fInumber\fR days\. The prose output appends "in cooldown for Nd more days" and the table form adds "(cooldown Nd)" to the Latest column\. When a version outside the window is newer than the installed one, the prose output also appends "newest out of cooldown X" and the table form becomes "(cooldown Nd, X out of cooldown)"\. With \fB\-\-filter\-strict\fR (or \fB\-\-patch\fR, \fB\-\-minor\fR, \fB\-\-major\fR, which imply it), "newest" is already the cooldown\-filtered resolved version, so none of these annotations appear\. See \fBcooldown\fR in bundle\-config(1)\.
59
59
  .SH "PATCH LEVEL OPTIONS"
60
60
  See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
61
61
  .SH "FILTERING OUTPUT"
@@ -76,7 +76,13 @@ are up to date, Bundler will exit with a status of 0. Otherwise, it will exit 1.
76
76
  Annotate (rather than hide) versions that are still inside the
77
77
  cooldown window of <number> days. The prose output appends "in
78
78
  cooldown for Nd more days" and the table form adds "(cooldown Nd)" to
79
- the Latest column. See `cooldown` in bundle-config(1).
79
+ the Latest column. When a version outside the window is newer than the
80
+ installed one, the prose output also appends "newest out of cooldown
81
+ X" and the table form becomes "(cooldown Nd, X out of cooldown)".
82
+ With `--filter-strict` (or `--patch`, `--minor`, `--major`, which
83
+ imply it), "newest" is already the cooldown-filtered resolved version,
84
+ so none of these annotations appear. See `cooldown` in
85
+ bundle-config(1).
80
86
 
81
87
  ## PATCH LEVEL OPTIONS
82
88
 
@@ -38,6 +38,8 @@ Your current platform satisfies the Ruby version requirement\.
38
38
  .IP "" 0
39
39
  .P
40
40
  \fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn't match the running Ruby VM, it tells you what part does not\.
41
+ .P
42
+ For a detailed explanation of how bundler handles platforms, see the \fBPLATFORMS\fR section in Gemfile(5)\.
41
43
  .SH "OPTIONS"
42
44
  .TP
43
45
  \fB\-\-ruby\fR
@@ -45,5 +47,7 @@ It will display the ruby directive information, so you don't have to parse it fr
45
47
  .SH "SEE ALSO"
46
48
  .IP "\(bu" 4
47
49
  bundle\-lock(1) \fIbundle\-lock\.1\.html\fR
50
+ .IP "\(bu" 4
51
+ Gemfile(5) \fIgemfile\.5\.html\fR
48
52
  .IP "" 0
49
53
 
@@ -38,6 +38,9 @@ If you run `bundle platform` on Ruby 3.1.2, it displays the following output:
38
38
  if the `ruby` directive requirement has been met. If `ruby` directive doesn't
39
39
  match the running Ruby VM, it tells you what part does not.
40
40
 
41
+ For a detailed explanation of how bundler handles platforms, see the
42
+ `PLATFORMS` section in Gemfile(5).
43
+
41
44
  ## OPTIONS
42
45
 
43
46
  * `--ruby`:
@@ -47,3 +50,4 @@ match the running Ruby VM, it tells you what part does not.
47
50
  ## SEE ALSO
48
51
 
49
52
  * [bundle-lock(1)](bundle-lock.1.html)
53
+ * [Gemfile(5)](gemfile.5.html)
@@ -392,7 +392,7 @@ gem "rails", git: "https://rails@bitbucket\.org/rails/rails\.git"
392
392
  .P
393
393
  Since the \fBbitbucket\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
394
394
  .SS "PATH"
395
- You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\.
395
+ You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\. The path must point to a directory containing the gem's unpacked source code, not to a packaged \fB\.gem\fR file\.
396
396
  .P
397
397
  Similar to the semantics of the \fB:git\fR option, the \fB:path\fR option requires that the directory in question either contains a \fB\.gemspec\fR for the gem, or that you specify an explicit version that bundler should use\.
398
398
  .P
@@ -451,7 +451,9 @@ Since the `bitbucket` method is a specialization of `git_source`, it accepts a `
451
451
 
452
452
  You can specify that a gem is located in a particular location
453
453
  on the file system. Relative paths are resolved relative to the
454
- directory containing the `Gemfile`.
454
+ directory containing the `Gemfile`. The path must point to a
455
+ directory containing the gem's unpacked source code, not to a
456
+ packaged `.gem` file.
455
457
 
456
458
  Similar to the semantics of the `:git` option, the `:path`
457
459
  option requires that the directory in question either contains
@@ -141,7 +141,7 @@ module Bundler
141
141
  end
142
142
  end
143
143
 
144
- Gem::Util.glob_files_in_dir("*/.git", cache_path.to_s).each do |git_dir|
144
+ SharedHelpers.glob_files_in_dir("*/.git", cache_path.to_s).each do |git_dir|
145
145
  FileUtils.rm_rf(git_dir)
146
146
  FileUtils.touch(File.expand_path("../.bundlecache", git_dir))
147
147
  end
@@ -159,13 +159,13 @@ module Bundler
159
159
  end
160
160
 
161
161
  def clean(dry_run = false)
162
- gem_bins = Gem::Util.glob_files_in_dir("bin/*", Gem.dir)
163
- git_dirs = Gem::Util.glob_files_in_dir("bundler/gems/*", Gem.dir)
164
- git_cache_dirs = Gem::Util.glob_files_in_dir("cache/bundler/git/*", Gem.dir)
165
- gem_dirs = Gem::Util.glob_files_in_dir("gems/*", Gem.dir)
166
- gem_files = Gem::Util.glob_files_in_dir("cache/*.gem", Gem.dir)
167
- gemspec_files = Gem::Util.glob_files_in_dir("specifications/*.gemspec", Gem.dir)
168
- extension_dirs = Gem::Util.glob_files_in_dir("extensions/*/*/*", Gem.dir) + Gem::Util.glob_files_in_dir("bundler/gems/extensions/*/*/*", Gem.dir)
162
+ gem_bins = SharedHelpers.glob_files_in_dir("bin/*", Gem.dir)
163
+ git_dirs = SharedHelpers.glob_files_in_dir("bundler/gems/*", Gem.dir)
164
+ git_cache_dirs = SharedHelpers.glob_files_in_dir("cache/bundler/git/*", Gem.dir)
165
+ gem_dirs = SharedHelpers.glob_files_in_dir("gems/*", Gem.dir)
166
+ gem_files = SharedHelpers.glob_files_in_dir("cache/*.gem", Gem.dir)
167
+ gemspec_files = SharedHelpers.glob_files_in_dir("specifications/*.gemspec", Gem.dir)
168
+ extension_dirs = SharedHelpers.glob_files_in_dir("extensions/*/*/*", Gem.dir) + SharedHelpers.glob_files_in_dir("bundler/gems/extensions/*/*/*", Gem.dir)
169
169
  spec_gem_paths = []
170
170
  # need to keep git sources around
171
171
  spec_git_paths = @definition.spec_git_paths
@@ -232,7 +232,7 @@ module Bundler
232
232
  private
233
233
 
234
234
  def prune_gem_cache(resolve, cache_path)
235
- cached = Gem::Util.glob_files_in_dir("*.gem", cache_path.to_s)
235
+ cached = SharedHelpers.glob_files_in_dir("*.gem", cache_path.to_s)
236
236
 
237
237
  cached = cached.delete_if do |path|
238
238
  spec = Bundler.rubygems.spec_from_gem path
@@ -257,7 +257,7 @@ module Bundler
257
257
  end
258
258
 
259
259
  def prune_git_and_path_cache(resolve, cache_path)
260
- cached = Gem::Util.glob_files_in_dir("*/.bundlecache", cache_path.to_s)
260
+ cached = SharedHelpers.glob_files_in_dir("*/.bundlecache", cache_path.to_s)
261
261
 
262
262
  cached = cached.delete_if do |path|
263
263
  name = File.basename(File.dirname(path))
@@ -283,7 +283,7 @@ module Bundler
283
283
  # Add man/ subdirectories from activated bundles to MANPATH for man(1)
284
284
  manuals = $LOAD_PATH.filter_map do |path|
285
285
  man_subdir = path.sub(/lib$/, "man")
286
- man_subdir unless Dir.glob("man?/", base: man_subdir).empty?
286
+ man_subdir unless SharedHelpers.glob_files_in_dir("man?/", man_subdir).empty?
287
287
  end
288
288
 
289
289
  return if manuals.empty?
@@ -231,6 +231,21 @@ module Bundler
231
231
  destination
232
232
  end
233
233
 
234
+ # Globs for entries matching +glob+ inside of +base_path+, returning
235
+ # absolute paths. Glob metacharacters in +base_path+ are not treated as
236
+ # part of the pattern, and matched entries are joined literally, so an
237
+ # entry starting with `~` is not expanded into the home directory.
238
+ #
239
+ # Bundler runs against whatever RubyGems the host provides, so this cannot
240
+ # delegate to Gem::Util.glob_files_in_dir, which only gained the literal
241
+ # join in RubyGems 4.1.
242
+ def glob_files_in_dir(glob, base_path)
243
+ expanded_path = nil
244
+ Dir.glob(glob, base: base_path).map! do |f|
245
+ File.join(expanded_path ||= File.expand_path(base_path), f)
246
+ end
247
+ end
248
+
234
249
  private
235
250
 
236
251
  def validate_bundle_path
@@ -193,7 +193,13 @@ module Bundler
193
193
  return out if status.success?
194
194
 
195
195
  if err.include?("couldn't find remote ref") || err.include?("not our ref")
196
- raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref, credential_filtered_uri)
196
+ default_branch = renamed_remote_default_branch if tracking_remote_default_branch?
197
+ if default_branch
198
+ out = follow_remote_default_branch(args, default_branch)
199
+ return out if out
200
+ end
201
+
202
+ raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref || current_branch, credential_filtered_uri)
197
203
  else
198
204
  if shallow?
199
205
  args -= depth_args
@@ -298,6 +304,61 @@ module Bundler
298
304
  branch_option || ref.nil?
299
305
  end
300
306
 
307
+ def tracking_remote_default_branch?
308
+ explicit_ref.nil? && commit.nil?
309
+ end
310
+
311
+ # Returns nil on any failure, leaving HEAD untouched so the caller reports
312
+ # the original fetch failure. Runs inside the retry block, so it must not
313
+ # touch the caller's command locals.
314
+ def follow_remote_default_branch(args, default_branch)
315
+ reference = "refs/heads/#{default_branch}"
316
+ command = fetch_command(args, "#{reference}:#{reference}")
317
+ check_allowed(command)
318
+
319
+ out, err, status = capture(command, path)
320
+ unless status.success?
321
+ Bundler.ui.debug "Could not fetch #{reference} from #{credential_filtered_uri}: #{err}"
322
+ return
323
+ end
324
+
325
+ previous_branch = current_branch
326
+ begin
327
+ git "symbolic-ref", "HEAD", reference, dir: path
328
+ rescue GitError => e
329
+ Bundler.ui.debug "Could not repoint the cached clone at #{reference}: #{e.message}"
330
+ return
331
+ end
332
+ @current_branch = nil
333
+ Bundler.ui.warn "#{credential_filtered_uri} no longer has #{previous_branch}, " \
334
+ "now following its default branch #{default_branch}"
335
+ out
336
+ end
337
+
338
+ # The cached clone's HEAD branch is gone from the remote, so the remote's
339
+ # own idea of its default branch is the only thing left to follow.
340
+ def renamed_remote_default_branch
341
+ default_branch = remote_default_branch
342
+ return if default_branch.nil? || default_branch == current_branch
343
+
344
+ default_branch
345
+ end
346
+
347
+ def remote_default_branch
348
+ command = ["ls-remote", "--symref", "--", configured_uri, "HEAD"]
349
+ check_allowed(command)
350
+
351
+ out, err, status = capture(command, path)
352
+ unless status.success?
353
+ Bundler.ui.debug "Could not ask #{credential_filtered_uri} for its default branch: #{err}"
354
+ return
355
+ end
356
+
357
+ # A remote is free to advertise a ref name that is not valid UTF-8, and
358
+ # matching that as text raises out of the GitError family.
359
+ out.b[%r{^ref:\s+refs/heads/(.+?)\s+HEAD}, 1]
360
+ end
361
+
301
362
  def pinned_to_full_sha?
302
363
  full_sha_revision?(ref)
303
364
  end
@@ -465,8 +526,8 @@ module Bundler
465
526
  args
466
527
  end
467
528
 
468
- def fetch_command(args)
469
- ["fetch", "--force", "--quiet", "--no-tags", *args, "--", configured_uri, refspec].compact
529
+ def fetch_command(args, spec = refspec)
530
+ ["fetch", "--force", "--quiet", "--no-tags", *args, "--", configured_uri, spec].compact
470
531
  end
471
532
 
472
533
  def clone_command(args)
@@ -91,9 +91,9 @@ module Bundler
91
91
 
92
92
  def to_s
93
93
  begin
94
- at = humanized_ref || current_branch
95
-
96
- rev = "at #{at}@#{shortref_for_display(revision)}"
94
+ at = humanized_ref
95
+ at = "#{at}@" if at
96
+ rev = "at #{at}#{shortref_for_display(revision)}"
97
97
  rescue GitError
98
98
  ""
99
99
  end
@@ -320,7 +320,7 @@ module Bundler
320
320
 
321
321
  def serialize_gemspecs_in(destination)
322
322
  destination = destination.expand_path(Bundler.root) if destination.relative?
323
- Gem::Util.glob_files_in_dir(@glob, destination.to_s).each do |spec_path|
323
+ SharedHelpers.glob_files_in_dir(@glob, destination.to_s).each do |spec_path|
324
324
  # Evaluate gemspecs and cache the result. Gemspecs
325
325
  # in git might require git or other dependencies.
326
326
  # The gemspecs we cache should already be evaluated.
@@ -161,7 +161,7 @@ module Bundler
161
161
 
162
162
  if File.directory?(expanded_path)
163
163
  # We sort depth-first since `<<` will override the earlier-found specs
164
- Gem::Util.glob_files_in_dir(@glob, expanded_path).sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
164
+ SharedHelpers.glob_files_in_dir(@glob, expanded_path).sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
165
165
  next unless spec = load_gemspec(file)
166
166
  spec.source = self
167
167
 
@@ -406,7 +406,7 @@ module Bundler
406
406
  @cached_specs ||= begin
407
407
  idx = Index.new
408
408
 
409
- Gem::Util.glob_files_in_dir("*.gem", cache_path.to_s).each do |gemfile|
409
+ SharedHelpers.glob_files_in_dir("*.gem", cache_path.to_s).each do |gemfile|
410
410
  s ||= Bundler.rubygems.spec_from_gem(gemfile)
411
411
  s.source = self
412
412
  idx << s
@@ -126,7 +126,9 @@ module Bundler
126
126
  def _remote_specification
127
127
  @_remote_specification ||= begin
128
128
  rs = stub.to_spec
129
- if rs.equal?(self) # happens when to_spec gets the spec from Gem.loaded_specs
129
+ # Gem::StubSpecification#to_spec may return an activated specification
130
+ # with the same name and version from a different gem installation.
131
+ if rs.equal?(self) || rs.loaded_from != loaded_from
130
132
  rs = Gem::Specification.load(loaded_from)
131
133
  Bundler.rubygems.stub_set_spec(stub, rs)
132
134
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "4.0.19".freeze
4
+ VERSION = "4.0.20".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= gem_version.segments.first
data/lib/bundler.rb CHANGED
@@ -527,11 +527,11 @@ module Bundler
527
527
  end
528
528
 
529
529
  def load_gemspec_uncached(file, validate = false)
530
- path = Pathname.new(file)
531
- contents = read_file(file)
530
+ path = Pathname.new(file).expand_path
531
+ contents = read_file(path.to_s)
532
532
  spec = eval_gemspec(path, contents)
533
533
  return unless spec
534
- spec.loaded_from = path.expand_path.to_s
534
+ spec.loaded_from = path.to_s
535
535
  Bundler.rubygems.validate(spec) if validate
536
536
  spec
537
537
  end
@@ -646,9 +646,19 @@ module Bundler
646
646
  eval_yaml_gemspec(path, contents)
647
647
  else
648
648
  # Eval the gemspec from its parent directory, because some gemspecs
649
- # depend on "./" relative paths.
649
+ # depend on "./" relative paths. The caller expands `path` first, since
650
+ # expanding it here would resolve against the gemspec directory once
651
+ # the chdir is active.
650
652
  SharedHelpers.chdir(path.dirname.to_s) do
651
- eval(contents, TOPLEVEL_BINDING.dup, path.expand_path.to_s)
653
+ # TOPLEVEL_BINDING always belongs to the main box, so inside a
654
+ # Ruby::Box use a binding from the box Bundler is loaded in, where
655
+ # Gem::Specification carries Bundler's own monkey patches.
656
+ eval_binding = if defined?(Ruby::Box) && Ruby::Box.enabled?
657
+ Ruby::Box.current.eval("binding")
658
+ else
659
+ TOPLEVEL_BINDING.dup
660
+ end
661
+ eval(contents, eval_binding, path.to_s)
652
662
  end
653
663
  end
654
664
  rescue ScriptError, StandardError => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.19
4
+ version: 4.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  - !ruby/object:Gem::Version
402
402
  version: 3.4.1
403
403
  requirements: []
404
- rubygems_version: 3.6.9
404
+ rubygems_version: 4.0.16
405
405
  specification_version: 4
406
406
  summary: The best way to manage your application's dependencies
407
407
  test_files: []