diff options
author | David RodrÃguez <[email protected]> | 2024-12-23 17:46:32 +0100 |
---|---|---|
committer | git <[email protected]> | 2024-12-26 18:09:15 +0000 |
commit | 11c9e4f1ceb90d73e1eac6acbf3434a6f7216044 (patch) | |
tree | 8ab289f5e36b85ca89f9a2ed03b00aafe9e773c3 | |
parent | d78ff6a767ca813ac5fa178dd7611f20a993c191 (diff) |
[rubygems/rubygems] Fix `bundle outdated <GEM>` failing if gems not installed
https://github.com/rubygems/rubygems/commit/694d5f444e
-rw-r--r-- | lib/bundler/cli/outdated.rb | 10 | ||||
-rw-r--r-- | spec/bundler/commands/outdated_spec.rb | 38 |
2 files changed, 44 insertions, 4 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 75fcdca641..1be44ff4b4 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -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 diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 449fba5935..38121ce50e 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -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 |