[rubygems/rubygems] Refine messages about gem installations being missing

The previous wording was too specific, there may be situations when the
gem has actually never installed (so never deleted either).

https://github.com/rubygems/rubygems/commit/e4a0d71fbe
This commit is contained in:
David Rodríguez 2025-01-31 16:20:39 +01:00 committed by Hiroshi SHIBATA
parent 385dc5dc16
commit 78ef59acf7
6 changed files with 15 additions and 15 deletions

View File

@ -39,8 +39,8 @@ module Bundler
path = File.expand_path("../../..", __dir__) path = File.expand_path("../../..", __dir__)
else else
path = spec.full_gem_path path = spec.full_gem_path
if spec.deleted_gem? if spec.installation_missing?
return Bundler.ui.warn "The gem #{name} has been deleted. It was installed at: #{path}" return Bundler.ui.warn "The gem #{name} is missing. It should be installed at #{path}, but was not found"
end end
end end
@ -65,8 +65,8 @@ module Bundler
gem_info << "\tDefault Gem: yes\n" if spec.respond_to?(:default_gem?) && spec.default_gem? gem_info << "\tDefault Gem: yes\n" if spec.respond_to?(:default_gem?) && spec.default_gem?
gem_info << "\tReverse Dependencies: \n\t\t#{gem_dependencies.join("\n\t\t")}" if gem_dependencies.any? gem_info << "\tReverse Dependencies: \n\t\t#{gem_dependencies.join("\n\t\t")}" if gem_dependencies.any?
if name != "bundler" && spec.deleted_gem? if name != "bundler" && spec.installation_missing?
return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}" return Bundler.ui.warn "The gem #{name} is missing. Gemspec information is still available though:\n#{gem_info}"
end end
Bundler.ui.info gem_info Bundler.ui.info gem_info

View File

@ -24,7 +24,7 @@ module Bundler
return unless spec return unless spec
path = spec.full_gem_path path = spec.full_gem_path
unless File.directory?(path) unless File.directory?(path)
return Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at: #{path}" return Bundler.ui.warn "The gem #{gem_name} is missing. It should be installed at #{path}, but was not found"
end end
end end
return Bundler.ui.info(path) return Bundler.ui.info(path)

View File

@ -258,7 +258,7 @@ module Gem
dependencies - development_dependencies dependencies - development_dependencies
end end
def deleted_gem? def installation_missing?
!default_gem? && !File.directory?(full_gem_path) !default_gem? && !File.directory?(full_gem_path)
end end

View File

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

View File

@ -56,12 +56,12 @@ RSpec.describe "bundle info" do
expect(out).to eq("2.3.2") expect(out).to eq("2.3.2")
end end
it "doesn't claim that bundler has been deleted, even if using a custom path without bundler there" do it "doesn't claim that bundler is missing, even if using a custom path without bundler there" do
bundle "config set --local path vendor/bundle" bundle "config set --local path vendor/bundle"
bundle "install" bundle "install"
bundle "info bundler" bundle "info bundler"
expect(out).to include("\tPath: #{root}") expect(out).to include("\tPath: #{root}")
expect(err).not_to match(/The gem bundler has been deleted/i) expect(err).not_to match(/The gem bundler is missing/i)
end end
it "complains if gem not in bundle" do it "complains if gem not in bundle" do
@ -69,20 +69,20 @@ RSpec.describe "bundle info" do
expect(err).to eq("Could not find gem 'missing'.") expect(err).to eq("Could not find gem 'missing'.")
end end
it "warns if path no longer exists on disk" do it "warns if path does not exist on disk, but specification is there" do
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2")) FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
bundle "info rails --path" bundle "info rails --path"
expect(err).to include("The gem rails has been deleted.") expect(err).to include("The gem rails is missing.")
expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
bundle "info rail --path" bundle "info rail --path"
expect(err).to include("The gem rails has been deleted.") expect(err).to include("The gem rails is missing.")
expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
bundle "info rails" bundle "info rails"
expect(err).to include("The gem rails has been deleted.") expect(err).to include("The gem rails is missing.")
expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s) expect(err).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
end end

View File

@ -35,12 +35,12 @@ RSpec.describe "bundle show", bundler: "< 3" do
expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s)
end end
it "warns if path no longer exists on disk" do it "warns if specification is installed, but path does not exist on disk" do
FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2")) FileUtils.rm_rf(default_bundle_path("gems", "rails-2.3.2"))
bundle "show rails" bundle "show rails"
expect(err).to match(/has been deleted/i) expect(err).to match(/is missing/i)
expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s)
end end