1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[rubygems/rubygems] Fix bundle install to force reinstallation of deleted gems

8950631f02
This commit is contained in:
David Rodriguez 2021-10-09 13:42:05 +02:00 committed by git
parent bd87397f73
commit 0f1f95a3e3
4 changed files with 23 additions and 5 deletions

View file

@ -45,7 +45,7 @@ module Bundler
path = File.expand_path("../../../..", __FILE__)
else
path = spec.full_gem_path
unless File.directory?(path)
if spec.deleted_gem?
return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}"
end
end
@ -56,7 +56,6 @@ module Bundler
def print_gem_info(spec)
metadata = spec.metadata
name = spec.name
path = spec.full_gem_path
gem_info = String.new
gem_info << " * #{name} (#{spec.version}#{spec.git_version})\n"
gem_info << "\tSummary: #{spec.summary}\n" if spec.summary
@ -68,10 +67,10 @@ module Bundler
gem_info << "\tChangelog: #{metadata["changelog_uri"]}\n" if metadata.key?("changelog_uri")
gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri")
gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri")
gem_info << "\tPath: #{path}\n"
gem_info << "\tPath: #{spec.full_gem_path}\n"
gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem?
unless File.directory?(path)
if spec.deleted_gem?
return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}"
end

View file

@ -85,6 +85,10 @@ module Gem
dependencies - development_dependencies
end
def deleted_gem?
!default_gem? && !File.directory?(full_gem_path)
end
private
def dependencies_to_gemfile(dependencies, group = nil)

View file

@ -480,7 +480,7 @@ module Bundler
end
def installed?(spec)
installed_specs[spec].any?
installed_specs[spec].any? && !spec.deleted_gem?
end
def requires_sudo?

View file

@ -94,6 +94,21 @@ RSpec.describe "bundle install with gem sources" do
expect(the_bundle).to include_gems("rack 1.0.0")
end
it "auto-heals missing gems" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
FileUtils.rm_rf(default_bundle_path("gems/rack-1.0.0"))
bundle "install --verbose"
expect(out).to include("Installing rack 1.0.0")
expect(default_bundle_path("gems/rack-1.0.0")).to exist
expect(the_bundle).to include_gems("rack 1.0.0")
end
it "fetches gems when multiple versions are specified" do
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"