Skip to content

Commit ad6b854

Browse files
schneemsmatzbot
authored andcommitted
[ruby/rubygems] Retain current bundler version on bundle clean
Previously: In ruby#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 ruby/rubygems#9218 ruby/rubygems@e3f0167ae4
1 parent 4377249 commit ad6b854

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

lib/bundler/runtime.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ def clean(dry_run = false)
175175
spec_gemspec_paths = []
176176
spec_extension_paths = []
177177
specs_to_keep = Bundler.rubygems.add_default_gems_to(specs).values
178+
179+
current_bundler = Bundler.rubygems.find_bundler(Bundler.gem_version)
180+
if current_bundler
181+
specs_to_keep << current_bundler
182+
end
183+
178184
specs_to_keep.each do |spec|
179185
spec_gem_paths << spec.full_gem_path
180186
# need to check here in case gems are nested like for the rails git repo

0 commit comments

Comments
 (0)