From ac093f4350ae8f41ef18ac64829ea9dbc272063d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 31 Jan 2025 16:20:54 +0100 Subject: [PATCH] [rubygems/rubygems] Auto-heal empty installation directory https://github.com/rubygems/rubygems/commit/9720a9b980 --- lib/bundler/rubygems_ext.rb | 2 +- spec/bundler/commands/install_spec.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index 33463618e5..50c650d378 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -259,7 +259,7 @@ module Gem end def installation_missing? - !default_gem? && !File.directory?(full_gem_path) + !default_gem? && (!Dir.exist?(full_gem_path) || Dir.empty?(full_gem_path)) end unless VALIDATES_FOR_RESOLUTION diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 3abe021855..92c8f52195 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -100,12 +100,23 @@ RSpec.describe "bundle install with gem sources" do gem 'myrack' G - FileUtils.rm_rf(default_bundle_path("gems/myrack-1.0.0")) + gem_dir = default_bundle_path("gems/myrack-1.0.0") + + FileUtils.rm_rf(gem_dir) bundle "install --verbose" expect(out).to include("Installing myrack 1.0.0") - expect(default_bundle_path("gems/myrack-1.0.0")).to exist + expect(gem_dir).to exist + expect(the_bundle).to include_gems("myrack 1.0.0") + + FileUtils.rm_rf(gem_dir) + Dir.mkdir(gem_dir) + + bundle "install --verbose" + + expect(out).to include("Installing myrack 1.0.0") + expect(gem_dir).to exist expect(the_bundle).to include_gems("myrack 1.0.0") end