summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSchneems <richard.schneeman+foo@gmail.com>2025-12-26 12:21:51 -0600
committergit <svn-admin@ruby-lang.org>2026-01-06 04:38:13 +0000
commitad6b85450db1b252660dae4b514f5be35ccd38b9 (patch)
treee4792dbd2014f377f64f821ba81ead5c77c440be /lib
parent4377249bbf1a27b3d860ab8948b508f1b024ba1c (diff)
[ruby/rubygems] Retain current bundler version on `bundle clean`
Previously: In #9218 a reproduction is shared where running `bundle clean` using a binstub (`bin/bundle`) results in bundler removing itself. This results in Ruby falling back to its default bundler version. This behavior seems to be present for as long as there has been a default version of bundler (Ruby 2.6+). Now: Bundler will explicitly add its current version number to the specs to be preserved. This prevents `bundle clean` from removing the current bundler version. close https://github.com/ruby/rubygems/pull/9218 https://github.com/ruby/rubygems/commit/e3f0167ae4
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/runtime.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index f632ce9144..5280e72aa2 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -175,6 +175,12 @@ module Bundler
spec_gemspec_paths = []
spec_extension_paths = []
specs_to_keep = Bundler.rubygems.add_default_gems_to(specs).values
+
+ current_bundler = Bundler.rubygems.find_bundler(Bundler.gem_version)
+ if current_bundler
+ specs_to_keep << current_bundler
+ end
+
specs_to_keep.each do |spec|
spec_gem_paths << spec.full_gem_path
# need to check here in case gems are nested like for the rails git repo