[rubygems/rubygems] Fix bundle outdated <GEM> failing if gems not installed

https://github.com/rubygems/rubygems/commit/694d5f444e
This commit is contained in:
David Rodríguez 2024-12-23 17:46:32 +01:00 committed by git
parent d78ff6a767
commit 11c9e4f1ce
2 changed files with 44 additions and 4 deletions

View File

@ -26,13 +26,15 @@ module Bundler
def run
check_for_deployment_mode!
gems.each do |gem_name|
Bundler::CLI::Common.select_spec(gem_name)
end
Bundler.definition.validate_runtime!
current_specs = Bundler.ui.silence { Bundler.definition.resolve }
gems.each do |gem_name|
if current_specs[gem_name].empty?
raise GemNotFound, "Could not find gem '#{gem_name}'."
end
end
current_dependencies = Bundler.ui.silence do
Bundler.load.dependencies.map {|dep| [dep.name, dep] }.to_h
end

View File

@ -526,6 +526,44 @@ RSpec.describe "bundle outdated" do
expect(out).to match(Regexp.new(expected_output))
end
it "does not require gems to be installed" do
build_repo4 do
build_gem "zeitwerk", "1.0.0"
build_gem "zeitwerk", "2.0.0"
end
gemfile <<-G
source "https://gem.repo4"
gem "zeitwerk"
G
lockfile <<~L
GEM
remote: https://gem.repo4/
specs:
zeitwerk (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
zeitwerk
BUNDLED WITH
#{Bundler::VERSION}
L
bundle "outdated zeitwerk", raise_on_error: false
expected_output = <<~TABLE.tr(".", "\.").strip
Gem Current Latest Requested Groups
zeitwerk 1.0.0 2.0.0 >= 0 default
TABLE
expect(out).to match(Regexp.new(expected_output))
expect(err).to be_empty
end
end
describe "pre-release gems" do